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; +}