2026-05-07 20:30:24 +03:30
|
|
|
import { TspProviderCustomerType } from '@/common/enums/enums'
|
2026-05-05 22:42:09 +03:30
|
|
|
import {
|
|
|
|
|
SharedCreateSalesInvoiceItemDto,
|
|
|
|
|
SharedCreateSalesInvoicePaymentsDto,
|
|
|
|
|
} from '@/common/services/saleInvoices/sale-invoice-create.dto'
|
2026-05-01 19:43:59 +03:30
|
|
|
import {
|
|
|
|
|
CustomerType,
|
2026-05-03 16:23:17 +03:30
|
|
|
InvoiceTemplateType,
|
|
|
|
|
PaymentMethodType,
|
|
|
|
|
TspProviderRequestType,
|
|
|
|
|
TspProviderResponseStatus,
|
|
|
|
|
TspProviderType,
|
2026-05-01 19:43:59 +03:30
|
|
|
} from '@/generated/prisma/enums'
|
2026-04-27 22:11:05 +03:30
|
|
|
import { ApiProperty } from '@nestjs/swagger'
|
|
|
|
|
import { Type } from 'class-transformer'
|
|
|
|
|
import {
|
2026-05-05 22:42:09 +03:30
|
|
|
ArrayMinSize,
|
2026-04-27 22:11:05 +03:30
|
|
|
IsArray,
|
2026-05-03 16:23:17 +03:30
|
|
|
IsBoolean,
|
2026-04-27 22:11:05 +03:30
|
|
|
IsDateString,
|
|
|
|
|
IsEnum,
|
|
|
|
|
IsNumber,
|
|
|
|
|
IsObject,
|
|
|
|
|
IsOptional,
|
|
|
|
|
IsString,
|
2026-05-03 16:23:17 +03:30
|
|
|
Min,
|
2026-04-27 22:11:05 +03:30
|
|
|
ValidateNested,
|
|
|
|
|
} from 'class-validator'
|
|
|
|
|
|
2026-05-01 19:43:59 +03:30
|
|
|
export class CustomerLegalInfoDto {
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
name: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
economic_code: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class CustomerIndividualInfoDto {
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
first_name: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
last_name: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
national_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
mobile_number: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class CustomerInfoDto {
|
|
|
|
|
@ApiProperty({ required: true, enum: CustomerType })
|
|
|
|
|
@IsEnum(CustomerType)
|
|
|
|
|
type: CustomerType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({})
|
|
|
|
|
@Type(() => CustomerLegalInfoDto)
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
legal_info?: CustomerLegalInfoDto
|
|
|
|
|
|
|
|
|
|
@ApiProperty({})
|
|
|
|
|
@Type(() => CustomerIndividualInfoDto)
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
individual_info?: CustomerIndividualInfoDto
|
|
|
|
|
}
|
2026-05-03 16:23:17 +03:30
|
|
|
|
|
|
|
|
export class PaymentInfoDto {
|
|
|
|
|
@ApiProperty({ required: true, enum: PaymentMethodType })
|
|
|
|
|
@IsEnum(PaymentMethodType)
|
|
|
|
|
payment_method: PaymentMethodType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsNumber({ allowInfinity: false, allowNaN: false })
|
|
|
|
|
@Min(10_000)
|
|
|
|
|
amount: number
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
tracking_code?: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
card_number?: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsDateString()
|
|
|
|
|
paid_at?: Date
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TspProviderSendItemPayloadDto {
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsString()
|
2026-05-01 19:43:59 +03:30
|
|
|
sku: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
sku_vat: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty()
|
2026-05-01 19:43:59 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
discount: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsNumber()
|
2026-05-01 19:43:59 +03:30
|
|
|
unit_price: number
|
|
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_item_id: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsNumber()
|
2026-05-01 19:43:59 +03:30
|
|
|
quantity: number
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsNumber()
|
|
|
|
|
total_amount: number
|
|
|
|
|
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsString()
|
2026-05-01 19:43:59 +03:30
|
|
|
measure_unit: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
good_id?: string | null
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
service_id?: string | null
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
payload?: unknown
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-05 22:42:09 +03:30
|
|
|
export class TspProviderOriginalSendPayloadDto {
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true, enum: TspProviderRequestType })
|
|
|
|
|
@IsEnum(TspProviderRequestType)
|
|
|
|
|
type: TspProviderRequestType
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true, enum: TspProviderCustomerType })
|
|
|
|
|
@IsEnum(TspProviderCustomerType)
|
|
|
|
|
customer_type: TspProviderCustomerType
|
2026-05-01 19:43:59 +03:30
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ type: [TspProviderSendItemPayloadDto] })
|
2026-05-01 19:43:59 +03:30
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
2026-05-03 16:23:17 +03:30
|
|
|
@Type(() => TspProviderSendItemPayloadDto)
|
|
|
|
|
items: TspProviderSendItemPayloadDto[]
|
2026-05-01 19:43:59 +03:30
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@Type(() => CustomerInfoDto)
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
customer?: CustomerInfoDto
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
2026-05-03 16:23:17 +03:30
|
|
|
@IsNumber()
|
|
|
|
|
invoice_number: number
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true, nullable: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsDateString()
|
2026-05-01 19:43:59 +03:30
|
|
|
invoice_date: Date
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_id: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsNumber()
|
|
|
|
|
total_amount: number
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true, enum: TspProviderType })
|
|
|
|
|
@IsEnum(TspProviderType)
|
|
|
|
|
tsp_provider: TspProviderType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
economic_code: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
fiscal_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, type: [PaymentInfoDto] })
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => PaymentInfoDto)
|
|
|
|
|
payments: PaymentInfoDto[]
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, enum: InvoiceTemplateType })
|
|
|
|
|
@IsEnum(InvoiceTemplateType)
|
|
|
|
|
invoice_template: InvoiceTemplateType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
tsp_token: string
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
export class TspProviderSendItemResultDto {
|
2026-04-27 22:11:05 +03:30
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
2026-05-03 16:23:17 +03:30
|
|
|
invoice_id: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ enum: TspProviderResponseStatus })
|
|
|
|
|
@IsEnum(TspProviderResponseStatus)
|
|
|
|
|
status: TspProviderResponseStatus
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
tax_id?: string | null
|
|
|
|
|
|
2026-05-05 22:42:09 +03:30
|
|
|
@ApiProperty({
|
|
|
|
|
required: true,
|
|
|
|
|
nullable: true,
|
|
|
|
|
type: TspProviderOriginalSendPayloadDto,
|
|
|
|
|
})
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
2026-05-05 22:42:09 +03:30
|
|
|
request_payload: Object
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
response_payload?: unknown
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
hasError: boolean
|
|
|
|
|
|
2026-04-27 22:11:05 +03:30
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
2026-05-03 16:23:17 +03:30
|
|
|
message?: string | null
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsDateString()
|
2026-05-03 16:23:17 +03:30
|
|
|
sent_at: string
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsDateString()
|
2026-05-03 16:23:17 +03:30
|
|
|
received_at: string
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
export class TspProviderBulkSendResultDto {
|
2026-04-27 22:11:05 +03:30
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_id: string
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ type: [TspProviderSendItemResultDto] })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
2026-05-03 16:23:17 +03:30
|
|
|
@Type(() => TspProviderSendItemResultDto)
|
|
|
|
|
items: TspProviderSendItemResultDto[]
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-05 22:42:09 +03:30
|
|
|
///////////// GET RELATED DTOs /////////////
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
export class TspProviderGetResultDto {
|
2026-04-27 22:11:05 +03:30
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
tax_id: string
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ enum: TspProviderResponseStatus })
|
|
|
|
|
@IsEnum(TspProviderResponseStatus)
|
|
|
|
|
status: TspProviderResponseStatus
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
hasError: boolean
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
message?: string | null
|
2026-04-27 22:11:05 +03:30
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
response_payload?: unknown
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsDateString()
|
|
|
|
|
sent_at: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsDateString()
|
2026-05-03 16:23:17 +03:30
|
|
|
received_at: string
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|
|
|
|
|
|
2026-05-05 22:42:09 +03:30
|
|
|
///////////// REVOKE RELATED DTOs /////////////
|
|
|
|
|
|
2026-05-04 11:21:49 +03:30
|
|
|
export class TspProviderRevokePayloadDto {
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsNumber()
|
|
|
|
|
invoice_number: number
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, enum: TspProviderType })
|
|
|
|
|
@IsEnum(TspProviderType)
|
|
|
|
|
tsp_provider: TspProviderType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
economic_code: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
fiscal_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
tsp_token: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
2026-05-05 22:42:09 +03:30
|
|
|
last_tax_id: string
|
2026-05-04 11:21:49 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TspProviderRevokeResponseDto {
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
tax_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ enum: TspProviderResponseStatus })
|
|
|
|
|
@IsEnum(TspProviderResponseStatus)
|
|
|
|
|
status: TspProviderResponseStatus
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsBoolean()
|
|
|
|
|
hasError: boolean
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
message?: string | null
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
request_payload?: unknown
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
response_payload?: unknown
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsDateString()
|
|
|
|
|
sent_at: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsDateString()
|
|
|
|
|
received_at: string
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-05 22:42:09 +03:30
|
|
|
///////////// CORRECTION RELATED DTOs /////////////
|
|
|
|
|
export class TspProviderCorrectionInvoicePayloadDto {
|
|
|
|
|
@ApiProperty({ type: [SharedCreateSalesInvoiceItemDto] })
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => SharedCreateSalesInvoiceItemDto)
|
|
|
|
|
@ArrayMinSize(1)
|
|
|
|
|
items: SharedCreateSalesInvoiceItemDto[]
|
|
|
|
|
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsNumber()
|
|
|
|
|
total_amount: number
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, type: SharedCreateSalesInvoicePaymentsDto })
|
|
|
|
|
@IsObject()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => SharedCreateSalesInvoicePaymentsDto)
|
|
|
|
|
payments: SharedCreateSalesInvoicePaymentsDto
|
|
|
|
|
}
|
|
|
|
|
export class TspProviderCorrectionSendPayloadDto extends TspProviderOriginalSendPayloadDto {
|
|
|
|
|
@ApiProperty({ required: true })
|
|
|
|
|
@IsString()
|
|
|
|
|
last_tax_id: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TspProviderCorrectionSendResponseDto {}
|
|
|
|
|
|
|
|
|
|
export class TspProviderActionResponseDto {
|
|
|
|
|
@IsObject()
|
|
|
|
|
invoice: object
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
message: string
|
|
|
|
|
|
|
|
|
|
@IsEnum(TspProviderResponseStatus)
|
|
|
|
|
status: TspProviderResponseStatus
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-03 16:23:17 +03:30
|
|
|
export interface IProviderSwitchAdapter {
|
2026-04-27 22:11:05 +03:30
|
|
|
readonly code: string
|
2026-05-05 22:42:09 +03:30
|
|
|
originalSend(
|
|
|
|
|
payload: TspProviderOriginalSendPayloadDto,
|
|
|
|
|
): Promise<TspProviderSendItemResultDto>
|
|
|
|
|
sendBulk(
|
|
|
|
|
payloads: TspProviderOriginalSendPayloadDto[],
|
|
|
|
|
): Promise<TspProviderBulkSendResultDto[]>
|
|
|
|
|
correctionSend(
|
|
|
|
|
payload: TspProviderCorrectionSendPayloadDto,
|
|
|
|
|
): Promise<TspProviderCorrectionSendResponseDto>
|
2026-05-03 16:23:17 +03:30
|
|
|
get(invoiceId: string, tsp_token: string): Promise<TspProviderGetResultDto>
|
2026-05-04 11:21:49 +03:30
|
|
|
revoke(payload: TspProviderRevokePayloadDto): Promise<TspProviderRevokeResponseDto>
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|