feat: implement correction and original send functionality for Nama provider
- Added new DTOs for correction requests and responses in `nama-provider.dto.ts`. - Updated `nama-provider.adapter.ts` to include `originalSend` and `correctionSend` methods. - Enhanced `nama-provider.util.ts` with mapping functions for correction requests. - Created operational guidelines for agents in `AGENT.md`. - Updated Prisma migrations to support new invoice types and relationships. - Introduced new service and DTO for creating sales invoices in `sale-invoice-create.service.ts` and `sale-invoice-create.dto.ts`. - Added utility for handling Prisma errors in `prisma-error.util.ts`.
This commit is contained in:
@@ -9,10 +9,12 @@ import {
|
||||
import {
|
||||
CustomerInfoDto,
|
||||
PaymentInfoDto,
|
||||
TspProviderCorrectionSendPayloadDto,
|
||||
TspProviderOriginalSendPayloadDto,
|
||||
TspProviderRevokePayloadDto,
|
||||
TspProviderSendPayloadDto,
|
||||
} from '../../dto/provider-switch.dto'
|
||||
import {
|
||||
NamaProviderCorrectionRequestDto,
|
||||
NamaProviderPaymentInfoDto,
|
||||
NamaProviderRequestDto,
|
||||
NamaProviderResponseStatus,
|
||||
@@ -35,7 +37,9 @@ export class NamaProviderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
mapToNamaRequestDto(payload: TspProviderSendPayloadDto): NamaProviderRequestDto {
|
||||
mapToNamaRequestDto(
|
||||
payload: TspProviderOriginalSendPayloadDto,
|
||||
): NamaProviderRequestDto {
|
||||
return {
|
||||
uuid: payload.invoice_id,
|
||||
economic_code: payload.economic_code,
|
||||
@@ -66,6 +70,39 @@ export class NamaProviderUtils {
|
||||
}
|
||||
}
|
||||
|
||||
mapToNamaCorrectionDto(
|
||||
payload: TspProviderCorrectionSendPayloadDto,
|
||||
): NamaProviderCorrectionRequestDto {
|
||||
return {
|
||||
uuid: payload.invoice_id,
|
||||
economic_code: payload.economic_code,
|
||||
fiscal_id: payload.fiscal_id,
|
||||
payment: this.mapPayments(payload.payments),
|
||||
header: {
|
||||
ins: this.mapTspProviderRequestType(TspProviderRequestType.CORRECTION),
|
||||
inp: this.mapInvoiceTemplate(payload.invoice_template),
|
||||
inty: this.mapTspProviderCustomerType(payload.customer_type),
|
||||
inno: payload.invoice_number.toString(),
|
||||
tins: '',
|
||||
indatim: payload.invoice_date.getTime() + '',
|
||||
setm: '1',
|
||||
...this.mapCustomerInfo(payload.customer),
|
||||
},
|
||||
body: payload.items.map(item => ({
|
||||
sstid: item.sku,
|
||||
vra: item.sku_vat,
|
||||
// sstt: item.unit_type,
|
||||
fee: String(item.unit_price),
|
||||
dis: String(item.discount),
|
||||
mu: item.measure_unit,
|
||||
am: String(item.quantity),
|
||||
consfee: '0',
|
||||
bros: '0',
|
||||
spro: '0',
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
mapRevokeToNamaRequestDto(
|
||||
payload: TspProviderRevokePayloadDto,
|
||||
): NamaProviderRevokeRequestDto {
|
||||
@@ -76,7 +113,7 @@ export class NamaProviderUtils {
|
||||
header: {
|
||||
inno: payload.invoice_number.toString(),
|
||||
ins: this.mapTspProviderRequestType(TspProviderRequestType.REVOKE),
|
||||
irtaxid: payload.last_attempt_tax_id,
|
||||
irtaxid: payload.last_tax_id,
|
||||
indatim: new Date().getTime() + '',
|
||||
},
|
||||
}
|
||||
@@ -84,9 +121,9 @@ export class NamaProviderUtils {
|
||||
|
||||
private mapTspProviderRequestType(type: TspProviderRequestType) {
|
||||
switch (type) {
|
||||
case TspProviderRequestType.MAIN:
|
||||
case TspProviderRequestType.ORIGINAL:
|
||||
return '1'
|
||||
case TspProviderRequestType.UPDATE:
|
||||
case TspProviderRequestType.CORRECTION:
|
||||
return '2'
|
||||
case TspProviderRequestType.REVOKE:
|
||||
return '3'
|
||||
|
||||
Reference in New Issue
Block a user