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:
2026-05-24 19:40:04 +03:30
parent b53b7d3ed3
commit ea6f1bfdd0
17 changed files with 340 additions and 268 deletions
@@ -0,0 +1,10 @@
-- Add as nullable first to support existing rows, backfill, then enforce NOT NULL
ALTER TABLE `sales_invoices`
ADD COLUMN `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NULL;
UPDATE `sales_invoices`
SET `settlement_type` = 'CASH'
WHERE `settlement_type` IS NULL;
ALTER TABLE `sales_invoices`
MODIFY `settlement_type` ENUM('CASH', 'CREDIT', 'MIXED') NOT NULL;
+6
View File
@@ -157,6 +157,12 @@ enum ConsumerType {
LEGAL
}
enum InvoiceSettlementType {
CASH
CREDIT
MIXED
}
enum TspProviderType {
NAMA
SUN
+8 -7
View File
@@ -1,11 +1,12 @@
model SalesInvoice {
id String @id @default(uuid())
code String @unique @db.VarChar(100)
total_amount Decimal @db.Decimal(15, 2)
invoice_number Int @db.Int()
invoice_date DateTime @default(now()) @db.Timestamp(0)
type TspProviderRequestType
tax_id String? @unique @db.VarChar(32)
id String @id @default(uuid())
code String @unique @db.VarChar(100)
total_amount Decimal @db.Decimal(15, 2)
invoice_number Int @db.Int()
invoice_date DateTime @default(now()) @db.Timestamp(0)
type TspProviderRequestType
settlement_type InvoiceSettlementType
tax_id String? @unique @db.VarChar(32)
notes String? @db.Text
unknown_customer Json? @db.Json