refactor: dtos openapi

This commit is contained in:
Ahmed Bouhuolia
2025-03-22 23:21:52 +02:00
parent 2eb56e5850
commit 4c42515613
9 changed files with 357 additions and 14 deletions

View File

@@ -2,12 +2,14 @@ import { Type } from 'class-transformer';
import {
IsArray,
IsDate,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
ValidateNested,
} from 'class-validator';
import { AttachmentLinkDto } from '@/modules/Attachments/dtos/Attachment.dto';
import { ApiProperty } from '@nestjs/swagger';
export class BillPaymentEntryDto {
@IsNumber()
@@ -19,48 +21,98 @@ export class BillPaymentEntryDto {
export class CommandBillPaymentDTO {
@IsNumber()
@IsNotEmpty()
@ApiProperty({
description: 'The id of the vendor',
example: 1,
})
vendorId: number;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The amount of the bill payment',
example: 100,
})
amount?: number;
@IsNumber()
@IsNotEmpty()
@ApiProperty({
description: 'The id of the payment account',
example: 1,
})
paymentAccountId: number;
@IsString()
@IsOptional()
@ApiProperty({
description: 'The payment number of the bill payment',
example: '123456',
})
paymentNumber?: string;
@IsDate()
@Type(() => Date)
@ApiProperty({
description: 'The payment date of the bill payment',
example: '2021-01-01',
})
paymentDate: Date | string;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The exchange rate of the bill payment',
example: 1,
})
exchangeRate?: number;
@IsString()
@IsOptional()
@ApiProperty({
description: 'The statement of the bill payment',
example: '123456',
})
statement?: string;
@IsString()
@IsOptional()
reference?: string;
@IsArray()
@ValidateNested({ each: true })
@Type(() => BillPaymentEntryDto)
@ApiProperty({
description: 'The entries of the bill payment',
example: [
{
billId: 1,
paymentAmount: 100,
},
],
})
entries: BillPaymentEntryDto[];
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The id of the branch',
example: 1,
})
branchId?: number;
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => AttachmentLinkDto)
@ApiProperty({
description: 'The attachments of the bill payment',
example: [
{
id: 1,
type: 'bill',
},
],
})
attachments?: AttachmentLinkDto[];
}