feat: implement SalesInvoiceTspSwitchService and SalesInvoiceTspService for handling TSP provider interactions
- Add SalesInvoiceTspSwitchService to manage TSP provider selection and sending invoices. - Introduce SalesInvoiceTspService for creating, sending, and retrieving sales invoices. - Implement NamaProviderSwitchAdapter for communication with the NAMA TSP provider API. - Define DTOs for request and response structures specific to the NAMA provider. - Enhance error handling and logging for TSP provider interactions.
This commit is contained in:
@@ -20,10 +20,9 @@ model SalesInvoice {
|
||||
pos_id String
|
||||
pos Pos @relation(fields: [pos_id], references: [id])
|
||||
|
||||
fiscal SaleInvoiceFiscals?
|
||||
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
items SalesInvoiceItem[]
|
||||
payments SalesInvoicePayment[]
|
||||
tsp_attempts SaleInvoiceTspAttempts[]
|
||||
|
||||
@@unique([invoice_number, pos_id])
|
||||
@@map("sales_invoices")
|
||||
@@ -43,13 +42,13 @@ model SalesInvoiceItem {
|
||||
notes String? @db.Text
|
||||
|
||||
payload Json?
|
||||
good_snapshot Json?
|
||||
good_snapshot Json
|
||||
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
good_id String?
|
||||
good Good? @relation(fields: [good_id], references: [id])
|
||||
good_id String
|
||||
good Good @relation(fields: [good_id], references: [id])
|
||||
|
||||
service_id String?
|
||||
service Service? @relation(fields: [service_id], references: [id])
|
||||
@@ -58,30 +57,13 @@ model SalesInvoiceItem {
|
||||
@@map("sales_invoice_items")
|
||||
}
|
||||
|
||||
model SaleInvoiceFiscals {
|
||||
id String @id @default(ulid())
|
||||
|
||||
retry_count Int @default(0)
|
||||
last_attempt_at DateTime? @db.Timestamp(0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
invoice_id String @unique
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
|
||||
attempts SaleInvoiceFiscalAttempts[]
|
||||
|
||||
@@map("sale_invoice_fiscals")
|
||||
}
|
||||
|
||||
model SaleInvoiceFiscalAttempts {
|
||||
model SaleInvoiceTspAttempts {
|
||||
id String @id @default(ulid())
|
||||
|
||||
attempt_no Int
|
||||
status FiscalResponseStatus
|
||||
tax_id String? @unique @db.VarChar(191)
|
||||
type FiscalRequestType
|
||||
status TspProviderResponseStatus
|
||||
tax_id String? @unique @db.VarChar(191)
|
||||
type TspProviderRequestType
|
||||
|
||||
request_payload Json?
|
||||
response_payload Json?
|
||||
@@ -91,13 +73,14 @@ model SaleInvoiceFiscalAttempts {
|
||||
received_at DateTime? @db.Timestamp(0)
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
fiscal_id String
|
||||
fiscal SaleInvoiceFiscals @relation(fields: [fiscal_id], references: [id], onDelete: Cascade)
|
||||
invoice_id String @unique
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([fiscal_id, attempt_no])
|
||||
@@unique([invoice_id, attempt_no])
|
||||
@@index([status])
|
||||
@@index([tax_id])
|
||||
@@map("sale_invoice_fiscal_attempts")
|
||||
@@index([invoice_id])
|
||||
@@map("sale_invoice_tsp_attempts")
|
||||
}
|
||||
|
||||
model SalesInvoicePayment {
|
||||
|
||||
Reference in New Issue
Block a user