feat(freight): surface scheduling clock and gate pay during drain

This commit is contained in:
marshalyordanos
2026-08-10 21:47:28 +03:00
parent d3096939e7
commit 40672e9c41
14 changed files with 524 additions and 25 deletions

View File

@@ -3680,23 +3680,24 @@ export class BookingBatchService implements OnModuleInit {
// (provider query errored / payment still in flight) means we could not
// confirm "not paid" — never expire on unknown; the next settle tick
// asks again.
if (reason === "payment" && (fresh?.paymentDeadline ?? booking.paymentDeadline)) {
const reconcile = await this.billing.reconcilePayable(booking.id);
if (reconcile.paid) {
this.logger.log(
`[BATCH] expire skipped for ${booking.reference} — gateway ` +
`reconcile found a settled payment; payment.succeeded will allocate it`,
);
return;
}
if (reconcile.unverifiable) {
this.logger.warn(
`[BATCH] expire deferred for ${booking.reference} — settlement ` +
`unverifiable at the gateway; retrying next settle tick`,
);
return;
}
}
// TODO: CBE has no reconcile endpoint yet — re-enable once available.
// if (reason === "payment" && (fresh?.paymentDeadline ?? booking.paymentDeadline)) {
// const reconcile = await this.billing.reconcilePayable(booking.id);
// if (reconcile.paid) {
// this.logger.log(
// `[BATCH] expire skipped for ${booking.reference} — gateway ` +
// `reconcile found a settled payment; payment.succeeded will allocate it`,
// );
// return;
// }
// if (reconcile.unverifiable) {
// this.logger.warn(
// `[BATCH] expire deferred for ${booking.reference} — settlement ` +
// `unverifiable at the gateway; retrying next settle tick`,
// );
// return;
// }
// }
}
const freedScheduleId = booking.trainScheduleId;
await this.bookingsRepository.update(booking.id, {