From 844dd81af222c7bb3d5be5b5cbabda8ee6a29f7c Mon Sep 17 00:00:00 2001 From: admin-valentin Date: Fri, 31 Jul 2026 10:44:56 +0000 Subject: [PATCH] feat(transactions): add dto --- src/transactions/dto.ts | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/transactions/dto.ts diff --git a/src/transactions/dto.ts b/src/transactions/dto.ts new file mode 100644 index 0000000..0ae9178 --- /dev/null +++ b/src/transactions/dto.ts @@ -0,0 +1,50 @@ +import { IsIn, IsISO8601, IsInt, IsOptional, IsString, IsUUID, Length, Min } from 'class-validator'; + +export const EVIDENCE_STATUSES = ['missing', 'partial', 'complete', 'not_required'] as const; +export type EvidenceStatusValue = (typeof EVIDENCE_STATUSES)[number]; + +export class CreateTransactionDto { + @IsUUID() + organizationId!: string; + + @IsString() + @Length(1, 64) + type!: string; + + /** Valoarea in unitati minore (ex: bani in centi). NU se admit zecimale. */ + @IsInt() + @Min(0) + amountMinorUnits!: number; + + @IsString() + @Length(3, 3) + currency!: string; + + @IsISO8601() + transactionDate!: string; + + @IsOptional() + @IsIn(EVIDENCE_STATUSES as unknown as string[]) + evidenceStatus?: EvidenceStatusValue; + + @IsOptional() + @IsString() + @Length(1, 255) + source?: string; +} + +export class UpdateTransactionDto { + @IsOptional() + @IsIn(EVIDENCE_STATUSES as unknown as string[]) + evidenceStatus?: EvidenceStatusValue; + + @IsOptional() + @IsString() + @Length(1, 64) + type?: string; + + @IsOptional() + @IsString() + @Length(1, 255) + source?: string; +}