Files
psp_api/src/modules/tspProviders/dto/original.dto.ts
T

178 lines
3.6 KiB
TypeScript
Raw Normal View History

import {
InvoiceSettlementType,
InvoiceTemplateType,
TspProviderType,
} from '@/generated/prisma/enums'
import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import {
IsArray,
IsDateString,
IsEnum,
IsNumber,
IsObject,
IsOptional,
IsString,
Min,
ValidateNested
} from 'class-validator'
2026-05-27 22:44:01 +03:30
import {
CustomerInfoDto,
goldTypePayload,
PaymentInfoDto,
ProviderCommonResponse,
} from './common.dto'
export class TspProviderOriginalItemPayloadDto {
@ApiProperty({ required: true })
@IsString()
sku: string
@ApiProperty({ required: true })
@IsString()
sku_vat: string
@ApiProperty({ required: true })
@IsNumber()
unit_price: number
// @ApiProperty()
// @IsString()
// invoice_item_id: string
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty()
@IsNumber()
@Min(0)
total_amount: number
@ApiProperty()
@IsNumber()
@Min(0)
discount_amount: number
@ApiProperty()
@IsNumber()
@Min(0)
tax_amount: number
@ApiProperty({ required: true })
@IsString()
measure_unit: string
@ApiProperty({ 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: goldTypePayload })
@IsOptional()
@IsObject()
gold_type_payload?: goldTypePayload
// @ApiProperty({ required: false, nullable: true, type: Object })
// @IsOptional()
// @IsObject()
// payload?: unknown
}
export class TspProviderOriginalSendPayloadDto {
@ApiProperty({ required: true, nullable: true })
@IsString()
id: string
@ApiProperty({ required: true, nullable: true })
@IsNumber()
invoice_number: number
@ApiProperty({ required: true, nullable: true })
@IsDateString()
invoice_date: Date
@ApiProperty({ required: true, nullable: true })
@IsString()
economic_code: string
@ApiProperty({ required: true, nullable: true })
@IsString()
fiscal_id: string
@ApiProperty({ required: true, enum: TspProviderType })
@IsEnum(TspProviderType)
tsp_provider: TspProviderType
@ApiProperty({ required: true, enum: InvoiceTemplateType })
@IsEnum(InvoiceTemplateType)
template: InvoiceTemplateType
@ApiProperty({ required: true })
@IsString()
token: string
@ApiProperty({ required: true, enum: InvoiceSettlementType })
@IsEnum(InvoiceSettlementType)
settlement_type: InvoiceSettlementType
@ApiProperty()
@IsNumber()
@Min(0)
total_amount: number
@ApiProperty()
@IsNumber()
@Min(0)
discount_amount: number
@ApiProperty()
@IsNumber()
@Min(0)
tax_amount: number
@ApiProperty({ type: [TspProviderOriginalItemPayloadDto] })
@IsArray()
@ValidateNested({ each: true })
@Type(() => TspProviderOriginalItemPayloadDto)
items: TspProviderOriginalItemPayloadDto[]
@ApiProperty({ required: false })
@Type(() => CustomerInfoDto)
@ValidateNested({ each: true })
customer?: CustomerInfoDto
@ApiProperty({ required: true, type: [PaymentInfoDto] })
@IsArray()
@ValidateNested({ each: true })
@Type(() => PaymentInfoDto)
payments: PaymentInfoDto[]
}
2026-05-27 22:44:01 +03:30
export class TspProviderOriginalResponseDto extends ProviderCommonResponse {
@ApiProperty()
@IsString()
invoice_id: string
@ApiProperty({ required: false, nullable: true })
@IsOptional()
@IsString()
tax_id?: string | null
@ApiProperty({
required: true,
nullable: true,
type: TspProviderOriginalSendPayloadDto,
})
@IsOptional()
@IsObject()
@ValidateNested({ each: true })
@Type(() => TspProviderOriginalSendPayloadDto)
provider_request_payload: TspProviderOriginalSendPayloadDto
}