mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 12:30:58 +00:00
feat(billing): enhance invoice payment processing and revert handling
feat(bookings): add event handlers for booking invoice payment processing fix(bookings): include PAYMENT_VERIFICATION_IN_PROGRESS status in queries fix(train-scheduling): update status checks to include PAYMENT_VERIFICATION_IN_PROGRESS feat(notifier): notify customers when a train is cancelled
This commit is contained in:
@@ -1058,16 +1058,24 @@ export class BillingService {
|
||||
* settlement; settleByPaymentId still performs the real transition.
|
||||
*/
|
||||
async markInvoicePaymentProcessing(paymentId: string): Promise<void> {
|
||||
await this.dataSource.getRepository(Invoice).update(
|
||||
{
|
||||
paymentId,
|
||||
status: In([
|
||||
Freight.InvoiceStatus.Issued,
|
||||
Freight.InvoiceStatus.Pending,
|
||||
]),
|
||||
},
|
||||
{ status: Freight.InvoiceStatus.PaymentProcessing },
|
||||
);
|
||||
const repo = this.dataSource.getRepository(Invoice);
|
||||
const invoices = await repo.findBy({
|
||||
paymentId,
|
||||
status: In([
|
||||
Freight.InvoiceStatus.Issued,
|
||||
Freight.InvoiceStatus.Pending,
|
||||
]),
|
||||
});
|
||||
for (const invoice of invoices) {
|
||||
await repo.update(
|
||||
{ id: invoice.id, status: invoice.status },
|
||||
{ status: Freight.InvoiceStatus.PaymentProcessing },
|
||||
);
|
||||
this.emitInvoiceEvent("payment-processing", {
|
||||
...invoice,
|
||||
status: Freight.InvoiceStatus.PaymentProcessing,
|
||||
} as Invoice);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1076,12 +1084,21 @@ export class BillingService {
|
||||
* retry. No-op from any other status.
|
||||
*/
|
||||
async revertInvoicePaymentProcessing(paymentId: string): Promise<void> {
|
||||
await this.dataSource
|
||||
.getRepository(Invoice)
|
||||
.update(
|
||||
{ paymentId, status: Freight.InvoiceStatus.PaymentProcessing },
|
||||
const repo = this.dataSource.getRepository(Invoice);
|
||||
const invoices = await repo.findBy({
|
||||
paymentId,
|
||||
status: Freight.InvoiceStatus.PaymentProcessing,
|
||||
});
|
||||
for (const invoice of invoices) {
|
||||
await repo.update(
|
||||
{ id: invoice.id, status: Freight.InvoiceStatus.PaymentProcessing },
|
||||
{ status: Freight.InvoiceStatus.Pending },
|
||||
);
|
||||
this.emitInvoiceEvent("payment-processing-reverted", {
|
||||
...invoice,
|
||||
status: Freight.InvoiceStatus.Pending,
|
||||
} as Invoice);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Payment initiation & settlement (the gateway boundary) ───────────────────
|
||||
|
||||
Reference in New Issue
Block a user