feat: implement tax switch functionality with Nama adapter
- Add DTOs for tax switch operations including payloads and results. - Create SalesInvoiceFiscalSwitchService to handle sending and retrieving tax data. - Implement SalesInvoiceFiscalService for managing invoice tax submissions and results persistence. - Develop NamaTaxSwitchAdapter for interfacing with the external tax service. - Introduce NamaTaxRequestDto and related classes for structured tax requests.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE `partners` ADD COLUMN `fiscal_switch_type` ENUM('NAMA', 'SUN') NOT NULL DEFAULT 'NAMA';
|
||||
@@ -19,6 +19,7 @@ model Partner {
|
||||
name String
|
||||
code String @unique()
|
||||
status PartnerStatus @default(ACTIVE)
|
||||
fiscal_switch_type PartnerFiscalSwitchType
|
||||
logo_url String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
@@ -155,3 +155,14 @@ enum ConsumerType {
|
||||
INDIVIDUAL
|
||||
LEGAL
|
||||
}
|
||||
|
||||
enum PartnerFiscalSwitchType {
|
||||
NAMA
|
||||
SUN
|
||||
}
|
||||
|
||||
enum FiscalResponseStatus {
|
||||
SUCCESS
|
||||
FAILURE
|
||||
NOT_SEND
|
||||
}
|
||||
|
||||
@@ -107,6 +107,26 @@ model SalesInvoicePayment {
|
||||
invoice_id String
|
||||
invoice SalesInvoice @relation(fields: [invoice_id], references: [id])
|
||||
|
||||
terminal_info SalesInvoicePaymentTerminalInfo?
|
||||
|
||||
@@index([invoice_id])
|
||||
@@map("sales_invoice_payments")
|
||||
}
|
||||
|
||||
model SalesInvoicePaymentTerminalInfo {
|
||||
id String @id @default(ulid())
|
||||
terminal_id String
|
||||
stan String
|
||||
rrn String
|
||||
transaction_date_time DateTime
|
||||
customer_card_no String?
|
||||
description String?
|
||||
|
||||
created_at DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
payment_id String @unique
|
||||
payment SalesInvoicePayment @relation(fields: [payment_id], references: [id])
|
||||
|
||||
@@unique([terminal_id, stan, rrn, payment_id])
|
||||
@@map("sales_invoice_payment_terminal_info")
|
||||
}
|
||||
|
||||
+7
-1
@@ -1,6 +1,11 @@
|
||||
import { PasswordUtil } from '@/common/utils/password.util'
|
||||
import { generateTrackingCode } from '@/common/utils/tracking-code-generator.util'
|
||||
import { ConsumerType, GoodPricingModel, UnitType } from '@/generated/prisma/enums'
|
||||
import {
|
||||
ConsumerType,
|
||||
GoodPricingModel,
|
||||
PartnerFiscalSwitchType,
|
||||
UnitType,
|
||||
} from '@/generated/prisma/enums'
|
||||
import { GoodCreateInput, GoodCreateManyInput } from '@/generated/prisma/models'
|
||||
import { prisma } from '../src/lib/prisma'
|
||||
|
||||
@@ -250,6 +255,7 @@ async function main() {
|
||||
name: 'تیس',
|
||||
code: 'TIS',
|
||||
status: 'ACTIVE',
|
||||
fiscal_switch_type: PartnerFiscalSwitchType.NAMA,
|
||||
accounts: {
|
||||
create: {
|
||||
role: 'OWNER',
|
||||
|
||||
@@ -1,14 +1,144 @@
|
||||
export default {
|
||||
PaymentMethodType: {
|
||||
TERMINAL: 'ترمینال',
|
||||
CASH: 'نقدی',
|
||||
SET_OFF: 'تهاتر',
|
||||
CARD: 'کارت',
|
||||
BANK: 'بانکی',
|
||||
CHECK: 'چک',
|
||||
OTHER: 'سایر',
|
||||
},
|
||||
UnitType: {
|
||||
COUNT: 'تعداد',
|
||||
GRAM: 'گرم',
|
||||
KILOGRAM: 'کیلوگرم',
|
||||
KILO_GRAM: 'کیلوگرم',
|
||||
LITER: 'لیتر',
|
||||
MILLILITER: 'میلیلیتر',
|
||||
METER: 'متر',
|
||||
HOUR: 'ساعت',
|
||||
},
|
||||
GoodPricingModel: {
|
||||
STANDARD: 'استاندارد',
|
||||
GOLD: 'طلا',
|
||||
},
|
||||
CustomerType: {
|
||||
INDIVIDUAL: 'حقیقی',
|
||||
LEGAL: 'حقوقی',
|
||||
UNKNOWN: 'نامشخص',
|
||||
},
|
||||
POSStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
DISABLED: 'غیرفعال',
|
||||
},
|
||||
POSRole: {
|
||||
MANAGER: 'مدیریت',
|
||||
OPERATOR: 'اپراتور',
|
||||
},
|
||||
LicenseType: {
|
||||
BASIC: 'پایه',
|
||||
PRO: 'حرفهای',
|
||||
ENTERPRISE: 'سازمانی',
|
||||
},
|
||||
LicenseStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
EXPIRED: 'منقضی',
|
||||
SUSPENDED: 'غیرفعال',
|
||||
},
|
||||
POSType: {
|
||||
PSP: 'PSP',
|
||||
MOBILE: 'موبایل',
|
||||
WEB: 'وب',
|
||||
API: 'API',
|
||||
},
|
||||
UserType: {
|
||||
LEGAL: 'حقوقی',
|
||||
INDIVIDUAL: 'حقیقی',
|
||||
},
|
||||
AccountType: {
|
||||
ADMIN: 'مدیر سیستم',
|
||||
PROVIDER: 'ارائهدهنده خدمات',
|
||||
PARTNER: 'شریک تجاری',
|
||||
CONSUMER: 'مصرفکننده',
|
||||
},
|
||||
UserStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
INACTIVE: 'غیرفعال',
|
||||
},
|
||||
AccountRole: {
|
||||
OWNER: 'مدیر اصلی',
|
||||
OPERATOR: 'اپراتور',
|
||||
ACCOUNTANT: 'حسابدار',
|
||||
},
|
||||
AccountStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
SUSPENDED: 'غیرفعال',
|
||||
},
|
||||
PartnerRole: {
|
||||
OWNER: 'مدیر اصلی',
|
||||
MANAGER: 'مدیریت',
|
||||
OPERATOR: 'اپراتور',
|
||||
},
|
||||
PartnerStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
SUSPENDED: 'غیرفعال',
|
||||
},
|
||||
ProviderRole: {
|
||||
OWNER: 'مدیر اصلی',
|
||||
MANAGER: 'مدیریت',
|
||||
OPERATOR: 'اپراتور',
|
||||
},
|
||||
ProviderStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
SUSPENDED: 'غیرفعال',
|
||||
},
|
||||
BusinessRole: {
|
||||
MANAGER: 'مدیریت',
|
||||
OPERATOR: 'اپراتور',
|
||||
},
|
||||
ConsumerRole: {
|
||||
OWNER: 'مدیر اصلی',
|
||||
MANAGER: 'مدیریت',
|
||||
OPERATOR: 'اپراتور',
|
||||
},
|
||||
ConsumerStatus: {
|
||||
ACTIVE: 'فعال',
|
||||
SUSPENDED: 'غیرفعال',
|
||||
},
|
||||
ConsumerType: {
|
||||
INDIVIDUAL: 'حقیقی',
|
||||
LEGAL: 'حقوقی',
|
||||
},
|
||||
TokenType: {
|
||||
ACCESS: 'دسترسی',
|
||||
REFRESH: 'نوسازی',
|
||||
},
|
||||
ApplicationPlatform: {
|
||||
ANDROID: 'اندروید',
|
||||
IOS: 'iOS',
|
||||
},
|
||||
ApplicationReleaseType: {
|
||||
STABLE: 'پایدار',
|
||||
BETA: 'بتا',
|
||||
ALPHA: 'آلفا',
|
||||
},
|
||||
ApplicationPublisher: {
|
||||
DIRECT: 'مستقیم',
|
||||
CAFE_BAZAR: 'کافه بازار',
|
||||
MAYKET: 'مایکت',
|
||||
},
|
||||
PartnerFiscalSwitchType: {
|
||||
NAMA: 'نما',
|
||||
SUN: 'سان',
|
||||
},
|
||||
FiscalResponseStatus: {
|
||||
SUCCESS: 'موفق',
|
||||
FAILURE: 'ناموفق',
|
||||
NOT_SEND: 'ارسال نشده',
|
||||
},
|
||||
GoldKarat: {
|
||||
KARAT_18: '۱۸ عیار',
|
||||
KARAT_21: '۲۱ عیار',
|
||||
KARAT_24: '۲۴ عیار',
|
||||
},
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import translates from '@/common/constants/translates/translates'
|
||||
|
||||
type EnumTranslateMap = Record<string, string>
|
||||
type EnumsRegistry = Record<string, EnumTranslateMap>
|
||||
|
||||
export interface EnumTranslatedValue {
|
||||
value: string | null | undefined
|
||||
translate: string | null
|
||||
}
|
||||
|
||||
export function translateEnumValue(
|
||||
enumKey: keyof typeof translates.enums,
|
||||
value: string | null | undefined,
|
||||
): EnumTranslatedValue {
|
||||
const enumsRegistry = translates.enums as EnumsRegistry
|
||||
const enumMap = enumsRegistry[String(enumKey)]
|
||||
|
||||
if (!value) {
|
||||
return {
|
||||
value,
|
||||
translate: null,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
value,
|
||||
translate: enumMap?.[value] ?? null,
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from './jwt-user.util'
|
||||
export * from './enum-translator.util'
|
||||
export * from './mappers/consumer_mappers.util'
|
||||
export * from './password.util'
|
||||
export * from './tracking-code-generator.util'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { translateEnumValue } from '../enum-translator.util'
|
||||
|
||||
export default (consumer: any) => {
|
||||
const { legal, individual, activation, _count, ...rest } = consumer
|
||||
const { legal, individual, activation, type, status, _count, ...rest } = consumer
|
||||
|
||||
const { business_activities: business_counts } = _count || { business_activities: 0 }
|
||||
const partner = legal?.partner || individual?.partner
|
||||
@@ -9,6 +11,8 @@ export default (consumer: any) => {
|
||||
return {
|
||||
...rest,
|
||||
partner,
|
||||
type: translateEnumValue('ConsumerType', consumer.type),
|
||||
status: translateEnumValue('ConsumerStatus', consumer.status),
|
||||
legal: legal ? { ...legal } : null,
|
||||
individual: individual
|
||||
? { ...individual, fullname: `${rest?.first_name} ${rest?.last_name}` }
|
||||
|
||||
@@ -227,6 +227,11 @@ export type SaleInvoiceFiscalAttempts = Prisma.SaleInvoiceFiscalAttemptsModel
|
||||
*
|
||||
*/
|
||||
export type SalesInvoicePayment = Prisma.SalesInvoicePaymentModel
|
||||
/**
|
||||
* Model SalesInvoicePaymentTerminalInfo
|
||||
*
|
||||
*/
|
||||
export type SalesInvoicePaymentTerminalInfo = Prisma.SalesInvoicePaymentTerminalInfoModel
|
||||
/**
|
||||
* Model Service
|
||||
*
|
||||
|
||||
@@ -249,6 +249,11 @@ export type SaleInvoiceFiscalAttempts = Prisma.SaleInvoiceFiscalAttemptsModel
|
||||
*
|
||||
*/
|
||||
export type SalesInvoicePayment = Prisma.SalesInvoicePaymentModel
|
||||
/**
|
||||
* Model SalesInvoicePaymentTerminalInfo
|
||||
*
|
||||
*/
|
||||
export type SalesInvoicePaymentTerminalInfo = Prisma.SalesInvoicePaymentTerminalInfoModel
|
||||
/**
|
||||
* Model Service
|
||||
*
|
||||
|
||||
@@ -195,6 +195,13 @@ export type EnumPartnerStatusFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumPartnerStatusFilter<$PrismaModel> | $Enums.PartnerStatus
|
||||
}
|
||||
|
||||
export type EnumPartnerFiscalSwitchTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerFiscalSwitchType | Prisma.EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerFiscalSwitchType[]
|
||||
notIn?: $Enums.PartnerFiscalSwitchType[]
|
||||
not?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel> | $Enums.PartnerFiscalSwitchType
|
||||
}
|
||||
|
||||
export type EnumPartnerStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerStatus | Prisma.EnumPartnerStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerStatus[]
|
||||
@@ -205,6 +212,16 @@ export type EnumPartnerStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumPartnerStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumPartnerFiscalSwitchTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerFiscalSwitchType | Prisma.EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerFiscalSwitchType[]
|
||||
notIn?: $Enums.PartnerFiscalSwitchType[]
|
||||
not?: Prisma.NestedEnumPartnerFiscalSwitchTypeWithAggregatesFilter<$PrismaModel> | $Enums.PartnerFiscalSwitchType
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumPOSRoleFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.POSRole | Prisma.EnumPOSRoleFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.POSRole[]
|
||||
@@ -831,6 +848,13 @@ export type NestedEnumPartnerStatusFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumPartnerStatusFilter<$PrismaModel> | $Enums.PartnerStatus
|
||||
}
|
||||
|
||||
export type NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerFiscalSwitchType | Prisma.EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerFiscalSwitchType[]
|
||||
notIn?: $Enums.PartnerFiscalSwitchType[]
|
||||
not?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel> | $Enums.PartnerFiscalSwitchType
|
||||
}
|
||||
|
||||
export type NestedEnumPartnerStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerStatus | Prisma.EnumPartnerStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerStatus[]
|
||||
@@ -841,6 +865,16 @@ export type NestedEnumPartnerStatusWithAggregatesFilter<$PrismaModel = never> =
|
||||
_max?: Prisma.NestedEnumPartnerStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumPartnerFiscalSwitchTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.PartnerFiscalSwitchType | Prisma.EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.PartnerFiscalSwitchType[]
|
||||
notIn?: $Enums.PartnerFiscalSwitchType[]
|
||||
not?: Prisma.NestedEnumPartnerFiscalSwitchTypeWithAggregatesFilter<$PrismaModel> | $Enums.PartnerFiscalSwitchType
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumPartnerFiscalSwitchTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumPOSRoleFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.POSRole | Prisma.EnumPOSRoleFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.POSRole[]
|
||||
|
||||
@@ -246,3 +246,20 @@ export const ConsumerType = {
|
||||
} as const
|
||||
|
||||
export type ConsumerType = (typeof ConsumerType)[keyof typeof ConsumerType]
|
||||
|
||||
|
||||
export const PartnerFiscalSwitchType = {
|
||||
NAMA: 'NAMA',
|
||||
SUN: 'SUN'
|
||||
} as const
|
||||
|
||||
export type PartnerFiscalSwitchType = (typeof PartnerFiscalSwitchType)[keyof typeof PartnerFiscalSwitchType]
|
||||
|
||||
|
||||
export const FiscalResponseStatus = {
|
||||
SUCCESS: 'SUCCESS',
|
||||
FAILURE: 'FAILURE',
|
||||
NOT_SEND: 'NOT_SEND'
|
||||
} as const
|
||||
|
||||
export type FiscalResponseStatus = (typeof FiscalResponseStatus)[keyof typeof FiscalResponseStatus]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -426,6 +426,7 @@ export const ModelName = {
|
||||
SaleInvoiceFiscals: 'SaleInvoiceFiscals',
|
||||
SaleInvoiceFiscalAttempts: 'SaleInvoiceFiscalAttempts',
|
||||
SalesInvoicePayment: 'SalesInvoicePayment',
|
||||
SalesInvoicePaymentTerminalInfo: 'SalesInvoicePaymentTerminalInfo',
|
||||
Service: 'Service',
|
||||
ServiceCategory: 'ServiceCategory'
|
||||
} as const
|
||||
@@ -443,7 +444,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" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "good" | "goodCategory" | "guild" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceFiscals" | "saleInvoiceFiscalAttempts" | "salesInvoicePayment" | "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" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "good" | "goodCategory" | "guild" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceFiscals" | "saleInvoiceFiscalAttempts" | "salesInvoicePayment" | "salesInvoicePaymentTerminalInfo" | "service" | "serviceCategory"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -3219,6 +3220,72 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
SalesInvoicePaymentTerminalInfo: {
|
||||
payload: Prisma.$SalesInvoicePaymentTerminalInfoPayload<ExtArgs>
|
||||
fields: Prisma.SalesInvoicePaymentTerminalInfoFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateSalesInvoicePaymentTerminalInfo>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.SalesInvoicePaymentTerminalInfoGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.SalesInvoicePaymentTerminalInfoCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.SalesInvoicePaymentTerminalInfoCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
Service: {
|
||||
payload: Prisma.$ServicePayload<ExtArgs>
|
||||
fields: Prisma.ServiceFieldRefs
|
||||
@@ -3561,6 +3628,7 @@ export const PartnerScalarFieldEnum = {
|
||||
name: 'name',
|
||||
code: 'code',
|
||||
status: 'status',
|
||||
fiscal_switch_type: 'fiscal_switch_type',
|
||||
logo_url: 'logo_url',
|
||||
created_at: 'created_at',
|
||||
updated_at: 'updated_at'
|
||||
@@ -3940,6 +4008,21 @@ export const SalesInvoicePaymentScalarFieldEnum = {
|
||||
export type SalesInvoicePaymentScalarFieldEnum = (typeof SalesInvoicePaymentScalarFieldEnum)[keyof typeof SalesInvoicePaymentScalarFieldEnum]
|
||||
|
||||
|
||||
export const SalesInvoicePaymentTerminalInfoScalarFieldEnum = {
|
||||
id: 'id',
|
||||
terminal_id: 'terminal_id',
|
||||
stan: 'stan',
|
||||
rrn: 'rrn',
|
||||
transaction_date_time: 'transaction_date_time',
|
||||
customer_card_no: 'customer_card_no',
|
||||
description: 'description',
|
||||
created_at: 'created_at',
|
||||
payment_id: 'payment_id'
|
||||
} as const
|
||||
|
||||
export type SalesInvoicePaymentTerminalInfoScalarFieldEnum = (typeof SalesInvoicePaymentTerminalInfoScalarFieldEnum)[keyof typeof SalesInvoicePaymentTerminalInfoScalarFieldEnum]
|
||||
|
||||
|
||||
export const ServiceScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
@@ -4437,6 +4520,19 @@ export const SalesInvoicePaymentOrderByRelevanceFieldEnum = {
|
||||
export type SalesInvoicePaymentOrderByRelevanceFieldEnum = (typeof SalesInvoicePaymentOrderByRelevanceFieldEnum)[keyof typeof SalesInvoicePaymentOrderByRelevanceFieldEnum]
|
||||
|
||||
|
||||
export const SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum = {
|
||||
id: 'id',
|
||||
terminal_id: 'terminal_id',
|
||||
stan: 'stan',
|
||||
rrn: 'rrn',
|
||||
customer_card_no: 'customer_card_no',
|
||||
description: 'description',
|
||||
payment_id: 'payment_id'
|
||||
} as const
|
||||
|
||||
export type SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum = (typeof SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum)[keyof typeof SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum]
|
||||
|
||||
|
||||
export const ServiceOrderByRelevanceFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
@@ -4519,6 +4615,13 @@ export type EnumPartnerStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$Pr
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'PartnerFiscalSwitchType'
|
||||
*/
|
||||
export type EnumPartnerFiscalSwitchTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'PartnerFiscalSwitchType'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'POSRole'
|
||||
*/
|
||||
@@ -4802,6 +4905,7 @@ export type GlobalOmitConfig = {
|
||||
saleInvoiceFiscals?: Prisma.SaleInvoiceFiscalsOmit
|
||||
saleInvoiceFiscalAttempts?: Prisma.SaleInvoiceFiscalAttemptsOmit
|
||||
salesInvoicePayment?: Prisma.SalesInvoicePaymentOmit
|
||||
salesInvoicePaymentTerminalInfo?: Prisma.SalesInvoicePaymentTerminalInfoOmit
|
||||
service?: Prisma.ServiceOmit
|
||||
serviceCategory?: Prisma.ServiceCategoryOmit
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ export const ModelName = {
|
||||
SaleInvoiceFiscals: 'SaleInvoiceFiscals',
|
||||
SaleInvoiceFiscalAttempts: 'SaleInvoiceFiscalAttempts',
|
||||
SalesInvoicePayment: 'SalesInvoicePayment',
|
||||
SalesInvoicePaymentTerminalInfo: 'SalesInvoicePaymentTerminalInfo',
|
||||
Service: 'Service',
|
||||
ServiceCategory: 'ServiceCategory'
|
||||
} as const
|
||||
@@ -284,6 +285,7 @@ export const PartnerScalarFieldEnum = {
|
||||
name: 'name',
|
||||
code: 'code',
|
||||
status: 'status',
|
||||
fiscal_switch_type: 'fiscal_switch_type',
|
||||
logo_url: 'logo_url',
|
||||
created_at: 'created_at',
|
||||
updated_at: 'updated_at'
|
||||
@@ -663,6 +665,21 @@ export const SalesInvoicePaymentScalarFieldEnum = {
|
||||
export type SalesInvoicePaymentScalarFieldEnum = (typeof SalesInvoicePaymentScalarFieldEnum)[keyof typeof SalesInvoicePaymentScalarFieldEnum]
|
||||
|
||||
|
||||
export const SalesInvoicePaymentTerminalInfoScalarFieldEnum = {
|
||||
id: 'id',
|
||||
terminal_id: 'terminal_id',
|
||||
stan: 'stan',
|
||||
rrn: 'rrn',
|
||||
transaction_date_time: 'transaction_date_time',
|
||||
customer_card_no: 'customer_card_no',
|
||||
description: 'description',
|
||||
created_at: 'created_at',
|
||||
payment_id: 'payment_id'
|
||||
} as const
|
||||
|
||||
export type SalesInvoicePaymentTerminalInfoScalarFieldEnum = (typeof SalesInvoicePaymentTerminalInfoScalarFieldEnum)[keyof typeof SalesInvoicePaymentTerminalInfoScalarFieldEnum]
|
||||
|
||||
|
||||
export const ServiceScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
@@ -1160,6 +1177,19 @@ export const SalesInvoicePaymentOrderByRelevanceFieldEnum = {
|
||||
export type SalesInvoicePaymentOrderByRelevanceFieldEnum = (typeof SalesInvoicePaymentOrderByRelevanceFieldEnum)[keyof typeof SalesInvoicePaymentOrderByRelevanceFieldEnum]
|
||||
|
||||
|
||||
export const SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum = {
|
||||
id: 'id',
|
||||
terminal_id: 'terminal_id',
|
||||
stan: 'stan',
|
||||
rrn: 'rrn',
|
||||
customer_card_no: 'customer_card_no',
|
||||
description: 'description',
|
||||
payment_id: 'payment_id'
|
||||
} as const
|
||||
|
||||
export type SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum = (typeof SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum)[keyof typeof SalesInvoicePaymentTerminalInfoOrderByRelevanceFieldEnum]
|
||||
|
||||
|
||||
export const ServiceOrderByRelevanceFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
|
||||
@@ -50,6 +50,7 @@ export type * from './models/SalesInvoiceItem.js'
|
||||
export type * from './models/SaleInvoiceFiscals.js'
|
||||
export type * from './models/SaleInvoiceFiscalAttempts.js'
|
||||
export type * from './models/SalesInvoicePayment.js'
|
||||
export type * from './models/SalesInvoicePaymentTerminalInfo.js'
|
||||
export type * from './models/Service.js'
|
||||
export type * from './models/ServiceCategory.js'
|
||||
export type * from './commonInputTypes.js'
|
||||
@@ -29,6 +29,7 @@ export type PartnerMinAggregateOutputType = {
|
||||
name: string | null
|
||||
code: string | null
|
||||
status: $Enums.PartnerStatus | null
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType | null
|
||||
logo_url: string | null
|
||||
created_at: Date | null
|
||||
updated_at: Date | null
|
||||
@@ -39,6 +40,7 @@ export type PartnerMaxAggregateOutputType = {
|
||||
name: string | null
|
||||
code: string | null
|
||||
status: $Enums.PartnerStatus | null
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType | null
|
||||
logo_url: string | null
|
||||
created_at: Date | null
|
||||
updated_at: Date | null
|
||||
@@ -49,6 +51,7 @@ export type PartnerCountAggregateOutputType = {
|
||||
name: number
|
||||
code: number
|
||||
status: number
|
||||
fiscal_switch_type: number
|
||||
logo_url: number
|
||||
created_at: number
|
||||
updated_at: number
|
||||
@@ -61,6 +64,7 @@ export type PartnerMinAggregateInputType = {
|
||||
name?: true
|
||||
code?: true
|
||||
status?: true
|
||||
fiscal_switch_type?: true
|
||||
logo_url?: true
|
||||
created_at?: true
|
||||
updated_at?: true
|
||||
@@ -71,6 +75,7 @@ export type PartnerMaxAggregateInputType = {
|
||||
name?: true
|
||||
code?: true
|
||||
status?: true
|
||||
fiscal_switch_type?: true
|
||||
logo_url?: true
|
||||
created_at?: true
|
||||
updated_at?: true
|
||||
@@ -81,6 +86,7 @@ export type PartnerCountAggregateInputType = {
|
||||
name?: true
|
||||
code?: true
|
||||
status?: true
|
||||
fiscal_switch_type?: true
|
||||
logo_url?: true
|
||||
created_at?: true
|
||||
updated_at?: true
|
||||
@@ -164,6 +170,7 @@ export type PartnerGroupByOutputType = {
|
||||
name: string
|
||||
code: string
|
||||
status: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url: string | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
@@ -195,6 +202,7 @@ export type PartnerWhereInput = {
|
||||
name?: Prisma.StringFilter<"Partner"> | string
|
||||
code?: Prisma.StringFilter<"Partner"> | string
|
||||
status?: Prisma.EnumPartnerStatusFilter<"Partner"> | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFilter<"Partner"> | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.StringNullableFilter<"Partner"> | string | null
|
||||
created_at?: Prisma.DateTimeFilter<"Partner"> | Date | string
|
||||
updated_at?: Prisma.DateTimeFilter<"Partner"> | Date | string
|
||||
@@ -211,6 +219,7 @@ export type PartnerOrderByWithRelationInput = {
|
||||
name?: Prisma.SortOrder
|
||||
code?: Prisma.SortOrder
|
||||
status?: Prisma.SortOrder
|
||||
fiscal_switch_type?: Prisma.SortOrder
|
||||
logo_url?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
created_at?: Prisma.SortOrder
|
||||
updated_at?: Prisma.SortOrder
|
||||
@@ -231,6 +240,7 @@ export type PartnerWhereUniqueInput = Prisma.AtLeast<{
|
||||
NOT?: Prisma.PartnerWhereInput | Prisma.PartnerWhereInput[]
|
||||
name?: Prisma.StringFilter<"Partner"> | string
|
||||
status?: Prisma.EnumPartnerStatusFilter<"Partner"> | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFilter<"Partner"> | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.StringNullableFilter<"Partner"> | string | null
|
||||
created_at?: Prisma.DateTimeFilter<"Partner"> | Date | string
|
||||
updated_at?: Prisma.DateTimeFilter<"Partner"> | Date | string
|
||||
@@ -247,6 +257,7 @@ export type PartnerOrderByWithAggregationInput = {
|
||||
name?: Prisma.SortOrder
|
||||
code?: Prisma.SortOrder
|
||||
status?: Prisma.SortOrder
|
||||
fiscal_switch_type?: Prisma.SortOrder
|
||||
logo_url?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
created_at?: Prisma.SortOrder
|
||||
updated_at?: Prisma.SortOrder
|
||||
@@ -263,6 +274,7 @@ export type PartnerScalarWhereWithAggregatesInput = {
|
||||
name?: Prisma.StringWithAggregatesFilter<"Partner"> | string
|
||||
code?: Prisma.StringWithAggregatesFilter<"Partner"> | string
|
||||
status?: Prisma.EnumPartnerStatusWithAggregatesFilter<"Partner"> | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeWithAggregatesFilter<"Partner"> | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.StringNullableWithAggregatesFilter<"Partner"> | string | null
|
||||
created_at?: Prisma.DateTimeWithAggregatesFilter<"Partner"> | Date | string
|
||||
updated_at?: Prisma.DateTimeWithAggregatesFilter<"Partner"> | Date | string
|
||||
@@ -273,6 +285,7 @@ export type PartnerCreateInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -289,6 +302,7 @@ export type PartnerUncheckedCreateInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -305,6 +319,7 @@ export type PartnerUpdateInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -321,6 +336,7 @@ export type PartnerUncheckedUpdateInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -337,6 +353,7 @@ export type PartnerCreateManyInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -347,6 +364,7 @@ export type PartnerUpdateManyMutationInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -357,6 +375,7 @@ export type PartnerUncheckedUpdateManyInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -378,6 +397,7 @@ export type PartnerCountOrderByAggregateInput = {
|
||||
name?: Prisma.SortOrder
|
||||
code?: Prisma.SortOrder
|
||||
status?: Prisma.SortOrder
|
||||
fiscal_switch_type?: Prisma.SortOrder
|
||||
logo_url?: Prisma.SortOrder
|
||||
created_at?: Prisma.SortOrder
|
||||
updated_at?: Prisma.SortOrder
|
||||
@@ -388,6 +408,7 @@ export type PartnerMaxOrderByAggregateInput = {
|
||||
name?: Prisma.SortOrder
|
||||
code?: Prisma.SortOrder
|
||||
status?: Prisma.SortOrder
|
||||
fiscal_switch_type?: Prisma.SortOrder
|
||||
logo_url?: Prisma.SortOrder
|
||||
created_at?: Prisma.SortOrder
|
||||
updated_at?: Prisma.SortOrder
|
||||
@@ -398,6 +419,7 @@ export type PartnerMinOrderByAggregateInput = {
|
||||
name?: Prisma.SortOrder
|
||||
code?: Prisma.SortOrder
|
||||
status?: Prisma.SortOrder
|
||||
fiscal_switch_type?: Prisma.SortOrder
|
||||
logo_url?: Prisma.SortOrder
|
||||
created_at?: Prisma.SortOrder
|
||||
updated_at?: Prisma.SortOrder
|
||||
@@ -463,6 +485,10 @@ export type EnumPartnerStatusFieldUpdateOperationsInput = {
|
||||
set?: $Enums.PartnerStatus
|
||||
}
|
||||
|
||||
export type EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput = {
|
||||
set?: $Enums.PartnerFiscalSwitchType
|
||||
}
|
||||
|
||||
export type PartnerCreateNestedOneWithoutConsumers_individualInput = {
|
||||
create?: Prisma.XOR<Prisma.PartnerCreateWithoutConsumers_individualInput, Prisma.PartnerUncheckedCreateWithoutConsumers_individualInput>
|
||||
connectOrCreate?: Prisma.PartnerCreateOrConnectWithoutConsumers_individualInput
|
||||
@@ -496,6 +522,7 @@ export type PartnerCreateWithoutLicense_charge_transactionsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -511,6 +538,7 @@ export type PartnerUncheckedCreateWithoutLicense_charge_transactionsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -542,6 +570,7 @@ export type PartnerUpdateWithoutLicense_charge_transactionsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -557,6 +586,7 @@ export type PartnerUncheckedUpdateWithoutLicense_charge_transactionsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -572,6 +602,7 @@ export type PartnerCreateWithoutLicense_renew_charge_transactionsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -587,6 +618,7 @@ export type PartnerUncheckedCreateWithoutLicense_renew_charge_transactionsInput
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -618,6 +650,7 @@ export type PartnerUpdateWithoutLicense_renew_charge_transactionsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -633,6 +666,7 @@ export type PartnerUncheckedUpdateWithoutLicense_renew_charge_transactionsInput
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -648,6 +682,7 @@ export type PartnerCreateWithoutAccount_quota_charge_transactionsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -663,6 +698,7 @@ export type PartnerUncheckedCreateWithoutAccount_quota_charge_transactionsInput
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -694,6 +730,7 @@ export type PartnerUpdateWithoutAccount_quota_charge_transactionsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -709,6 +746,7 @@ export type PartnerUncheckedUpdateWithoutAccount_quota_charge_transactionsInput
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -724,6 +762,7 @@ export type PartnerCreateWithoutAccountsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -739,6 +778,7 @@ export type PartnerUncheckedCreateWithoutAccountsInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -770,6 +810,7 @@ export type PartnerUpdateWithoutAccountsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -785,6 +826,7 @@ export type PartnerUncheckedUpdateWithoutAccountsInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -800,6 +842,7 @@ export type PartnerCreateWithoutConsumers_individualInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -815,6 +858,7 @@ export type PartnerUncheckedCreateWithoutConsumers_individualInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -846,6 +890,7 @@ export type PartnerUpdateWithoutConsumers_individualInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -861,6 +906,7 @@ export type PartnerUncheckedUpdateWithoutConsumers_individualInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -876,6 +922,7 @@ export type PartnerCreateWithoutConsumers_legalInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -891,6 +938,7 @@ export type PartnerUncheckedCreateWithoutConsumers_legalInput = {
|
||||
name: string
|
||||
code: string
|
||||
status?: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: string | null
|
||||
created_at?: Date | string
|
||||
updated_at?: Date | string
|
||||
@@ -922,6 +970,7 @@ export type PartnerUpdateWithoutConsumers_legalInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -937,6 +986,7 @@ export type PartnerUncheckedUpdateWithoutConsumers_legalInput = {
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
code?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
status?: Prisma.EnumPartnerStatusFieldUpdateOperationsInput | $Enums.PartnerStatus
|
||||
fiscal_switch_type?: Prisma.EnumPartnerFiscalSwitchTypeFieldUpdateOperationsInput | $Enums.PartnerFiscalSwitchType
|
||||
logo_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
@@ -1028,6 +1078,7 @@ export type PartnerSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs
|
||||
name?: boolean
|
||||
code?: boolean
|
||||
status?: boolean
|
||||
fiscal_switch_type?: boolean
|
||||
logo_url?: boolean
|
||||
created_at?: boolean
|
||||
updated_at?: boolean
|
||||
@@ -1047,12 +1098,13 @@ export type PartnerSelectScalar = {
|
||||
name?: boolean
|
||||
code?: boolean
|
||||
status?: boolean
|
||||
fiscal_switch_type?: boolean
|
||||
logo_url?: boolean
|
||||
created_at?: boolean
|
||||
updated_at?: boolean
|
||||
}
|
||||
|
||||
export type PartnerOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "code" | "status" | "logo_url" | "created_at" | "updated_at", ExtArgs["result"]["partner"]>
|
||||
export type PartnerOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "code" | "status" | "fiscal_switch_type" | "logo_url" | "created_at" | "updated_at", ExtArgs["result"]["partner"]>
|
||||
export type PartnerInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
accounts?: boolean | Prisma.Partner$accountsArgs<ExtArgs>
|
||||
consumers_individual?: boolean | Prisma.Partner$consumers_individualArgs<ExtArgs>
|
||||
@@ -1078,6 +1130,7 @@ export type $PartnerPayload<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
name: string
|
||||
code: string
|
||||
status: $Enums.PartnerStatus
|
||||
fiscal_switch_type: $Enums.PartnerFiscalSwitchType
|
||||
logo_url: string | null
|
||||
created_at: Date
|
||||
updated_at: Date
|
||||
@@ -1460,6 +1513,7 @@ export interface PartnerFieldRefs {
|
||||
readonly name: Prisma.FieldRef<"Partner", 'String'>
|
||||
readonly code: Prisma.FieldRef<"Partner", 'String'>
|
||||
readonly status: Prisma.FieldRef<"Partner", 'PartnerStatus'>
|
||||
readonly fiscal_switch_type: Prisma.FieldRef<"Partner", 'PartnerFiscalSwitchType'>
|
||||
readonly logo_url: Prisma.FieldRef<"Partner", 'String'>
|
||||
readonly created_at: Prisma.FieldRef<"Partner", 'DateTime'>
|
||||
readonly updated_at: Prisma.FieldRef<"Partner", 'DateTime'>
|
||||
|
||||
@@ -225,6 +225,7 @@ export type SalesInvoicePaymentWhereInput = {
|
||||
created_at?: Prisma.DateTimeFilter<"SalesInvoicePayment"> | Date | string
|
||||
invoice_id?: Prisma.StringFilter<"SalesInvoicePayment"> | string
|
||||
invoice?: Prisma.XOR<Prisma.SalesInvoiceScalarRelationFilter, Prisma.SalesInvoiceWhereInput>
|
||||
terminal_info?: Prisma.XOR<Prisma.SalesInvoicePaymentTerminalInfoNullableScalarRelationFilter, Prisma.SalesInvoicePaymentTerminalInfoWhereInput> | null
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentOrderByWithRelationInput = {
|
||||
@@ -235,6 +236,7 @@ export type SalesInvoicePaymentOrderByWithRelationInput = {
|
||||
created_at?: Prisma.SortOrder
|
||||
invoice_id?: Prisma.SortOrder
|
||||
invoice?: Prisma.SalesInvoiceOrderByWithRelationInput
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoOrderByWithRelationInput
|
||||
_relevance?: Prisma.SalesInvoicePaymentOrderByRelevanceInput
|
||||
}
|
||||
|
||||
@@ -249,6 +251,7 @@ export type SalesInvoicePaymentWhereUniqueInput = Prisma.AtLeast<{
|
||||
created_at?: Prisma.DateTimeFilter<"SalesInvoicePayment"> | Date | string
|
||||
invoice_id?: Prisma.StringFilter<"SalesInvoicePayment"> | string
|
||||
invoice?: Prisma.XOR<Prisma.SalesInvoiceScalarRelationFilter, Prisma.SalesInvoiceWhereInput>
|
||||
terminal_info?: Prisma.XOR<Prisma.SalesInvoicePaymentTerminalInfoNullableScalarRelationFilter, Prisma.SalesInvoicePaymentTerminalInfoWhereInput> | null
|
||||
}, "id">
|
||||
|
||||
export type SalesInvoicePaymentOrderByWithAggregationInput = {
|
||||
@@ -284,6 +287,7 @@ export type SalesInvoicePaymentCreateInput = {
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
invoice: Prisma.SalesInvoiceCreateNestedOneWithoutPaymentsInput
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoCreateNestedOneWithoutPaymentInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedCreateInput = {
|
||||
@@ -293,6 +297,7 @@ export type SalesInvoicePaymentUncheckedCreateInput = {
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
invoice_id: string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUncheckedCreateNestedOneWithoutPaymentInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUpdateInput = {
|
||||
@@ -302,6 +307,7 @@ export type SalesInvoicePaymentUpdateInput = {
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
invoice?: Prisma.SalesInvoiceUpdateOneRequiredWithoutPaymentsNestedInput
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUpdateOneWithoutPaymentNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedUpdateInput = {
|
||||
@@ -311,6 +317,7 @@ export type SalesInvoicePaymentUncheckedUpdateInput = {
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
invoice_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUncheckedUpdateOneWithoutPaymentNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateManyInput = {
|
||||
@@ -390,6 +397,11 @@ export type SalesInvoicePaymentSumOrderByAggregateInput = {
|
||||
amount?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentScalarRelationFilter = {
|
||||
is?: Prisma.SalesInvoicePaymentWhereInput
|
||||
isNot?: Prisma.SalesInvoicePaymentWhereInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateNestedManyWithoutInvoiceInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoicePaymentCreateWithoutInvoiceInput, Prisma.SalesInvoicePaymentUncheckedCreateWithoutInvoiceInput> | Prisma.SalesInvoicePaymentCreateWithoutInvoiceInput[] | Prisma.SalesInvoicePaymentUncheckedCreateWithoutInvoiceInput[]
|
||||
connectOrCreate?: Prisma.SalesInvoicePaymentCreateOrConnectWithoutInvoiceInput | Prisma.SalesInvoicePaymentCreateOrConnectWithoutInvoiceInput[]
|
||||
@@ -436,12 +448,27 @@ export type EnumPaymentMethodTypeFieldUpdateOperationsInput = {
|
||||
set?: $Enums.PaymentMethodType
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateNestedOneWithoutTerminal_infoInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoicePaymentCreateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedCreateWithoutTerminal_infoInput>
|
||||
connectOrCreate?: Prisma.SalesInvoicePaymentCreateOrConnectWithoutTerminal_infoInput
|
||||
connect?: Prisma.SalesInvoicePaymentWhereUniqueInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUpdateOneRequiredWithoutTerminal_infoNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.SalesInvoicePaymentCreateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedCreateWithoutTerminal_infoInput>
|
||||
connectOrCreate?: Prisma.SalesInvoicePaymentCreateOrConnectWithoutTerminal_infoInput
|
||||
upsert?: Prisma.SalesInvoicePaymentUpsertWithoutTerminal_infoInput
|
||||
connect?: Prisma.SalesInvoicePaymentWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.SalesInvoicePaymentUpdateToOneWithWhereWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUpdateWithoutTerminal_infoInput>, Prisma.SalesInvoicePaymentUncheckedUpdateWithoutTerminal_infoInput>
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateWithoutInvoiceInput = {
|
||||
id?: string
|
||||
amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
payment_method: $Enums.PaymentMethodType
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoCreateNestedOneWithoutPaymentInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedCreateWithoutInvoiceInput = {
|
||||
@@ -450,6 +477,7 @@ export type SalesInvoicePaymentUncheckedCreateWithoutInvoiceInput = {
|
||||
payment_method: $Enums.PaymentMethodType
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUncheckedCreateNestedOneWithoutPaymentInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateOrConnectWithoutInvoiceInput = {
|
||||
@@ -490,6 +518,58 @@ export type SalesInvoicePaymentScalarWhereInput = {
|
||||
invoice_id?: Prisma.StringFilter<"SalesInvoicePayment"> | string
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateWithoutTerminal_infoInput = {
|
||||
id?: string
|
||||
amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
payment_method: $Enums.PaymentMethodType
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
invoice: Prisma.SalesInvoiceCreateNestedOneWithoutPaymentsInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedCreateWithoutTerminal_infoInput = {
|
||||
id?: string
|
||||
amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
payment_method: $Enums.PaymentMethodType
|
||||
paid_at: Date | string
|
||||
created_at?: Date | string
|
||||
invoice_id: string
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateOrConnectWithoutTerminal_infoInput = {
|
||||
where: Prisma.SalesInvoicePaymentWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.SalesInvoicePaymentCreateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedCreateWithoutTerminal_infoInput>
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUpsertWithoutTerminal_infoInput = {
|
||||
update: Prisma.XOR<Prisma.SalesInvoicePaymentUpdateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedUpdateWithoutTerminal_infoInput>
|
||||
create: Prisma.XOR<Prisma.SalesInvoicePaymentCreateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedCreateWithoutTerminal_infoInput>
|
||||
where?: Prisma.SalesInvoicePaymentWhereInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUpdateToOneWithWhereWithoutTerminal_infoInput = {
|
||||
where?: Prisma.SalesInvoicePaymentWhereInput
|
||||
data: Prisma.XOR<Prisma.SalesInvoicePaymentUpdateWithoutTerminal_infoInput, Prisma.SalesInvoicePaymentUncheckedUpdateWithoutTerminal_infoInput>
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUpdateWithoutTerminal_infoInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
amount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
payment_method?: Prisma.EnumPaymentMethodTypeFieldUpdateOperationsInput | $Enums.PaymentMethodType
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
invoice?: Prisma.SalesInvoiceUpdateOneRequiredWithoutPaymentsNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedUpdateWithoutTerminal_infoInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
amount?: Prisma.DecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
payment_method?: Prisma.EnumPaymentMethodTypeFieldUpdateOperationsInput | $Enums.PaymentMethodType
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
invoice_id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentCreateManyInvoiceInput = {
|
||||
id?: string
|
||||
amount: runtime.Decimal | runtime.DecimalJsLike | number | string
|
||||
@@ -504,6 +584,7 @@ export type SalesInvoicePaymentUpdateWithoutInvoiceInput = {
|
||||
payment_method?: Prisma.EnumPaymentMethodTypeFieldUpdateOperationsInput | $Enums.PaymentMethodType
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUpdateOneWithoutPaymentNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedUpdateWithoutInvoiceInput = {
|
||||
@@ -512,6 +593,7 @@ export type SalesInvoicePaymentUncheckedUpdateWithoutInvoiceInput = {
|
||||
payment_method?: Prisma.EnumPaymentMethodTypeFieldUpdateOperationsInput | $Enums.PaymentMethodType
|
||||
paid_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
terminal_info?: Prisma.SalesInvoicePaymentTerminalInfoUncheckedUpdateOneWithoutPaymentNestedInput
|
||||
}
|
||||
|
||||
export type SalesInvoicePaymentUncheckedUpdateManyWithoutInvoiceInput = {
|
||||
@@ -532,6 +614,7 @@ export type SalesInvoicePaymentSelect<ExtArgs extends runtime.Types.Extensions.I
|
||||
created_at?: boolean
|
||||
invoice_id?: boolean
|
||||
invoice?: boolean | Prisma.SalesInvoiceDefaultArgs<ExtArgs>
|
||||
terminal_info?: boolean | Prisma.SalesInvoicePayment$terminal_infoArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["salesInvoicePayment"]>
|
||||
|
||||
|
||||
@@ -548,12 +631,14 @@ export type SalesInvoicePaymentSelectScalar = {
|
||||
export type SalesInvoicePaymentOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "amount" | "payment_method" | "paid_at" | "created_at" | "invoice_id", ExtArgs["result"]["salesInvoicePayment"]>
|
||||
export type SalesInvoicePaymentInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
invoice?: boolean | Prisma.SalesInvoiceDefaultArgs<ExtArgs>
|
||||
terminal_info?: boolean | Prisma.SalesInvoicePayment$terminal_infoArgs<ExtArgs>
|
||||
}
|
||||
|
||||
export type $SalesInvoicePaymentPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
name: "SalesInvoicePayment"
|
||||
objects: {
|
||||
invoice: Prisma.$SalesInvoicePayload<ExtArgs>
|
||||
terminal_info: Prisma.$SalesInvoicePaymentTerminalInfoPayload<ExtArgs> | null
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -903,6 +988,7 @@ readonly fields: SalesInvoicePaymentFieldRefs;
|
||||
export interface Prisma__SalesInvoicePaymentClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
|
||||
readonly [Symbol.toStringTag]: "PrismaPromise"
|
||||
invoice<T extends Prisma.SalesInvoiceDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.SalesInvoiceDefaultArgs<ExtArgs>>): Prisma.Prisma__SalesInvoiceClient<runtime.Types.Result.GetResult<Prisma.$SalesInvoicePayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
terminal_info<T extends Prisma.SalesInvoicePayment$terminal_infoArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.SalesInvoicePayment$terminal_infoArgs<ExtArgs>>): Prisma.Prisma__SalesInvoicePaymentTerminalInfoClient<runtime.Types.Result.GetResult<Prisma.$SalesInvoicePaymentTerminalInfoPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -1285,6 +1371,25 @@ export type SalesInvoicePaymentDeleteManyArgs<ExtArgs extends runtime.Types.Exte
|
||||
limit?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* SalesInvoicePayment.terminal_info
|
||||
*/
|
||||
export type SalesInvoicePayment$terminal_infoArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the SalesInvoicePaymentTerminalInfo
|
||||
*/
|
||||
select?: Prisma.SalesInvoicePaymentTerminalInfoSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the SalesInvoicePaymentTerminalInfo
|
||||
*/
|
||||
omit?: Prisma.SalesInvoicePaymentTerminalInfoOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.SalesInvoicePaymentTerminalInfoInclude<ExtArgs> | null
|
||||
where?: Prisma.SalesInvoicePaymentTerminalInfoWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* SalesInvoicePayment without action
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+5
-1
@@ -57,7 +57,11 @@ async function bootstrap() {
|
||||
|
||||
// Enable CORS. You can set `CORS_ORIGINS` to a comma-separated list of allowed origins.
|
||||
// Defaults include common localhost origins used by front-end dev servers.
|
||||
const defaultOrigins = ['http://localhost:5000', 'http://127.0.0.1:5000']
|
||||
const defaultOrigins = [
|
||||
'http://localhost:5000',
|
||||
'http://127.0.0.1:5000',
|
||||
'http://192.168.128.73:5000',
|
||||
]
|
||||
const envOrigins = process.env.CORS_ORIGINS
|
||||
? process.env.CORS_ORIGINS.split(',')
|
||||
.map(s => s.trim())
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { translateEnumValue } from '@/common/utils'
|
||||
import { PasswordUtil } from '@/common/utils/password.util'
|
||||
import { AccountStatus, AccountType } from '@/generated/prisma/enums'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
@@ -16,6 +17,22 @@ export class AccountsService {
|
||||
id: true,
|
||||
role: true,
|
||||
created_at: true,
|
||||
pos: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
complex: {
|
||||
select: {
|
||||
name: true,
|
||||
business_activity: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
account: {
|
||||
select: {
|
||||
username: true,
|
||||
@@ -24,7 +41,15 @@ export class AccountsService {
|
||||
},
|
||||
},
|
||||
})
|
||||
return ResponseMapper.list(accounts)
|
||||
|
||||
const mappedAccounts = accounts.map(account => {
|
||||
return {
|
||||
...account,
|
||||
role: translateEnumValue('ConsumerRole', account.role),
|
||||
status: translateEnumValue('AccountStatus', account.account.status),
|
||||
}
|
||||
})
|
||||
return ResponseMapper.list(mappedAccounts)
|
||||
}
|
||||
|
||||
async findOne(id: string) {
|
||||
|
||||
@@ -17,6 +17,9 @@ export class BusinessActivitiesService {
|
||||
},
|
||||
id: true,
|
||||
name: true,
|
||||
economic_code: true,
|
||||
fiscal_id: true,
|
||||
partner_token: true,
|
||||
created_at: true,
|
||||
} as BusinessActivitySelect
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PartnerStatus } from '@/generated/prisma/enums'
|
||||
import { PartnerFiscalSwitchType, PartnerStatus } from '@/generated/prisma/enums'
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator'
|
||||
|
||||
@@ -11,10 +11,14 @@ export class CreatePartnerDto {
|
||||
@ApiProperty({ required: true })
|
||||
code: string
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@IsEnum(PartnerFiscalSwitchType)
|
||||
@ApiProperty({ required: true })
|
||||
license_quota?: number
|
||||
fiscal_switch_type: PartnerFiscalSwitchType
|
||||
|
||||
// @IsOptional()
|
||||
// @IsNumber()
|
||||
// @ApiProperty({ required: true })
|
||||
// license_quota?: number
|
||||
|
||||
@IsString()
|
||||
@ApiProperty({ required: true })
|
||||
|
||||
@@ -27,6 +27,7 @@ export class PartnersService {
|
||||
code: true,
|
||||
status: true,
|
||||
logo_url: true,
|
||||
fiscal_switch_type: true,
|
||||
created_at: true,
|
||||
license_charge_transactions: {
|
||||
select: {
|
||||
|
||||
+12
-10
@@ -1,14 +1,14 @@
|
||||
import { Injectable } from '@nestjs/common'
|
||||
import {
|
||||
TaxSwitchBulkSendResultDto,
|
||||
TaxSwitchBulkSendResultDto as FiscalSwitchBulkSendResultDto,
|
||||
TaxSwitchSendItemResultDto as FiscalSwitchSendItemResultDto,
|
||||
TaxSwitchSendPayloadDto as FiscalSwitchSendPayloadDto,
|
||||
TaxSwitchGetResultDto,
|
||||
TaxSwitchSendItemResultDto,
|
||||
TaxSwitchSendPayloadDto,
|
||||
} from './dto/tax-switch.dto'
|
||||
import { NamaTaxSwitchAdapter } from './switch/nama-tax-switch.adapter'
|
||||
import { NamaTaxSwitchAdapter } from './switch/nama/nama-fiscal-switch.adapter'
|
||||
|
||||
@Injectable()
|
||||
export class SalesInvoiceTaxSwitchService {
|
||||
export class SalesInvoiceFiscalSwitchService {
|
||||
constructor(private readonly namaAdapter: NamaTaxSwitchAdapter) {}
|
||||
|
||||
private resolveSwitch(providerCode?: string | null) {
|
||||
@@ -21,15 +21,17 @@ export class SalesInvoiceTaxSwitchService {
|
||||
}
|
||||
}
|
||||
|
||||
async send(payload: TaxSwitchSendPayloadDto): Promise<TaxSwitchSendItemResultDto[]> {
|
||||
async send(
|
||||
payload: FiscalSwitchSendPayloadDto,
|
||||
): Promise<FiscalSwitchSendItemResultDto[]> {
|
||||
const adapter = this.resolveSwitch(payload.provider_code)
|
||||
return adapter.send(payload)
|
||||
}
|
||||
|
||||
async sendBulk(
|
||||
payloads: TaxSwitchSendPayloadDto[],
|
||||
): Promise<TaxSwitchBulkSendResultDto[]> {
|
||||
const groupedByProvider = new Map<string, TaxSwitchSendPayloadDto[]>()
|
||||
payloads: FiscalSwitchSendPayloadDto[],
|
||||
): Promise<FiscalSwitchBulkSendResultDto[]> {
|
||||
const groupedByProvider = new Map<string, FiscalSwitchSendPayloadDto[]>()
|
||||
|
||||
for (const payload of payloads) {
|
||||
const key = payload.provider_code?.trim().toUpperCase() || 'NAMA'
|
||||
@@ -38,7 +40,7 @@ export class SalesInvoiceTaxSwitchService {
|
||||
groupedByProvider.set(key, currentGroup)
|
||||
}
|
||||
|
||||
const result: TaxSwitchBulkSendResultDto[] = []
|
||||
const result: FiscalSwitchBulkSendResultDto[] = []
|
||||
for (const [providerCode, groupedPayloads] of groupedByProvider.entries()) {
|
||||
const adapter = this.resolveSwitch(providerCode)
|
||||
const providerResult = await adapter.sendBulk(groupedPayloads)
|
||||
+4
-4
@@ -7,7 +7,7 @@ import {
|
||||
TaxSwitchSendItemResultDto,
|
||||
TaxSwitchSendPayloadDto,
|
||||
} from './dto/tax-switch.dto'
|
||||
import { SalesInvoiceTaxSwitchService } from './sales-invoice-tax-switch.service'
|
||||
import { SalesInvoiceFiscalSwitchService } from './sales-invoice-fiscal-switch.service'
|
||||
|
||||
type TaxRow = {
|
||||
id: string
|
||||
@@ -20,10 +20,10 @@ type ItemTaxProviderRow = {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SalesInvoiceTaxService {
|
||||
export class SalesInvoiceFiscalService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly taxSwitchService: SalesInvoiceTaxSwitchService,
|
||||
private readonly taxSwitchService: SalesInvoiceFiscalSwitchService,
|
||||
) {}
|
||||
|
||||
async send(consumer_id: string, invoice_id: string): Promise<void> {
|
||||
@@ -173,7 +173,7 @@ export class SalesInvoiceTaxService {
|
||||
})
|
||||
|
||||
if (!invoice) {
|
||||
throw new NotFoundException('Sales invoice was not found.')
|
||||
throw new NotFoundException('فاکتور مورد نظر یافت نشد.')
|
||||
}
|
||||
|
||||
return {
|
||||
+1
-1
@@ -6,7 +6,7 @@ import {
|
||||
TaxSwitchGetResultDto,
|
||||
TaxSwitchSendItemResultDto,
|
||||
TaxSwitchSendPayloadDto,
|
||||
} from '../dto/tax-switch.dto'
|
||||
} from '../../dto/tax-switch.dto'
|
||||
|
||||
@Injectable()
|
||||
export class NamaTaxSwitchAdapter implements ITaxSwitchAdapter {
|
||||
@@ -0,0 +1,124 @@
|
||||
import { ApiProperty } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import { IsArray, IsString, ValidateNested } from 'class-validator'
|
||||
|
||||
export class NamaTaxBodyItemDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
sstid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
vra: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
sstt: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fee: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
dis: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
mu: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
am: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
consfee: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
bros: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
spro: string
|
||||
}
|
||||
|
||||
export class NamaTaxHeaderDto {
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
ins: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inp: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inty: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
unique_tax_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
inno: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tins: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
indatim: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
name: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
tob: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
address: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
mobile: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
bid: string
|
||||
}
|
||||
|
||||
export class NamaTaxRequestDto {
|
||||
@ApiProperty({ type: [NamaTaxBodyItemDto] })
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => NamaTaxBodyItemDto)
|
||||
body: NamaTaxBodyItemDto[]
|
||||
|
||||
@ApiProperty({ type: [Object] })
|
||||
@IsArray()
|
||||
payment: unknown[]
|
||||
|
||||
@ApiProperty({ type: NamaTaxHeaderDto })
|
||||
@ValidateNested()
|
||||
@Type(() => NamaTaxHeaderDto)
|
||||
header: NamaTaxHeaderDto
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
uuid: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
economic_code: string
|
||||
|
||||
@ApiProperty()
|
||||
@IsString()
|
||||
fiscal_id: string
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
import { PrismaModule } from '@/prisma/prisma.module'
|
||||
import { Module } from '@nestjs/common'
|
||||
import { SalesInvoiceFiscalSwitchService } from './fiscal/sales-invoice-fiscal-switch.service'
|
||||
import { SalesInvoiceFiscalService } from './fiscal/sales-invoice-fiscal.service'
|
||||
import { NamaTaxSwitchAdapter } from './fiscal/switch/nama/nama-fiscal-switch.adapter'
|
||||
import { StatisticsController } from './saleInvoices.controller'
|
||||
import { SaleInvoicesService } from './saleInvoices.service'
|
||||
import { SalesInvoiceTaxSwitchService } from './tax/sales-invoice-tax-switch.service'
|
||||
import { SalesInvoiceTaxService } from './tax/sales-invoice-tax.service'
|
||||
import { NamaTaxSwitchAdapter } from './tax/switch/nama-tax-switch.adapter'
|
||||
|
||||
@Module({
|
||||
imports: [PrismaModule],
|
||||
controllers: [StatisticsController],
|
||||
providers: [
|
||||
SaleInvoicesService,
|
||||
SalesInvoiceTaxService,
|
||||
SalesInvoiceTaxSwitchService,
|
||||
SalesInvoiceFiscalService,
|
||||
SalesInvoiceFiscalSwitchService,
|
||||
NamaTaxSwitchAdapter,
|
||||
],
|
||||
exports: [SaleInvoicesService],
|
||||
|
||||
@@ -6,13 +6,13 @@ import {
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { BadRequestException, Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import { SalesInvoiceTaxService } from './tax/sales-invoice-tax.service'
|
||||
import { SalesInvoiceFiscalService } from './fiscal/sales-invoice-fiscal.service'
|
||||
|
||||
@Injectable()
|
||||
export class SaleInvoicesService {
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private salesInvoiceTaxService: SalesInvoiceTaxService,
|
||||
private salesInvoiceTaxService: SalesInvoiceFiscalService,
|
||||
) {}
|
||||
|
||||
private readonly defaultSelect: SalesInvoiceSelect = {
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
import translates from '@/common/constants/translates/translates'
|
||||
import { translateEnumValue } from '@/common/utils/enum-translator.util'
|
||||
import {
|
||||
AccountRole,
|
||||
AccountStatus,
|
||||
ApplicationPlatform,
|
||||
ApplicationPublisher,
|
||||
ApplicationReleaseType,
|
||||
BusinessRole,
|
||||
ConsumerRole,
|
||||
ConsumerStatus,
|
||||
ConsumerType,
|
||||
CustomerType,
|
||||
FiscalResponseStatus,
|
||||
GoodPricingModel,
|
||||
LicenseStatus,
|
||||
LicenseType,
|
||||
PartnerFiscalSwitchType,
|
||||
PartnerRole,
|
||||
PartnerStatus,
|
||||
PaymentMethodType,
|
||||
POSRole,
|
||||
POSStatus,
|
||||
POSType,
|
||||
ProviderRole,
|
||||
ProviderStatus,
|
||||
UnitType,
|
||||
UserStatus,
|
||||
UserType,
|
||||
@@ -22,33 +34,62 @@ import { ResponseMapper } from 'common/response/response-mapper'
|
||||
|
||||
@Injectable()
|
||||
export class EnumsService {
|
||||
private prepareData(items: Record<string, string>) {
|
||||
return Object.values(items).map(item => ({
|
||||
name: translates.enums[item] || item,
|
||||
value: item,
|
||||
}))
|
||||
private prepareData(
|
||||
items: Record<string, string>,
|
||||
enumName: keyof typeof translates.enums,
|
||||
) {
|
||||
return Object.values(items).map(item => {
|
||||
const translated = translateEnumValue(enumName, item)
|
||||
return {
|
||||
name: translated.translate || item,
|
||||
value: translated.value,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getAllEnums() {
|
||||
return {
|
||||
GoldKarat: this.prepareData(GoldKarat),
|
||||
UserStatus: this.prepareData(UserStatus),
|
||||
AccountRole: this.prepareData(AccountRole),
|
||||
AccountStatus: this.prepareData(AccountStatus),
|
||||
POSStatus: this.prepareData(POSStatus),
|
||||
POSRole: this.prepareData(POSRole),
|
||||
LicenseType: this.prepareData(LicenseType),
|
||||
LicenseStatus: this.prepareData(LicenseStatus),
|
||||
POSType: this.prepareData(POSType),
|
||||
UserType: this.prepareData(UserType),
|
||||
AccountType: this.prepareData(AccountType),
|
||||
PartnerRole: this.prepareData(PartnerRole),
|
||||
BusinessRole: this.prepareData(BusinessRole),
|
||||
ProviderRole: this.prepareData(ProviderRole),
|
||||
TokenType: this.prepareData(TokenType),
|
||||
UnitType: this.prepareData(UnitType),
|
||||
GoodPricingModel: this.prepareData(GoodPricingModel),
|
||||
ConsumerRole: this.prepareData(ConsumerRole),
|
||||
PaymentMethodType: this.prepareData(PaymentMethodType, 'PaymentMethodType'),
|
||||
GoldKarat: this.prepareData(GoldKarat, 'GoldKarat'),
|
||||
UserStatus: this.prepareData(UserStatus, 'UserStatus'),
|
||||
AccountRole: this.prepareData(AccountRole, 'AccountRole'),
|
||||
AccountStatus: this.prepareData(AccountStatus, 'AccountStatus'),
|
||||
POSStatus: this.prepareData(POSStatus, 'POSStatus'),
|
||||
POSRole: this.prepareData(POSRole, 'POSRole'),
|
||||
LicenseType: this.prepareData(LicenseType, 'LicenseType'),
|
||||
LicenseStatus: this.prepareData(LicenseStatus, 'LicenseStatus'),
|
||||
POSType: this.prepareData(POSType, 'POSType'),
|
||||
UserType: this.prepareData(UserType, 'UserType'),
|
||||
AccountType: this.prepareData(AccountType, 'AccountType'),
|
||||
PartnerRole: this.prepareData(PartnerRole, 'PartnerRole'),
|
||||
BusinessRole: this.prepareData(BusinessRole, 'BusinessRole'),
|
||||
ProviderRole: this.prepareData(ProviderRole, 'ProviderRole'),
|
||||
ProviderStatus: this.prepareData(ProviderStatus, 'ProviderStatus'),
|
||||
TokenType: this.prepareData(TokenType, 'TokenType'),
|
||||
UnitType: this.prepareData(UnitType, 'UnitType'),
|
||||
GoodPricingModel: this.prepareData(GoodPricingModel, 'GoodPricingModel'),
|
||||
ConsumerRole: this.prepareData(ConsumerRole, 'ConsumerRole'),
|
||||
ConsumerStatus: this.prepareData(ConsumerStatus, 'ConsumerStatus'),
|
||||
ConsumerType: this.prepareData(ConsumerType, 'ConsumerType'),
|
||||
PartnerStatus: this.prepareData(PartnerStatus, 'PartnerStatus'),
|
||||
PartnerFiscalSwitchType: this.prepareData(
|
||||
PartnerFiscalSwitchType,
|
||||
'PartnerFiscalSwitchType',
|
||||
),
|
||||
ApplicationPlatform: this.prepareData(ApplicationPlatform, 'ApplicationPlatform'),
|
||||
ApplicationReleaseType: this.prepareData(
|
||||
ApplicationReleaseType,
|
||||
'ApplicationReleaseType',
|
||||
),
|
||||
ApplicationPublisher: this.prepareData(
|
||||
ApplicationPublisher,
|
||||
'ApplicationPublisher',
|
||||
),
|
||||
CustomerType: this.prepareData(CustomerType, 'CustomerType'),
|
||||
FiscalResponseStatus: this.prepareData(
|
||||
FiscalResponseStatus,
|
||||
'FiscalResponseStatus',
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { checkAndDecodeJwtToken } from '@/common/utils/jwt-user.util'
|
||||
import { POSStatus } from '@/generated/prisma/enums'
|
||||
import { PosSelect } from '@/generated/prisma/models'
|
||||
import { ConsumerRole, POSStatus } from '@/generated/prisma/enums'
|
||||
import { PosSelect, PosWhereInput } from '@/generated/prisma/models'
|
||||
import { PrismaService } from '@/prisma/prisma.service'
|
||||
import {
|
||||
ForbiddenException,
|
||||
@@ -55,8 +55,7 @@ export class PosMiddleware implements NestMiddleware {
|
||||
let pos!: any
|
||||
|
||||
if (!posId || typeof posId !== 'string') {
|
||||
const poses = await tx.pos.findMany({
|
||||
where: {
|
||||
const defaultWhere: PosWhereInput = {
|
||||
complex: {
|
||||
business_activity: {
|
||||
consumer: {
|
||||
@@ -68,7 +67,14 @@ export class PosMiddleware implements NestMiddleware {
|
||||
},
|
||||
},
|
||||
},
|
||||
account_id,
|
||||
}
|
||||
|
||||
if (role === ConsumerRole.OPERATOR) {
|
||||
defaultWhere.account_id = account_id
|
||||
}
|
||||
const poses = await tx.pos.findMany({
|
||||
where: {
|
||||
...defaultWhere,
|
||||
},
|
||||
select: posSelect,
|
||||
})
|
||||
@@ -137,7 +143,7 @@ export class PosMiddleware implements NestMiddleware {
|
||||
req.posData = {
|
||||
pos_id: posId,
|
||||
complex_id: pos.complex.id,
|
||||
business_id: pos.complex.id,
|
||||
business_id: pos.complex.business_activity.id,
|
||||
guild_id: pos.complex.business_activity.guild_id,
|
||||
consumer_account_id: account_id,
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ export class PosService {
|
||||
id: true,
|
||||
name: true,
|
||||
code: true,
|
||||
logo_url: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,18 +1,110 @@
|
||||
import { ApiProperty, PartialType } from '@nestjs/swagger'
|
||||
import { Type } from 'class-transformer'
|
||||
import {
|
||||
ArrayMinSize,
|
||||
IsBoolean,
|
||||
IsDate,
|
||||
IsDateString,
|
||||
IsEnum,
|
||||
IsNotEmpty,
|
||||
IsNumber,
|
||||
IsObject,
|
||||
IsOptional,
|
||||
IsString,
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from 'class-validator'
|
||||
import type { CustomerIndividual, CustomerLegal } from 'generated/prisma/client'
|
||||
import { CustomerType } from 'generated/prisma/enums'
|
||||
import { CreateSalesInvoiceItemDto } from '../sales-invoice-items/dto/create-sales-invoice-item.dto'
|
||||
|
||||
export class CreateTerminalPayment {
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
amount?: number
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ required: true })
|
||||
terminalId: string
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ required: true })
|
||||
stan: string
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@ApiProperty({ required: true })
|
||||
rrn: string
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@ApiProperty({ required: true })
|
||||
response_code?: string
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@ApiProperty({ required: true })
|
||||
customer_card_no?: string
|
||||
|
||||
@Type(() => Date)
|
||||
@IsDate()
|
||||
@ApiProperty({ required: true })
|
||||
transaction_date_time: Date
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiProperty({ required: false })
|
||||
description?: string
|
||||
}
|
||||
|
||||
export class CreateSalesInvoicePaymentsDto {
|
||||
@IsOptional()
|
||||
@ValidateNested()
|
||||
@Type(() => CreateTerminalPayment)
|
||||
@ApiProperty({ required: false, type: () => CreateTerminalPayment })
|
||||
terminals?: CreateTerminalPayment
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
cash?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
set_off?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
card?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
bank?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
check?: number
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty({ required: false, default: 0 })
|
||||
other?: number
|
||||
}
|
||||
|
||||
export class CreateSalesInvoiceDto {
|
||||
// @TODO: totalAmount must calculated instead of get from api
|
||||
@IsNumber()
|
||||
@@ -28,11 +120,9 @@ export class CreateSalesInvoiceDto {
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsObject()
|
||||
payments: {
|
||||
terminal: number
|
||||
cash: number
|
||||
set_off: number
|
||||
}
|
||||
@ValidateNested()
|
||||
@Type(() => CreateSalesInvoicePaymentsDto)
|
||||
payments: CreateSalesInvoicePaymentsDto
|
||||
|
||||
@ApiProperty()
|
||||
@ArrayMinSize(1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { SalesInvoiceTaxSwitchService } from '../../consumer/saleInvoices/tax/sales-invoice-tax-switch.service'
|
||||
import { SalesInvoiceTaxService } from '../../consumer/saleInvoices/tax/sales-invoice-tax.service'
|
||||
import { NamaTaxSwitchAdapter } from '../../consumer/saleInvoices/tax/switch/nama-tax-switch.adapter'
|
||||
import { SalesInvoiceFiscalSwitchService } from '../../consumer/saleInvoices/fiscal/sales-invoice-fiscal-switch.service'
|
||||
import { SalesInvoiceFiscalService } from '../../consumer/saleInvoices/fiscal/sales-invoice-fiscal.service'
|
||||
import { NamaTaxSwitchAdapter } from '../../consumer/saleInvoices/fiscal/switch/nama/nama-fiscal-switch.adapter'
|
||||
import { SalesInvoicesController } from './sales-invoices.controller'
|
||||
import { SalesInvoicesService } from './sales-invoices.service'
|
||||
|
||||
@@ -9,8 +9,8 @@ import { SalesInvoicesService } from './sales-invoices.service'
|
||||
controllers: [SalesInvoicesController],
|
||||
providers: [
|
||||
SalesInvoicesService,
|
||||
SalesInvoiceTaxService,
|
||||
SalesInvoiceTaxSwitchService,
|
||||
SalesInvoiceFiscalService,
|
||||
SalesInvoiceFiscalSwitchService,
|
||||
NamaTaxSwitchAdapter,
|
||||
],
|
||||
})
|
||||
|
||||
@@ -3,8 +3,9 @@ import { PrismaService } from '@/prisma/prisma.service'
|
||||
import { BadRequestException, Injectable } from '@nestjs/common'
|
||||
import { ResponseMapper } from 'common/response/response-mapper'
|
||||
import type { CustomerIndividual, CustomerLegal } from 'generated/prisma/client'
|
||||
import { Prisma } from 'generated/prisma/client'
|
||||
import { CustomerType, PaymentMethodType } from 'generated/prisma/enums'
|
||||
import { SalesInvoiceTaxService } from '../../consumer/saleInvoices/tax/sales-invoice-tax.service'
|
||||
import { SalesInvoiceFiscalService } from '../../consumer/saleInvoices/fiscal/sales-invoice-fiscal.service'
|
||||
import { CreateSalesInvoiceDto } from './dto/create-sales-invoice.dto'
|
||||
|
||||
// Define type guard for CustomerIndividual
|
||||
@@ -25,11 +26,28 @@ function isCustomerLegal(customer: any): customer is CustomerLegal {
|
||||
)
|
||||
}
|
||||
|
||||
interface TerminalPaymentInfo {
|
||||
terminalId: string
|
||||
stan: string
|
||||
rrn: string
|
||||
transactionDateTime: string | Date
|
||||
customerCardNO?: string
|
||||
description?: string
|
||||
amount?: number
|
||||
}
|
||||
|
||||
interface NormalizedPayment {
|
||||
method: PaymentMethodType
|
||||
amount: number
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SalesInvoicesService {
|
||||
private readonly createInvoiceRetries = 3
|
||||
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
private salesInvoiceTaxService: SalesInvoiceTaxService,
|
||||
private salesInvoiceTaxService: SalesInvoiceFiscalService,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
@@ -65,44 +83,183 @@ export class SalesInvoicesService {
|
||||
// }
|
||||
|
||||
async create(data: CreateSalesInvoiceDto, posInfo: IPosPayload) {
|
||||
data.invoice_date = new Date(data.invoice_date).toISOString() as any
|
||||
|
||||
const { business_id, pos_id, consumer_account_id } = posInfo
|
||||
const normalizedInvoiceDate = this.normalizeInvoiceDate(data.invoice_date)
|
||||
const { payments, terminalInfo } = this.buildPaymentsData(
|
||||
data.payments,
|
||||
data.total_amount,
|
||||
)
|
||||
|
||||
for (let attempt = 1; attempt <= this.createInvoiceRetries; attempt++) {
|
||||
try {
|
||||
const salesInvoice = await this.prisma.$transaction(async $tx => {
|
||||
const payments = Object.entries(data.payments)
|
||||
.filter(([_, value]) => value > 0 && PaymentMethodType[_.toUpperCase()])
|
||||
.map(([key, value]) => {
|
||||
return {
|
||||
amount: value,
|
||||
payment_method: key.toLocaleUpperCase() as PaymentMethodType,
|
||||
paid_at: data.invoice_date,
|
||||
}
|
||||
const invoiceNumber = await this.getNextInvoiceNumber($tx, business_id)
|
||||
const newCustomerId = await this.resolveCustomerId($tx, data, business_id)
|
||||
const goodsById = await this.getGoodsById($tx, data)
|
||||
const salesInvoiceData = this.buildSalesInvoiceData({
|
||||
data,
|
||||
normalizedInvoiceDate,
|
||||
invoiceNumber,
|
||||
consumer_account_id,
|
||||
pos_id,
|
||||
goodsById,
|
||||
customerId: newCustomerId,
|
||||
})
|
||||
|
||||
const totalPayments = payments.reduce((sum, payment) => sum + payment.amount, 0)
|
||||
const salesInvoice = await $tx.salesInvoice.create({
|
||||
data: salesInvoiceData,
|
||||
})
|
||||
|
||||
if (totalPayments !== data.total_amount) {
|
||||
throw new Error('مبلغ پرداختی باید برابر با مبلغ کل فاکتور باشد.')
|
||||
await this.createPayments(
|
||||
$tx,
|
||||
salesInvoice.id,
|
||||
payments,
|
||||
terminalInfo,
|
||||
normalizedInvoiceDate,
|
||||
)
|
||||
|
||||
return salesInvoice
|
||||
})
|
||||
|
||||
if (data.send_to_tax) {
|
||||
await this.salesInvoiceTaxService.send(salesInvoice.id, pos_id)
|
||||
}
|
||||
|
||||
const { customer_id, customer_type, customer, ...invoiceData } = data
|
||||
let newCustomerId: string | null = customer_id || null
|
||||
if (customer_id) {
|
||||
} else if (
|
||||
customer_type === CustomerType.INDIVIDUAL &&
|
||||
customer?.customer_individual
|
||||
return ResponseMapper.create(salesInvoice)
|
||||
} catch (error) {
|
||||
if (
|
||||
this.isRetryableInvoiceConflict(error) &&
|
||||
attempt < this.createInvoiceRetries
|
||||
) {
|
||||
const customer_individual = customer.customer_individual
|
||||
const customerIndividual = await $tx.customerIndividual.upsert({
|
||||
continue
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
throw new BadRequestException('ایجاد فاکتور با خطا مواجه شد.')
|
||||
}
|
||||
|
||||
private isRetryableInvoiceConflict(error: unknown) {
|
||||
if (!(error instanceof Prisma.PrismaClientKnownRequestError)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (error.code !== 'P2002') {
|
||||
return false
|
||||
}
|
||||
|
||||
const target = (error.meta?.target as string[]) || []
|
||||
return (
|
||||
target.includes('invoice_number') ||
|
||||
target.includes('sales_invoices_invoice_number_pos_id_key')
|
||||
)
|
||||
}
|
||||
|
||||
private normalizeInvoiceDate(invoiceDate: Date | string) {
|
||||
return new Date(invoiceDate).toISOString() as any
|
||||
}
|
||||
|
||||
private buildPaymentsData(
|
||||
paymentsData: CreateSalesInvoiceDto['payments'],
|
||||
totalAmount: number,
|
||||
) {
|
||||
const paymentMethodMap: Record<string, PaymentMethodType> = {
|
||||
cash: PaymentMethodType.CASH,
|
||||
set_off: PaymentMethodType.SET_OFF,
|
||||
card: PaymentMethodType.CARD,
|
||||
bank: PaymentMethodType.BANK,
|
||||
check: PaymentMethodType.CHECK,
|
||||
other: PaymentMethodType.OTHER,
|
||||
terminal: PaymentMethodType.TERMINAL,
|
||||
}
|
||||
|
||||
const rawPayments = (paymentsData || {}) as Record<string, unknown>
|
||||
const terminalInfo = rawPayments.terminals as TerminalPaymentInfo | undefined
|
||||
|
||||
const payments: NormalizedPayment[] = Object.entries(rawPayments)
|
||||
.filter(([key]) => key !== 'terminals')
|
||||
.map(([key, value]) => ({
|
||||
method: paymentMethodMap[key.toLowerCase()],
|
||||
amount: typeof value === 'number' ? value : Number(value || 0),
|
||||
}))
|
||||
.filter(payment => payment.method && payment.amount > 0) as NormalizedPayment[]
|
||||
|
||||
const hasTerminalPayment = payments.some(
|
||||
payment => payment.method === PaymentMethodType.TERMINAL,
|
||||
)
|
||||
const nonTerminalTotal = payments
|
||||
.filter(payment => payment.method !== PaymentMethodType.TERMINAL)
|
||||
.reduce((sum, payment) => sum + payment.amount, 0)
|
||||
|
||||
if (!hasTerminalPayment && terminalInfo) {
|
||||
const terminalAmount =
|
||||
typeof terminalInfo.amount === 'number'
|
||||
? terminalInfo.amount
|
||||
: Math.max(0, Number(totalAmount) - nonTerminalTotal)
|
||||
|
||||
if (terminalAmount > 0) {
|
||||
payments.push({
|
||||
method: PaymentMethodType.TERMINAL,
|
||||
amount: terminalAmount,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.validatePayments(payments, totalAmount, terminalInfo)
|
||||
|
||||
return {
|
||||
payments,
|
||||
terminalInfo,
|
||||
}
|
||||
}
|
||||
|
||||
private validatePayments(
|
||||
payments: NormalizedPayment[],
|
||||
totalAmount: number,
|
||||
terminalInfo?: TerminalPaymentInfo,
|
||||
) {
|
||||
const totalPayments = payments.reduce((sum, payment) => sum + payment.amount, 0)
|
||||
const roundedTotalPayments = Number(totalPayments.toFixed(2))
|
||||
const roundedTotalAmount = Number(Number(totalAmount).toFixed(2))
|
||||
|
||||
if (roundedTotalPayments !== roundedTotalAmount) {
|
||||
throw new BadRequestException('مبلغ پرداختی باید برابر با مبلغ کل فاکتور باشد.')
|
||||
}
|
||||
|
||||
const terminalPayments = payments.filter(
|
||||
payment => payment.method === PaymentMethodType.TERMINAL,
|
||||
)
|
||||
|
||||
if (terminalPayments.length > 0 && !terminalInfo) {
|
||||
throw new BadRequestException('برای پرداخت ترمینال اطلاعات ترمینال الزامی است.')
|
||||
}
|
||||
}
|
||||
|
||||
private async resolveCustomerId(
|
||||
tx: Prisma.TransactionClient,
|
||||
data: CreateSalesInvoiceDto,
|
||||
businessId: string,
|
||||
) {
|
||||
if (data.customer_id) {
|
||||
return data.customer_id
|
||||
}
|
||||
|
||||
if (
|
||||
data.customer_type === CustomerType.INDIVIDUAL &&
|
||||
data.customer?.customer_individual
|
||||
) {
|
||||
const { national_id, mobile_number, ...rest } = data.customer.customer_individual
|
||||
|
||||
const customerIndividual = await tx.customerIndividual.upsert({
|
||||
where: {
|
||||
business_activity_id_national_id: {
|
||||
business_activity_id: business_id,
|
||||
national_id: customer_individual.national_id,
|
||||
business_activity_id: businessId,
|
||||
national_id: data.customer.customer_individual.national_id,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
...customer_individual,
|
||||
...data.customer.customer_individual,
|
||||
customer: {
|
||||
create: {
|
||||
type: CustomerType.INDIVIDUAL,
|
||||
@@ -110,11 +267,11 @@ export class SalesInvoicesService {
|
||||
},
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: business_id,
|
||||
id: businessId,
|
||||
},
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
update: { ...rest },
|
||||
select: {
|
||||
customer_id: true,
|
||||
},
|
||||
@@ -123,19 +280,21 @@ export class SalesInvoicesService {
|
||||
if (!customerIndividual) {
|
||||
throw new BadRequestException('متاسفانه مشکلی در اطلاعات مشتری وجود دارد.')
|
||||
}
|
||||
newCustomerId = customerIndividual.customer_id
|
||||
} else if (data.customer_type === CustomerType.LEGAL && customer?.customer_legal) {
|
||||
const customer_legal = customer.customer_legal
|
||||
|
||||
const customerLegal = await $tx.customerLegal.upsert({
|
||||
return customerIndividual.customer_id
|
||||
}
|
||||
|
||||
if (data.customer_type === CustomerType.LEGAL && data.customer?.customer_legal) {
|
||||
const { registration_number, ...rest } = data.customer.customer_legal
|
||||
const customerLegal = await tx.customerLegal.upsert({
|
||||
where: {
|
||||
business_activity_id_economic_code: {
|
||||
business_activity_id: business_id,
|
||||
economic_code: customer_legal.economic_code,
|
||||
business_activity_id: businessId,
|
||||
economic_code: data.customer.customer_legal.economic_code,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
...customer_legal,
|
||||
...data.customer.customer_legal,
|
||||
customer: {
|
||||
create: {
|
||||
type: CustomerType.LEGAL,
|
||||
@@ -143,11 +302,13 @@ export class SalesInvoicesService {
|
||||
},
|
||||
business_activity: {
|
||||
connect: {
|
||||
id: business_id,
|
||||
id: businessId,
|
||||
},
|
||||
},
|
||||
},
|
||||
update: {},
|
||||
update: {
|
||||
...rest,
|
||||
},
|
||||
select: {
|
||||
customer_id: true,
|
||||
},
|
||||
@@ -156,16 +317,20 @@ export class SalesInvoicesService {
|
||||
if (!customerLegal) {
|
||||
throw new BadRequestException('متاسفانه مشکلی در اطلاعات مشتری وجود دارد.')
|
||||
}
|
||||
newCustomerId = customerLegal.customer_id
|
||||
} else if (data.customer_type === CustomerType.UNKNOWN) {
|
||||
|
||||
return customerLegal.customer_id
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private async getGoodsById(tx: Prisma.TransactionClient, data: CreateSalesInvoiceDto) {
|
||||
const itemGoodIds = data.items
|
||||
.map(item => item.good_id)
|
||||
.filter((goodId): goodId is string => Boolean(goodId))
|
||||
|
||||
const goods = itemGoodIds.length
|
||||
? await $tx.good.findMany({
|
||||
? await tx.good.findMany({
|
||||
where: {
|
||||
id: {
|
||||
in: itemGoodIds,
|
||||
@@ -191,13 +356,35 @@ export class SalesInvoicesService {
|
||||
})
|
||||
: []
|
||||
|
||||
const goodsById = new Map(goods.map(good => [good.id, good]))
|
||||
return new Map(goods.map(good => [good.id, good]))
|
||||
}
|
||||
|
||||
private buildSalesInvoiceData(params: {
|
||||
data: CreateSalesInvoiceDto
|
||||
normalizedInvoiceDate: Date
|
||||
invoiceNumber: number
|
||||
consumer_account_id: string
|
||||
pos_id: string
|
||||
goodsById: Map<string, any>
|
||||
customerId: string | null
|
||||
}) {
|
||||
const {
|
||||
data,
|
||||
normalizedInvoiceDate,
|
||||
invoiceNumber,
|
||||
consumer_account_id,
|
||||
pos_id,
|
||||
goodsById,
|
||||
customerId,
|
||||
} = params
|
||||
const { customer_id, customer_type, customer, payments, ...invoiceData } = data
|
||||
|
||||
const salesInvoiceData: any = {
|
||||
...invoiceData,
|
||||
invoice_date: normalizedInvoiceDate,
|
||||
invoice_number: invoiceNumber,
|
||||
total_amount: data.total_amount,
|
||||
code: 'INV-' + Date.now(),
|
||||
|
||||
items: {
|
||||
createMany: {
|
||||
data: data.items.map(item => ({
|
||||
@@ -205,9 +392,7 @@ export class SalesInvoicesService {
|
||||
quantity: item.quantity,
|
||||
unit_price: item.unit_price,
|
||||
total_amount: item.total_amount,
|
||||
payload: item.payload
|
||||
? JSON.parse(JSON.stringify(item.payload))
|
||||
: undefined,
|
||||
payload: item.payload ? JSON.parse(JSON.stringify(item.payload)) : undefined,
|
||||
good_snapshot: item.good_id
|
||||
? JSON.parse(
|
||||
JSON.stringify({
|
||||
@@ -216,21 +401,10 @@ export class SalesInvoicesService {
|
||||
)
|
||||
: undefined,
|
||||
unit_type: item.unit_type,
|
||||
// pricing_model: item.pricingModel,
|
||||
})),
|
||||
},
|
||||
},
|
||||
unknown_customer: {},
|
||||
payments: {
|
||||
createMany: {
|
||||
data: payments,
|
||||
},
|
||||
},
|
||||
// customer: {
|
||||
// connect: {
|
||||
// id: newCustomerId || undefined,
|
||||
// },
|
||||
// },
|
||||
consumer_account: {
|
||||
connect: {
|
||||
id: consumer_account_id,
|
||||
@@ -243,24 +417,70 @@ export class SalesInvoicesService {
|
||||
},
|
||||
}
|
||||
|
||||
if (newCustomerId) {
|
||||
if (customerId) {
|
||||
salesInvoiceData.customer = {
|
||||
connect: {
|
||||
id: newCustomerId || undefined,
|
||||
id: customerId,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const salesInvoice = await $tx.salesInvoice.create({
|
||||
data: salesInvoiceData,
|
||||
})
|
||||
|
||||
return salesInvoice
|
||||
})
|
||||
if (data.send_to_tax) {
|
||||
await this.salesInvoiceTaxService.send(salesInvoice.id, pos_id)
|
||||
return salesInvoiceData
|
||||
}
|
||||
|
||||
return ResponseMapper.create(salesInvoice)
|
||||
private async getNextInvoiceNumber(tx: Prisma.TransactionClient, businessId: string) {
|
||||
const latestInvoice = await tx.salesInvoice.findFirst({
|
||||
where: {
|
||||
pos: {
|
||||
complex: {
|
||||
business_activity_id: businessId,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
invoice_number: 'desc',
|
||||
},
|
||||
select: {
|
||||
invoice_number: true,
|
||||
},
|
||||
})
|
||||
|
||||
return (latestInvoice?.invoice_number || 0) + 1
|
||||
}
|
||||
|
||||
private async createPayments(
|
||||
tx: Prisma.TransactionClient,
|
||||
invoiceId: string,
|
||||
payments: NormalizedPayment[],
|
||||
terminalInfo: TerminalPaymentInfo | undefined,
|
||||
paidAt: Date,
|
||||
) {
|
||||
for (const payment of payments) {
|
||||
if (payment.amount <= 0) {
|
||||
continue
|
||||
}
|
||||
const createdPayment = await tx.salesInvoicePayment.create({
|
||||
data: {
|
||||
invoice_id: invoiceId,
|
||||
amount: payment.amount,
|
||||
payment_method: payment.method,
|
||||
paid_at: paidAt,
|
||||
},
|
||||
})
|
||||
|
||||
if (payment.method === PaymentMethodType.TERMINAL && terminalInfo) {
|
||||
await tx.salesInvoicePaymentTerminalInfo.create({
|
||||
data: {
|
||||
payment_id: createdPayment.id,
|
||||
terminal_id: terminalInfo.terminalId,
|
||||
stan: terminalInfo.stan,
|
||||
rrn: terminalInfo.rrn,
|
||||
transaction_date_time: new Date(terminalInfo.transactionDateTime),
|
||||
customer_card_no: terminalInfo.customerCardNO || null,
|
||||
description: terminalInfo.description || null,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user