feat: update invoice processing to use last_tsp_status for status mapping
This commit is contained in:
@@ -245,9 +245,7 @@ export class SharedSaleInvoiceCreateService {
|
||||
}
|
||||
|
||||
return customerIndividualId
|
||||
}
|
||||
|
||||
if (customer_type === CustomerType.LEGAL && customer?.customer_legal) {
|
||||
} else if (customer_type === CustomerType.LEGAL && customer?.customer_legal) {
|
||||
const { registration_number, economic_code, postal_code } = customer.customer_legal
|
||||
const foundedCustomer = await tx.customerLegal.findFirst({
|
||||
where: {
|
||||
@@ -454,6 +452,8 @@ export class SharedSaleInvoiceCreateService {
|
||||
id: customerId,
|
||||
},
|
||||
}
|
||||
} else if (data.customer?.customer_unknown) {
|
||||
salesInvoiceData.unknown_customer = data.customer.customer_unknown
|
||||
}
|
||||
|
||||
if (type !== TspProviderRequestType.ORIGINAL) {
|
||||
|
||||
@@ -10,13 +10,13 @@ export class StatisticsService {
|
||||
constructor(private readonly prisma: PrismaService) {}
|
||||
|
||||
private readonly invoiceMapper = (invoice: any) => {
|
||||
const { tsp_attempts, ...rest } = invoice || {}
|
||||
const { last_tsp_status, ...rest } = invoice || {}
|
||||
|
||||
return {
|
||||
...rest,
|
||||
status: translateEnumValue(
|
||||
'TspProviderResponseStatus',
|
||||
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
last_tsp_status || TspProviderResponseStatus.NOT_SEND,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,14 +115,14 @@ export class InvoicesService {
|
||||
private readonly where = () => ({})
|
||||
|
||||
private readonly invoiceMapper = (invoice: any) => {
|
||||
const { tsp_attempts, type, ...rest } = invoice || {}
|
||||
const { last_tsp_status, type, ...rest } = invoice || {}
|
||||
|
||||
return {
|
||||
...rest,
|
||||
type: translateEnumValue('TspProviderRequestType', type),
|
||||
status: translateEnumValue(
|
||||
'TspProviderResponseStatus',
|
||||
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
last_tsp_status || TspProviderResponseStatus.NOT_SEND,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ export class SalesInvoicesService {
|
||||
])
|
||||
|
||||
const summaryItems = items.map(invoice => {
|
||||
const { tsp_attempts, type, ...rest } = invoice
|
||||
const { last_tsp_status, type, ...rest } = invoice
|
||||
return {
|
||||
...rest,
|
||||
type: translateEnumValue('TspProviderRequestType', type),
|
||||
status: translateEnumValue(
|
||||
'TspProviderResponseStatus',
|
||||
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
last_tsp_status || TspProviderResponseStatus.NOT_SEND,
|
||||
),
|
||||
}
|
||||
})
|
||||
@@ -78,13 +78,13 @@ export class SalesInvoicesService {
|
||||
})
|
||||
|
||||
if (invoice) {
|
||||
const { tsp_attempts, type, ...rest } = invoice
|
||||
const { last_tsp_status, type, ...rest } = invoice
|
||||
const mappedInvoice = {
|
||||
...rest,
|
||||
type: translateEnumValue('TspProviderRequestType', type),
|
||||
status: translateEnumValue(
|
||||
'TspProviderResponseStatus',
|
||||
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND,
|
||||
last_tsp_status || TspProviderResponseStatus.NOT_SEND,
|
||||
),
|
||||
settlement_type: translateEnumValue(
|
||||
'InvoiceSettlementType',
|
||||
|
||||
Reference in New Issue
Block a user