Files
CRM_Montzar/apps/api/src/finance/dto.ts
T

81 lines
1.3 KiB
TypeScript

import {
IsIn,
IsNumber,
IsOptional,
IsString,
MaxLength,
Min,
MinLength,
} from 'class-validator';
import { Type } from 'class-transformer';
const CHEQUE_STATUSES = ['pending', 'cleared', 'bounced'] as const;
const CHEQUE_DIRECTIONS = ['in', 'out'] as const;
export class CreateChequeDto {
@IsString()
@MinLength(1)
personId!: string;
@Type(() => Number)
@IsNumber()
@Min(0.01)
amount!: number;
@IsOptional()
@IsString()
@MaxLength(8)
currency?: string;
@IsString()
@MinLength(1)
@MaxLength(80)
number!: string;
@IsString()
@MinLength(1)
@MaxLength(120)
bank!: string;
@IsString()
dueDate!: string;
@IsOptional()
@IsIn(CHEQUE_STATUSES)
status?: (typeof CHEQUE_STATUSES)[number];
@IsOptional()
@IsIn(CHEQUE_DIRECTIONS)
direction?: (typeof CHEQUE_DIRECTIONS)[number];
@IsOptional()
@IsString()
@MaxLength(2000)
notes?: string;
}
export class UpdateChequeDto {
@IsOptional()
@IsString()
@MaxLength(80)
number?: string;
@IsOptional()
@IsString()
@MaxLength(120)
bank?: string;
@IsOptional()
@IsString()
dueDate?: string;
@IsOptional()
@IsIn(CHEQUE_STATUSES)
status?: (typeof CHEQUE_STATUSES)[number];
@IsOptional()
@IsString()
@MaxLength(2000)
notes?: string | null;
}