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:
-5
@@ -1,5 +0,0 @@
|
||||
import type { SalesInvoiceItemsService } from '../sales-invoice-items.service'
|
||||
|
||||
export type SalesInvoiceItemsServiceCreateResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['create']>>
|
||||
export type SalesInvoiceItemsServiceFindAllResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['findAll']>>
|
||||
export type SalesInvoiceItemsServiceFindOneResponseDto = Awaited<ReturnType<SalesInvoiceItemsService['findOne']>>
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common'
|
||||
import { SalesInvoiceItemsService } from './sales-invoice-items.service'
|
||||
|
||||
@Controller('sales_invoice_items')
|
||||
export class SalesInvoiceItemsController {
|
||||
constructor(private readonly salesInvoiceItemsService: SalesInvoiceItemsService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.salesInvoiceItemsService.findAll()
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.salesInvoiceItemsService.findOne(+id)
|
||||
}
|
||||
|
||||
@Post()
|
||||
create(@Body() data: any) {
|
||||
return this.salesInvoiceItemsService.create(data)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { SalesInvoiceItemsController } from './sales-invoice-items.controller'
|
||||
import { SalesInvoiceItemsService } from './sales-invoice-items.service'
|
||||
|
||||
@Module({
|
||||
controllers: [SalesInvoiceItemsController],
|
||||
providers: [SalesInvoiceItemsService],
|
||||
})
|
||||
export class SalesInvoiceItemsModule {}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
|
||||
@Injectable()
|
||||
export class SalesInvoiceItemsService {
|
||||
findAll() {
|
||||
// TODO: Implement fetching all sales invoice items
|
||||
return []
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
// TODO: Implement fetching a single sales invoice item
|
||||
return {}
|
||||
}
|
||||
|
||||
create(data: any) {
|
||||
// TODO: Implement sales invoice item creation
|
||||
return data
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export class SalesInvoicesService {
|
||||
}
|
||||
|
||||
async create(data: CreateSalesInvoiceDto, posInfo: IPosPayload) {
|
||||
const salesInvoice = await this.sharedSaleInvoiceCreateService.create({
|
||||
let salesInvoice = await this.sharedSaleInvoiceCreateService.create({
|
||||
data,
|
||||
businessId: posInfo.business_id,
|
||||
complexId: posInfo.complex_id,
|
||||
@@ -240,7 +240,13 @@ export class SalesInvoicesService {
|
||||
})
|
||||
|
||||
if (data.send_to_tsp) {
|
||||
await this.salesInvoiceTaxService.originalSend(salesInvoice.id, posInfo.pos_id)
|
||||
const providerResponse = await this.salesInvoiceTaxService.originalSend(
|
||||
salesInvoice.id,
|
||||
posInfo.pos_id,
|
||||
)
|
||||
if (providerResponse?.invoice) {
|
||||
salesInvoice = providerResponse?.invoice as any
|
||||
}
|
||||
}
|
||||
|
||||
return ResponseMapper.create(salesInvoice)
|
||||
|
||||
Reference in New Issue
Block a user