style: clean up the invoice and setup event for warehouse.

This commit is contained in:
Nathnael
2026-06-30 13:28:14 +00:00
parent fa3138f2ac
commit 0056dec924
5 changed files with 30 additions and 68 deletions

View File

@@ -96,11 +96,6 @@ export interface GenerateInvoiceInput {
* (default PENDING) stamps `issuedAt`.
*/
status?: Freight.InvoiceStatus;
/**
* Document number prefix for this source (e.g. `WHF` for warehouse fees);
* defaults to `FRT`. The daily sequence is allocated per prefix.
*/
numberCode?: string;
}
/** Payload broadcast on `${source}.invoice.<event>`. */
@@ -665,11 +660,12 @@ export class BillingService {
const result = await this.payment.initiate({
referenceId: sourceId,
source: invoice.source,
// Gateway reference type derives from the invoice source by convention
// (source.toUpperCase() ∈ PaymentReferenceType) — no domain word here, and
// the domain never supplies it. New sources add their uppercased value to
// the PaymentReferenceType enum.
referenceType: invoice.source.toUpperCase() as PaymentReferenceType,
// Freight payments settle under the generic SHIPMENT reference — how the
// payment service attributes them to the freight API. The payment ↔ invoice
// link is the intent id (`paymentId`); per-source post-payment reactions live
// in the domain via `${source}.invoice.paid`. Neither billing nor the payment
// service branches on a domain-specific reference type.
referenceType: PaymentReferenceType.SHIPMENT,
orderRef: invoice.invoiceNumber,
amountMinor: Math.round(Number(invoice.totalAmount)),
currency: invoice.currency,