2026-05-01 19:43:59 +03:30
|
|
|
import {
|
|
|
|
|
CustomerType,
|
|
|
|
|
FiscalInvoiceCustomerType,
|
|
|
|
|
FiscalRequestType,
|
|
|
|
|
PartnerFiscalSwitchType,
|
|
|
|
|
} from '@/generated/prisma/enums'
|
2026-04-27 22:11:05 +03:30
|
|
|
import { ApiProperty } from '@nestjs/swagger'
|
|
|
|
|
import { Type } from 'class-transformer'
|
|
|
|
|
import {
|
|
|
|
|
IsArray,
|
|
|
|
|
IsDateString,
|
|
|
|
|
IsEnum,
|
|
|
|
|
IsNumber,
|
|
|
|
|
IsObject,
|
|
|
|
|
IsOptional,
|
|
|
|
|
IsString,
|
|
|
|
|
ValidateNested,
|
|
|
|
|
} from 'class-validator'
|
|
|
|
|
|
|
|
|
|
export enum TaxSendStatus {
|
|
|
|
|
SENT = 'SENT',
|
|
|
|
|
FAILED = 'FAILED',
|
|
|
|
|
PENDING = 'PENDING',
|
|
|
|
|
}
|
|
|
|
|
|
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-04-27 22:11:05 +03:30
|
|
|
export class TaxSwitchSendItemPayloadDto {
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TaxSwitchSendPayloadDto {
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true, enum: FiscalRequestType })
|
|
|
|
|
@IsEnum(FiscalRequestType)
|
|
|
|
|
type: FiscalRequestType
|
2026-04-27 22:11:05 +03:30
|
|
|
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true, enum: FiscalInvoiceCustomerType })
|
|
|
|
|
@IsEnum(FiscalInvoiceCustomerType)
|
|
|
|
|
customer_type: FiscalInvoiceCustomerType
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ type: [TaxSwitchSendItemPayloadDto] })
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => TaxSwitchSendItemPayloadDto)
|
|
|
|
|
items: TaxSwitchSendItemPayloadDto[]
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false })
|
|
|
|
|
@Type(() => CustomerInfoDto)
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
customer?: CustomerInfoDto
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: true, nullable: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsString()
|
|
|
|
|
invoice_code: string
|
|
|
|
|
|
2026-05-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true, nullable: true })
|
2026-04-27 22:11:05 +03:30
|
|
|
@IsOptional()
|
|
|
|
|
@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-01 19:43:59 +03:30
|
|
|
@ApiProperty({ required: true, enum: PartnerFiscalSwitchType })
|
|
|
|
|
@IsEnum(PartnerFiscalSwitchType)
|
|
|
|
|
provider_code: PartnerFiscalSwitchType
|
2026-04-27 22:11:05 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TaxSwitchSendItemResultDto {
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_item_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ enum: TaxSendStatus })
|
|
|
|
|
@IsEnum(TaxSendStatus)
|
|
|
|
|
status: TaxSendStatus
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
tax_id?: 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: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsString()
|
|
|
|
|
error_message?: string | null
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsDateString()
|
|
|
|
|
sent_at?: string | null
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsDateString()
|
|
|
|
|
received_at?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TaxSwitchBulkSendResultDto {
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
invoice_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ type: [TaxSwitchSendItemResultDto] })
|
|
|
|
|
@IsArray()
|
|
|
|
|
@ValidateNested({ each: true })
|
|
|
|
|
@Type(() => TaxSwitchSendItemResultDto)
|
|
|
|
|
items: TaxSwitchSendItemResultDto[]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class TaxSwitchGetResultDto {
|
|
|
|
|
@ApiProperty()
|
|
|
|
|
@IsString()
|
|
|
|
|
tax_id: string
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ enum: TaxSendStatus })
|
|
|
|
|
@IsEnum(TaxSendStatus)
|
|
|
|
|
status: TaxSendStatus
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true, type: Object })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsObject()
|
|
|
|
|
response_payload?: unknown
|
|
|
|
|
|
|
|
|
|
@ApiProperty({ required: false, nullable: true })
|
|
|
|
|
@IsOptional()
|
|
|
|
|
@IsDateString()
|
|
|
|
|
received_at?: string | null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ITaxSwitchAdapter {
|
|
|
|
|
readonly code: string
|
|
|
|
|
send(payload: TaxSwitchSendPayloadDto): Promise<TaxSwitchSendItemResultDto[]>
|
|
|
|
|
sendBulk(payloads: TaxSwitchSendPayloadDto[]): Promise<TaxSwitchBulkSendResultDto[]>
|
|
|
|
|
get(taxId: string): Promise<TaxSwitchGetResultDto>
|
|
|
|
|
}
|