refactor: nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-03-22 20:36:48 +02:00
parent 136cc907bb
commit 2eb56e5850
45 changed files with 1210 additions and 198 deletions

View File

@@ -1,10 +1,12 @@
import { ItemEntryDto } from '@/modules/TransactionItemEntry/dto/ItemEntry.dto';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
IsArray,
IsBoolean,
IsDate,
IsEnum,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
@@ -26,18 +28,35 @@ class AttachmentDto {
}
export class CommandSaleEstimateDto {
@IsNumber()
@IsNotEmpty()
@ApiProperty({
description: 'The id of the customer',
example: 1,
})
customerId: number;
@IsDate()
@Type(() => Date)
@ApiProperty({
description: 'The date of the estimate',
example: '2021-01-01',
})
estimateDate: Date;
@IsDate()
@Type(() => Date)
@ApiProperty({
description: 'The expiration date of the estimate',
example: '2021-01-01',
})
expirationDate: Date;
@IsString()
@IsOptional()
@ApiProperty({
description: 'The reference of the estimate',
example: '123456',
})
reference?: string;
@IsString()
@@ -50,53 +69,111 @@ export class CommandSaleEstimateDto {
@IsNumber()
@Min(0.01)
@IsOptional()
@ApiProperty({
description: 'The exchange rate of the estimate',
example: 1,
})
exchangeRate?: number;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The id of the warehouse',
example: 1,
})
warehouseId?: number;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The id of the branch',
example: 1,
})
branchId?: number;
@IsArray()
@MinLength(1)
@ValidateNested({ each: true })
@Type(() => SaleEstimateEntryDto)
@ApiProperty({
description: 'The entries of the estimate',
example: [
{
index: 1,
itemId: 1,
description: 'This is a description',
quantity: 100,
cost: 100,
},
],
})
entries: SaleEstimateEntryDto[];
@IsString()
@IsOptional()
@ApiProperty({
description: 'The note of the estimate',
example: 'This is a note',
})
note?: string;
@IsString()
@IsOptional()
@ApiProperty({
description: 'The terms and conditions of the estimate',
example: 'This is a terms and conditions',
})
termsConditions?: string;
@IsString()
@IsOptional()
@ApiProperty({
description: 'The email to send the estimate to',
example: 'test@test.com',
})
sendToEmail?: string;
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => AttachmentDto)
attachments?: AttachmentDto[];
@ApiProperty({
description: 'The attachments of the estimate',
example: [
{
key: '123456',
},
],
})
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The id of the pdf template',
example: 1,
})
pdfTemplateId?: number;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The discount of the estimate',
example: 1,
})
discount?: number;
@IsEnum(DiscountType)
@ApiProperty({
description: 'The type of the discount',
example: DiscountType.Amount,
})
discountType: DiscountType = DiscountType.Amount;
@IsNumber()
@IsOptional()
@ApiProperty({
description: 'The adjustment of the estimate',
example: 1,
})
adjustment?: number;
}