feat: add settlement_type to SalesInvoice model and related DTOs
- Added settlement_type field to SalesInvoice model with ENUM values (CASH, CREDIT, MIXED). - Updated SalesInvoice aggregate types, input types, and where filters to include settlement_type. - Modified StatisticsService to calculate credit amounts based on settlement_type. - Enhanced TspProviderOriginalSendPayloadDto to include settlement_type. - Updated NamaProvider DTOs and utility functions to handle new settlement_type logic. - Created migration to add settlement_type column to sales_invoices table and backfill existing records.
This commit is contained in:
@@ -288,6 +288,7 @@ export class SalesInvoiceTspService {
|
||||
items: dataToUpdate.items,
|
||||
total_amount: dataToUpdate.total_amount,
|
||||
customer_id: relatedInvoice.customer_id || undefined,
|
||||
settlement_type: relatedInvoice.settlement_type,
|
||||
},
|
||||
businessId,
|
||||
complexId,
|
||||
@@ -320,8 +321,7 @@ export class SalesInvoiceTspService {
|
||||
)
|
||||
if (result?.hasError) {
|
||||
result.provider_request_payload =
|
||||
result.provider_request_payload ||
|
||||
JSON.parse(JSON.stringify(correctionPayload))
|
||||
result.provider_request_payload || JSON.parse(JSON.stringify(correctionPayload))
|
||||
result.sent_at = result.sent_at || new Date().toISOString()
|
||||
result.received_at = result.received_at || new Date().toISOString()
|
||||
}
|
||||
@@ -472,6 +472,7 @@ export class SalesInvoiceTspService {
|
||||
customer_type: relatedInvoice.customer?.type || CustomerType.UNKNOWN,
|
||||
invoice_date: new Date(),
|
||||
payments,
|
||||
settlement_type: relatedInvoice.settlement_type,
|
||||
items: relatedInvoice.items.map(item => ({
|
||||
unit_price: Number(item.unit_price),
|
||||
quantity: Number(item.quantity),
|
||||
|
||||
Reference in New Issue
Block a user