feat: update invoice processing to use last_tsp_status for status mapping

This commit is contained in:
2026-06-15 19:34:21 +03:30
parent 9170d8cd5a
commit d51b677f26
4 changed files with 11 additions and 11 deletions
@@ -245,9 +245,7 @@ export class SharedSaleInvoiceCreateService {
} }
return customerIndividualId return customerIndividualId
} } else if (customer_type === CustomerType.LEGAL && customer?.customer_legal) {
if (customer_type === CustomerType.LEGAL && customer?.customer_legal) {
const { registration_number, economic_code, postal_code } = customer.customer_legal const { registration_number, economic_code, postal_code } = customer.customer_legal
const foundedCustomer = await tx.customerLegal.findFirst({ const foundedCustomer = await tx.customerLegal.findFirst({
where: { where: {
@@ -454,6 +452,8 @@ export class SharedSaleInvoiceCreateService {
id: customerId, id: customerId,
}, },
} }
} else if (data.customer?.customer_unknown) {
salesInvoiceData.unknown_customer = data.customer.customer_unknown
} }
if (type !== TspProviderRequestType.ORIGINAL) { if (type !== TspProviderRequestType.ORIGINAL) {
@@ -10,13 +10,13 @@ export class StatisticsService {
constructor(private readonly prisma: PrismaService) {} constructor(private readonly prisma: PrismaService) {}
private readonly invoiceMapper = (invoice: any) => { private readonly invoiceMapper = (invoice: any) => {
const { tsp_attempts, ...rest } = invoice || {} const { last_tsp_status, ...rest } = invoice || {}
return { return {
...rest, ...rest,
status: translateEnumValue( status: translateEnumValue(
'TspProviderResponseStatus', 'TspProviderResponseStatus',
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND, last_tsp_status || TspProviderResponseStatus.NOT_SEND,
), ),
} }
} }
+2 -2
View File
@@ -115,14 +115,14 @@ export class InvoicesService {
private readonly where = () => ({}) private readonly where = () => ({})
private readonly invoiceMapper = (invoice: any) => { private readonly invoiceMapper = (invoice: any) => {
const { tsp_attempts, type, ...rest } = invoice || {} const { last_tsp_status, type, ...rest } = invoice || {}
return { return {
...rest, ...rest,
type: translateEnumValue('TspProviderRequestType', type), type: translateEnumValue('TspProviderRequestType', type),
status: translateEnumValue( status: translateEnumValue(
'TspProviderResponseStatus', '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 summaryItems = items.map(invoice => {
const { tsp_attempts, type, ...rest } = invoice const { last_tsp_status, type, ...rest } = invoice
return { return {
...rest, ...rest,
type: translateEnumValue('TspProviderRequestType', type), type: translateEnumValue('TspProviderRequestType', type),
status: translateEnumValue( status: translateEnumValue(
'TspProviderResponseStatus', 'TspProviderResponseStatus',
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND, last_tsp_status || TspProviderResponseStatus.NOT_SEND,
), ),
} }
}) })
@@ -78,13 +78,13 @@ export class SalesInvoicesService {
}) })
if (invoice) { if (invoice) {
const { tsp_attempts, type, ...rest } = invoice const { last_tsp_status, type, ...rest } = invoice
const mappedInvoice = { const mappedInvoice = {
...rest, ...rest,
type: translateEnumValue('TspProviderRequestType', type), type: translateEnumValue('TspProviderRequestType', type),
status: translateEnumValue( status: translateEnumValue(
'TspProviderResponseStatus', 'TspProviderResponseStatus',
invoice.tsp_attempts?.[0]?.status || TspProviderResponseStatus.NOT_SEND, last_tsp_status || TspProviderResponseStatus.NOT_SEND,
), ),
settlement_type: translateEnumValue( settlement_type: translateEnumValue(
'InvoiceSettlementType', 'InvoiceSettlementType',