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:
2026-05-03 16:23:17 +03:30
parent ad470d2166
commit a486127ade
62 changed files with 4136 additions and 5015 deletions
+69 -141
View File
@@ -425,8 +425,7 @@ export const ModelName = {
Guild: 'Guild',
SalesInvoice: 'SalesInvoice',
SalesInvoiceItem: 'SalesInvoiceItem',
SaleInvoiceFiscals: 'SaleInvoiceFiscals',
SaleInvoiceFiscalAttempts: 'SaleInvoiceFiscalAttempts',
SaleInvoiceTspAttempts: 'SaleInvoiceTspAttempts',
SalesInvoicePayment: 'SalesInvoicePayment',
SalesInvoicePaymentTerminalInfo: 'SalesInvoicePaymentTerminalInfo',
Service: 'Service',
@@ -446,7 +445,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "adminAccount" | "admin" | "account" | "deviceBrand" | "device" | "licenseChargeTransaction" | "license" | "licenseActivation" | "licenseRenewChargeTransaction" | "licenseRenew" | "partnerAccountQuotaChargeTransaction" | "partnerAccountQuotaCredit" | "licenseAccountAllocation" | "partnerAccount" | "partner" | "permissionConsumer" | "permissionPos" | "permissionComplex" | "permissionBusiness" | "providerAccount" | "provider" | "consumerDevices" | "applicationReleasedInfo" | "consumerAccount" | "consumer" | "consumerIndividual" | "consumerLegal" | "businessActivity" | "complex" | "pos" | "good" | "goodCategory" | "measureUnits" | "stockKeepingUnits" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "guild" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceFiscals" | "saleInvoiceFiscalAttempts" | "salesInvoicePayment" | "salesInvoicePaymentTerminalInfo" | "service" | "serviceCategory"
modelProps: "adminAccount" | "admin" | "account" | "deviceBrand" | "device" | "licenseChargeTransaction" | "license" | "licenseActivation" | "licenseRenewChargeTransaction" | "licenseRenew" | "partnerAccountQuotaChargeTransaction" | "partnerAccountQuotaCredit" | "licenseAccountAllocation" | "partnerAccount" | "partner" | "permissionConsumer" | "permissionPos" | "permissionComplex" | "permissionBusiness" | "providerAccount" | "provider" | "consumerDevices" | "applicationReleasedInfo" | "consumerAccount" | "consumer" | "consumerIndividual" | "consumerLegal" | "businessActivity" | "complex" | "pos" | "good" | "goodCategory" | "measureUnits" | "stockKeepingUnits" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "guild" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceTspAttempts" | "salesInvoicePayment" | "salesInvoicePaymentTerminalInfo" | "service" | "serviceCategory"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -3156,135 +3155,69 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
SaleInvoiceFiscals: {
payload: Prisma.$SaleInvoiceFiscalsPayload<ExtArgs>
fields: Prisma.SaleInvoiceFiscalsFieldRefs
SaleInvoiceTspAttempts: {
payload: Prisma.$SaleInvoiceTspAttemptsPayload<ExtArgs>
fields: Prisma.SaleInvoiceTspAttemptsFieldRefs
operations: {
findUnique: {
args: Prisma.SaleInvoiceFiscalsFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload> | null
args: Prisma.SaleInvoiceTspAttemptsFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload> | null
}
findUniqueOrThrow: {
args: Prisma.SaleInvoiceFiscalsFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
findFirst: {
args: Prisma.SaleInvoiceFiscalsFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload> | null
args: Prisma.SaleInvoiceTspAttemptsFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload> | null
}
findFirstOrThrow: {
args: Prisma.SaleInvoiceFiscalsFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
findMany: {
args: Prisma.SaleInvoiceFiscalsFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>[]
args: Prisma.SaleInvoiceTspAttemptsFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>[]
}
create: {
args: Prisma.SaleInvoiceFiscalsCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
createMany: {
args: Prisma.SaleInvoiceFiscalsCreateManyArgs<ExtArgs>
args: Prisma.SaleInvoiceTspAttemptsCreateManyArgs<ExtArgs>
result: BatchPayload
}
delete: {
args: Prisma.SaleInvoiceFiscalsDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
update: {
args: Prisma.SaleInvoiceFiscalsUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
deleteMany: {
args: Prisma.SaleInvoiceFiscalsDeleteManyArgs<ExtArgs>
args: Prisma.SaleInvoiceTspAttemptsDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.SaleInvoiceFiscalsUpdateManyArgs<ExtArgs>
args: Prisma.SaleInvoiceTspAttemptsUpdateManyArgs<ExtArgs>
result: BatchPayload
}
upsert: {
args: Prisma.SaleInvoiceFiscalsUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalsPayload>
args: Prisma.SaleInvoiceTspAttemptsUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceTspAttemptsPayload>
}
aggregate: {
args: Prisma.SaleInvoiceFiscalsAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateSaleInvoiceFiscals>
args: Prisma.SaleInvoiceTspAttemptsAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateSaleInvoiceTspAttempts>
}
groupBy: {
args: Prisma.SaleInvoiceFiscalsGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceFiscalsGroupByOutputType>[]
args: Prisma.SaleInvoiceTspAttemptsGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceTspAttemptsGroupByOutputType>[]
}
count: {
args: Prisma.SaleInvoiceFiscalsCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceFiscalsCountAggregateOutputType> | number
}
}
}
SaleInvoiceFiscalAttempts: {
payload: Prisma.$SaleInvoiceFiscalAttemptsPayload<ExtArgs>
fields: Prisma.SaleInvoiceFiscalAttemptsFieldRefs
operations: {
findUnique: {
args: Prisma.SaleInvoiceFiscalAttemptsFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload> | null
}
findUniqueOrThrow: {
args: Prisma.SaleInvoiceFiscalAttemptsFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
findFirst: {
args: Prisma.SaleInvoiceFiscalAttemptsFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload> | null
}
findFirstOrThrow: {
args: Prisma.SaleInvoiceFiscalAttemptsFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
findMany: {
args: Prisma.SaleInvoiceFiscalAttemptsFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>[]
}
create: {
args: Prisma.SaleInvoiceFiscalAttemptsCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
createMany: {
args: Prisma.SaleInvoiceFiscalAttemptsCreateManyArgs<ExtArgs>
result: BatchPayload
}
delete: {
args: Prisma.SaleInvoiceFiscalAttemptsDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
update: {
args: Prisma.SaleInvoiceFiscalAttemptsUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
deleteMany: {
args: Prisma.SaleInvoiceFiscalAttemptsDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.SaleInvoiceFiscalAttemptsUpdateManyArgs<ExtArgs>
result: BatchPayload
}
upsert: {
args: Prisma.SaleInvoiceFiscalAttemptsUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$SaleInvoiceFiscalAttemptsPayload>
}
aggregate: {
args: Prisma.SaleInvoiceFiscalAttemptsAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateSaleInvoiceFiscalAttempts>
}
groupBy: {
args: Prisma.SaleInvoiceFiscalAttemptsGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceFiscalAttemptsGroupByOutputType>[]
}
count: {
args: Prisma.SaleInvoiceFiscalAttemptsCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceFiscalAttemptsCountAggregateOutputType> | number
args: Prisma.SaleInvoiceTspAttemptsCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.SaleInvoiceTspAttemptsCountAggregateOutputType> | number
}
}
}
@@ -3762,7 +3695,7 @@ export const PartnerScalarFieldEnum = {
name: 'name',
code: 'code',
status: 'status',
fiscal_switch_type: 'fiscal_switch_type',
tsp_provider: 'tsp_provider',
logo_url: 'logo_url',
created_at: 'created_at',
updated_at: 'updated_at'
@@ -3927,6 +3860,7 @@ export const BusinessActivityScalarFieldEnum = {
name: 'name',
fiscal_id: 'fiscal_id',
partner_token: 'partner_token',
invoice_number_sequence: 'invoice_number_sequence',
created_at: 'created_at',
updated_at: 'updated_at',
guild_id: 'guild_id',
@@ -4082,6 +4016,7 @@ export type CustomerLegalScalarFieldEnum = (typeof CustomerLegalScalarFieldEnum)
export const GuildScalarFieldEnum = {
id: 'id',
name: 'name',
invoice_template: 'invoice_template',
code: 'code',
created_at: 'created_at',
updated_at: 'updated_at'
@@ -4130,19 +4065,7 @@ export const SalesInvoiceItemScalarFieldEnum = {
export type SalesInvoiceItemScalarFieldEnum = (typeof SalesInvoiceItemScalarFieldEnum)[keyof typeof SalesInvoiceItemScalarFieldEnum]
export const SaleInvoiceFiscalsScalarFieldEnum = {
id: 'id',
retry_count: 'retry_count',
last_attempt_at: 'last_attempt_at',
created_at: 'created_at',
updated_at: 'updated_at',
invoice_id: 'invoice_id'
} as const
export type SaleInvoiceFiscalsScalarFieldEnum = (typeof SaleInvoiceFiscalsScalarFieldEnum)[keyof typeof SaleInvoiceFiscalsScalarFieldEnum]
export const SaleInvoiceFiscalAttemptsScalarFieldEnum = {
export const SaleInvoiceTspAttemptsScalarFieldEnum = {
id: 'id',
attempt_no: 'attempt_no',
status: 'status',
@@ -4154,10 +4077,10 @@ export const SaleInvoiceFiscalAttemptsScalarFieldEnum = {
sent_at: 'sent_at',
received_at: 'received_at',
created_at: 'created_at',
fiscal_id: 'fiscal_id'
invoice_id: 'invoice_id'
} as const
export type SaleInvoiceFiscalAttemptsScalarFieldEnum = (typeof SaleInvoiceFiscalAttemptsScalarFieldEnum)[keyof typeof SaleInvoiceFiscalAttemptsScalarFieldEnum]
export type SaleInvoiceTspAttemptsScalarFieldEnum = (typeof SaleInvoiceTspAttemptsScalarFieldEnum)[keyof typeof SaleInvoiceTspAttemptsScalarFieldEnum]
export const SalesInvoicePaymentScalarFieldEnum = {
@@ -4237,6 +4160,13 @@ export const NullableJsonNullValueInput = {
export type NullableJsonNullValueInput = (typeof NullableJsonNullValueInput)[keyof typeof NullableJsonNullValueInput]
export const JsonNullValueInput = {
JsonNull: JsonNull
} as const
export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput]
export const AdminAccountOrderByRelevanceFieldEnum = {
id: 'id',
admin_id: 'admin_id',
@@ -4679,22 +4609,14 @@ export const SalesInvoiceItemOrderByRelevanceFieldEnum = {
export type SalesInvoiceItemOrderByRelevanceFieldEnum = (typeof SalesInvoiceItemOrderByRelevanceFieldEnum)[keyof typeof SalesInvoiceItemOrderByRelevanceFieldEnum]
export const SaleInvoiceFiscalsOrderByRelevanceFieldEnum = {
id: 'id',
invoice_id: 'invoice_id'
} as const
export type SaleInvoiceFiscalsOrderByRelevanceFieldEnum = (typeof SaleInvoiceFiscalsOrderByRelevanceFieldEnum)[keyof typeof SaleInvoiceFiscalsOrderByRelevanceFieldEnum]
export const SaleInvoiceFiscalAttemptsOrderByRelevanceFieldEnum = {
export const SaleInvoiceTspAttemptsOrderByRelevanceFieldEnum = {
id: 'id',
tax_id: 'tax_id',
error_message: 'error_message',
fiscal_id: 'fiscal_id'
invoice_id: 'invoice_id'
} as const
export type SaleInvoiceFiscalAttemptsOrderByRelevanceFieldEnum = (typeof SaleInvoiceFiscalAttemptsOrderByRelevanceFieldEnum)[keyof typeof SaleInvoiceFiscalAttemptsOrderByRelevanceFieldEnum]
export type SaleInvoiceTspAttemptsOrderByRelevanceFieldEnum = (typeof SaleInvoiceTspAttemptsOrderByRelevanceFieldEnum)[keyof typeof SaleInvoiceTspAttemptsOrderByRelevanceFieldEnum]
export const SalesInvoicePaymentOrderByRelevanceFieldEnum = {
@@ -4801,9 +4723,9 @@ export type EnumPartnerStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$Pr
/**
* Reference to a field of type 'PartnerFiscalSwitchType'
* Reference to a field of type 'TspProviderType'
*/
export type EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'PartnerFiscalSwitchType'>
export type EnumTspProviderTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'TspProviderType'>
@@ -4898,6 +4820,13 @@ export type EnumConsumerStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$P
/**
* Reference to a field of type 'Decimal'
*/
export type DecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal'>
/**
* Reference to a field of type 'POSStatus'
*/
@@ -4919,13 +4848,6 @@ export type EnumGoodPricingModelFieldRefInput<$PrismaModel> = FieldRefInputType<
/**
* Reference to a field of type 'Decimal'
*/
export type DecimalFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Decimal'>
/**
* Reference to a field of type 'SKUGuildType'
*/
@@ -4941,16 +4863,23 @@ export type EnumCustomerTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$Pri
/**
* Reference to a field of type 'FiscalResponseStatus'
* Reference to a field of type 'InvoiceTemplateType'
*/
export type EnumFiscalResponseStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'FiscalResponseStatus'>
export type EnumInvoiceTemplateTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'InvoiceTemplateType'>
/**
* Reference to a field of type 'FiscalRequestType'
* Reference to a field of type 'TspProviderResponseStatus'
*/
export type EnumFiscalRequestTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'FiscalRequestType'>
export type EnumTspProviderResponseStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'TspProviderResponseStatus'>
/**
* Reference to a field of type 'TspProviderRequestType'
*/
export type EnumTspProviderRequestTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'TspProviderRequestType'>
@@ -5103,8 +5032,7 @@ export type GlobalOmitConfig = {
guild?: Prisma.GuildOmit
salesInvoice?: Prisma.SalesInvoiceOmit
salesInvoiceItem?: Prisma.SalesInvoiceItemOmit
saleInvoiceFiscals?: Prisma.SaleInvoiceFiscalsOmit
saleInvoiceFiscalAttempts?: Prisma.SaleInvoiceFiscalAttemptsOmit
saleInvoiceTspAttempts?: Prisma.SaleInvoiceTspAttemptsOmit
salesInvoicePayment?: Prisma.SalesInvoicePaymentOmit
salesInvoicePaymentTerminalInfo?: Prisma.SalesInvoicePaymentTerminalInfoOmit
service?: Prisma.ServiceOmit