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:
@@ -15,7 +15,11 @@ import {
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from 'class-validator'
|
||||
import type { CustomerIndividual, CustomerLegal } from 'generated/prisma/client'
|
||||
import {
|
||||
CustomerIndividual,
|
||||
CustomerLegal,
|
||||
InvoiceSettlementType,
|
||||
} from 'generated/prisma/client'
|
||||
import { CustomerType } from 'generated/prisma/enums'
|
||||
|
||||
export class SharedCreateSalesInvoiceItemDto {
|
||||
@@ -165,6 +169,10 @@ export class SharedCreateSalesInvoiceDto {
|
||||
)
|
||||
invoice_date: Date
|
||||
|
||||
@ApiProperty({ required: true, enum: InvoiceSettlementType })
|
||||
@IsEnum(InvoiceSettlementType)
|
||||
settlement_type: InvoiceSettlementType
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsObject()
|
||||
@ValidateNested({ each: true })
|
||||
|
||||
@@ -382,7 +382,14 @@ export class SharedSaleInvoiceCreateService {
|
||||
main_invoice_id,
|
||||
ref_invoice_id,
|
||||
} = params
|
||||
const { customer_id, customer_type, customer, payments, ...invoiceData } = data
|
||||
const {
|
||||
customer_id,
|
||||
customer_type,
|
||||
customer,
|
||||
payments,
|
||||
settlement_type,
|
||||
...invoiceData
|
||||
} = data
|
||||
|
||||
if (
|
||||
type !== TspProviderRequestType.ORIGINAL &&
|
||||
@@ -398,6 +405,7 @@ export class SharedSaleInvoiceCreateService {
|
||||
total_amount: data.total_amount,
|
||||
code: this.generateInvoiceCode(businessId, complexId, posId, invoiceNumber),
|
||||
type,
|
||||
settlement_type,
|
||||
items: {
|
||||
createMany: {
|
||||
data: data.items.map(item => ({
|
||||
|
||||
Reference in New Issue
Block a user