import { BaseStatusDto } from 'src/core/modules/infrastructure/dto/base-status.dto'; import { ApiProperty } from '@nestjs/swagger'; import { IsArray, IsNumber, IsObject, IsString, ValidateIf, } from 'class-validator'; import { SeasonPeriodEntity } from 'src/modules/season-related/season-period/domain/entities/season-period.entity'; import { TransactionItemEntity } from 'src/modules/transaction/transaction/domain/entities/transaction-item.entity'; import { TransactionPaymentType, TransactionUserType, } from 'src/modules/transaction/transaction/constants'; export class TransactionDto extends BaseStatusDto { @ApiProperty({ type: Object, required: false, example: { id: 'uuid', season_type: { id: 'uuid', name: 'high season', }, }, }) @IsObject() @ValidateIf((body) => body.season_period) season_period: SeasonPeriodEntity; @ApiProperty({ type: String, required: true, example: TransactionUserType.GROUP, }) @IsString() customer_type: TransactionUserType; @ApiProperty({ type: String, required: true, example: 'Andika', }) @IsString() customer_name: string; @ApiProperty({ type: String, required: false, example: '0823...', }) @ValidateIf((body) => body.customer_phone) customer_phone: string; @ApiProperty({ type: Date, required: true, example: '2024-01-01', }) booking_date: Date; @ApiProperty({ type: String, required: false, example: TransactionPaymentType.MIDTRANS, }) payment_type: TransactionPaymentType; @ApiProperty({ type: Number, required: true, example: 7000000, }) @IsNumber() payment_sub_total: number; @ApiProperty({ type: Number, required: true, example: 3500000, }) @IsNumber() payment_total: number; @ApiProperty({ type: [Object], required: true, example: [ { item: { id: '68aa12f7-2cce-422b-9bae-185eb1343b94', created_at: '1718876384378', status: 'active', name: 'tes', item_type: 'bundling', hpp: '100000', base_price: '100000', limit_type: 'no limit', limit_value: 0, item_category: { id: 'ab15981a-a656-4efc-856c-b2abfbe30979', name: 'Kategori Bundling 2', }, bundling_items: [ { id: 'bd5a7a38-df25-4203-a1cd-bf94867946b2', name: 'Wahana 21 panjangggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg', }, ], tenant: null, }, qty: 40, total_price: 4000000, }, ], }) @IsArray() items: TransactionItemEntity[]; }