refactor: remove SalesInvoiceItemsService and update sales invoice handling

- Deleted SalesInvoiceItemsService as it was not implemented.
- Changed variable declaration from `const` to `let` in SalesInvoicesService for sales invoice creation.
- Updated response handling after sending to TSP provider in SalesInvoicesService.
- Renamed payload properties in TspProvider DTOs for clarity.
- Enhanced error handling in SalesInvoiceTspSwitchService for unsupported providers.
- Refactored SalesInvoiceTspService to utilize utility functions for payload building and sending.
- Updated PrismaService to increase connection limit and utilize dynamic options.
- Added new migration scripts to update database schema for sale_invoice_tsp_attempts.
- Introduced utility functions for building payloads and handling responses in sales invoice processing.
This commit is contained in:
2026-05-08 18:09:13 +03:30
parent fbe7230865
commit 4e61ff618e
28 changed files with 944 additions and 713 deletions
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common'
import { BadRequestException, Injectable } from '@nestjs/common'
import {
TspProviderBulkSendResultDto,
TspProviderCorrectionSendPayloadDto,
@@ -18,17 +18,25 @@ export class SalesInvoiceTspSwitchService {
private resolveSwitch(providerCode: string) {
const normalizedCode = providerCode.trim().toUpperCase() || ''
let adapter: NamaProviderSwitchAdapter | null = null
switch (normalizedCode) {
case 'NAMA':
default:
return this.namaAdapter
adapter = this.namaAdapter
}
if (!adapter) {
throw new BadRequestException(
`${providerCode} برای ارسال انتخاب شده است که در حال حاضر پشتیبانی نمی شود.`,
)
}
return adapter
}
async send(
payload: TspProviderOriginalSendPayloadDto,
): Promise<TspProviderSendItemResultDto> {
const adapter = this.resolveSwitch(payload.tsp_provider)
return adapter.originalSend(payload)
}
@@ -36,6 +44,7 @@ export class SalesInvoiceTspSwitchService {
payload: TspProviderCorrectionSendPayloadDto,
): Promise<TspProviderCorrectionSendResponseDto> {
const adapter = this.resolveSwitch(payload.tsp_provider)
return adapter.correctionSend(payload)
}