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:
@@ -15,12 +15,12 @@ model PartnerAccount {
|
||||
}
|
||||
|
||||
model Partner {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
code String @unique()
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
fiscal_switch_type PartnerFiscalSwitchType
|
||||
logo_url String?
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
code String @unique()
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
tsp_provider TspProviderType @default(NAMA)
|
||||
logo_url String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @default(now()) @updatedAt @db.Timestamp(0)
|
||||
|
||||
@@ -74,11 +74,12 @@ model ConsumerLegal {
|
||||
}
|
||||
|
||||
model BusinessActivity {
|
||||
id String @id @default(ulid())
|
||||
economic_code String
|
||||
name String
|
||||
fiscal_id String
|
||||
partner_token String
|
||||
id String @id @default(ulid())
|
||||
economic_code String
|
||||
name String
|
||||
fiscal_id String
|
||||
partner_token String
|
||||
invoice_number_sequence Decimal @default(1) @db.Decimal(20, 0)
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
@@ -3,7 +3,7 @@ model StockKeepingUnits {
|
||||
code String @unique
|
||||
name String
|
||||
VAT Decimal @db.Decimal(5, 2)
|
||||
type SKUGuildType @default(GOLD)
|
||||
type SKUGuildType
|
||||
is_public Boolean @default(true)
|
||||
is_domestic Boolean @default(false)
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
enum PaymentMethodType {
|
||||
TERMINAL
|
||||
CASH
|
||||
CHEQUE
|
||||
SET_OFF
|
||||
CASH
|
||||
TERMINAL
|
||||
PAYMENT_GATEWAY
|
||||
CARD
|
||||
BANK
|
||||
CHECK
|
||||
OTHER
|
||||
}
|
||||
|
||||
@@ -156,26 +157,26 @@ enum ConsumerType {
|
||||
LEGAL
|
||||
}
|
||||
|
||||
enum PartnerFiscalSwitchType {
|
||||
enum TspProviderType {
|
||||
NAMA
|
||||
SUN
|
||||
}
|
||||
|
||||
enum FiscalResponseStatus {
|
||||
enum TspProviderResponseStatus {
|
||||
SUCCESS
|
||||
FAILURE
|
||||
NOT_SEND
|
||||
QUEUED
|
||||
}
|
||||
|
||||
enum FiscalRequestType {
|
||||
enum TspProviderRequestType {
|
||||
MAIN
|
||||
UPDATE
|
||||
REVOKE
|
||||
REMOVE
|
||||
}
|
||||
|
||||
enum FiscalInvoiceCustomerType {
|
||||
enum TspProviderCustomerType {
|
||||
Unknown
|
||||
Known
|
||||
}
|
||||
@@ -183,3 +184,17 @@ enum FiscalInvoiceCustomerType {
|
||||
enum SKUGuildType {
|
||||
GOLD
|
||||
}
|
||||
|
||||
enum InvoiceTemplateType {
|
||||
SALE
|
||||
FX_SALE
|
||||
GOLD_JEWELRY
|
||||
CONTRACT
|
||||
UTILITY
|
||||
AIR_TICKET
|
||||
EXPORT
|
||||
BILL_OF_LADING
|
||||
PETROCHEMICAL
|
||||
COMMODITY_EXCHANGE
|
||||
INSURANCE
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
model Guild {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
code String?
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
invoice_template InvoiceTemplateType
|
||||
code String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
updated_at DateTime @updatedAt() @db.Timestamp(0)
|
||||
|
||||
@@ -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