mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 01:20:55 +00:00
changes export flow
This commit is contained in:
@@ -1002,6 +1002,23 @@ export class BillingService {
|
||||
);
|
||||
}
|
||||
|
||||
// A booking's PREPAID invoice is only payable inside its pay window —
|
||||
// `dueAt` mirrors booking.paymentDeadline (issuePayable at reserve time).
|
||||
// Blocking INITIATION here is what makes the deadline real: the settle
|
||||
// sweep's grace only shelters payments that started before this gate.
|
||||
// Other invoice types keep dueAt as display-only.
|
||||
if (
|
||||
invoice.source === Freight.InvoiceSource.Booking &&
|
||||
invoice.type === "PREPAID" &&
|
||||
invoice.dueAt &&
|
||||
invoice.dueAt.getTime() <= Date.now()
|
||||
) {
|
||||
throw new BadRequestException(
|
||||
"The payment window for this booking has closed — the reserved wagons " +
|
||||
"were released. Please book again.",
|
||||
);
|
||||
}
|
||||
|
||||
const amountDue = Number(invoice.balanceAmount ?? invoice.totalAmount);
|
||||
if (!(amountDue > 0)) {
|
||||
throw new BadRequestException("Invoice has no outstanding balance.");
|
||||
|
||||
Reference in New Issue
Block a user