From 41f480554c664fb7e7b28c22da9231b90868985f Mon Sep 17 00:00:00 2001 From: Hagernesh Date: Fri, 14 Aug 2026 07:16:19 +0000 Subject: [PATCH] feat(billing): add PNR row to freight invoice from booking payment reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PNR isn't a column on Invoice/Payment — it's written onto Booking.pnrCode when a CBE_BILL payment initiates. toDocumentModel() now looks it up by invoice.sourceId and adds it to the existing summary grid, shown only when present. --- .../src/modules/billing/billing.service.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/edr-freight-api/src/modules/billing/billing.service.ts b/apps/edr-freight-api/src/modules/billing/billing.service.ts index bc79f8899..5afa30128 100644 --- a/apps/edr-freight-api/src/modules/billing/billing.service.ts +++ b/apps/edr-freight-api/src/modules/billing/billing.service.ts @@ -513,6 +513,17 @@ export class BillingService { // MoR EIMS reference — only once actually registered, never a placeholder row. if (invoice.eimsIrn) summary.push({ label: "EIMS IRN", value: invoice.eimsIrn }); + // PNR — the CBE_BILL reference the customer pays against, written onto the booking at + // payment-initiation time (see initiatePayment()). Not a column on Invoice/Payment, so + // look it up by source id; only shown once a payment actually generated one. + if (invoice.source === Freight.InvoiceSource.Booking) { + const booking = await this.dataSource.getRepository(Booking).findOne({ + where: { id: invoice.sourceId }, + select: ["id", "pnrCode"], + }); + if (booking?.pnrCode) summary.push({ label: "PNR", value: booking.pnrCode }); + } + return { kind, title,