mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 16:28:12 +00:00
fix(temp): invoice no for the telebirr
This commit is contained in:
@@ -829,7 +829,10 @@ export class BillingService {
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const mg = manager ?? this.dataSource.manager;
|
const mg = manager ?? this.dataSource.manager;
|
||||||
const invoice = await mg.findOne(Invoice, {
|
const invoice = await mg.findOne(Invoice, {
|
||||||
where: { id: invoiceId, status: In([Freight.InvoiceStatus.Draft, ...OPEN_STATUSES]) },
|
where: {
|
||||||
|
id: invoiceId,
|
||||||
|
status: In([Freight.InvoiceStatus.Draft, ...OPEN_STATUSES]),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!invoice) return;
|
if (!invoice) return;
|
||||||
await mg.update(
|
await mg.update(
|
||||||
@@ -882,7 +885,7 @@ export class BillingService {
|
|||||||
// in the domain via `${source}.invoice.paid`. Neither billing nor the payment
|
// in the domain via `${source}.invoice.paid`. Neither billing nor the payment
|
||||||
// service branches on a domain-specific reference type.
|
// service branches on a domain-specific reference type.
|
||||||
referenceType: PaymentReferenceType.SHIPMENT,
|
referenceType: PaymentReferenceType.SHIPMENT,
|
||||||
orderRef: invoice.invoiceNumber,
|
orderRef: invoice.invoiceNumber.replace("-", "_"),
|
||||||
amountMinor: Math.round(Number(invoice.balanceAmount)),
|
amountMinor: Math.round(Number(invoice.balanceAmount)),
|
||||||
currency: invoice.currency,
|
currency: invoice.currency,
|
||||||
reason: `Payment for invoice ${invoice.invoiceNumber}`,
|
reason: `Payment for invoice ${invoice.invoiceNumber}`,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
Injectable,
|
Injectable,
|
||||||
Logger,
|
Logger,
|
||||||
} from "@nestjs/common";
|
} from "@nestjs/common";
|
||||||
import { OnEvent } from "@nestjs/event-emitter";
|
|
||||||
import { Freight } from "@edr/types";
|
import { Freight } from "@edr/types";
|
||||||
import { DataSource, EntityManager } from "typeorm";
|
import { DataSource, EntityManager } from "typeorm";
|
||||||
|
|
||||||
@@ -95,8 +94,10 @@ export class BookingInvoiceService {
|
|||||||
* reactions live here (not in the payment process): each invoice type advances
|
* reactions live here (not in the payment process): each invoice type advances
|
||||||
* the booking its own way. Only PREPAID exists today.
|
* the booking its own way. Only PREPAID exists today.
|
||||||
*/
|
*/
|
||||||
@OnEvent("booking.invoice.paid")
|
|
||||||
async onBookingInvoicePaid(payload: InvoiceEventPayload): Promise<void> {
|
async onBookingInvoicePaid(payload: InvoiceEventPayload): Promise<void> {
|
||||||
|
this.logger.log(
|
||||||
|
`onBookingInvoicePaid trigger for ${payload.sourceId} from ${payload.invoiceId}`,
|
||||||
|
);
|
||||||
switch (payload.type) {
|
switch (payload.type) {
|
||||||
case "PREPAID":
|
case "PREPAID":
|
||||||
await this.advanceBookingOnPayment(payload.sourceId);
|
await this.advanceBookingOnPayment(payload.sourceId);
|
||||||
|
|||||||
Reference in New Issue
Block a user