import { IsBoolean, IsIn, IsOptional, IsString, MinLength, } from "class-validator"; /** Mirrors the Prisma `Currency` enum; a chequera's is fixed at creation. */ export const BANK_CURRENCIES = ["MXN", "USD"] as const; export type BankAccountCurrency = (typeof BANK_CURRENCIES)[number]; /** Mirrors `TransactionDomain`. A soft hint on the account, never enforced. */ export const BANK_BUSINESS_LINES = ["UTILITY", "INSURANCE", "TRUST"] as const; export type BankBusinessLine = (typeof BANK_BUSINESS_LINES)[number]; export class CreateBankDto { @IsString() @MinLength(1) name!: string; /** "MX" | "US" — free text, informational only. */ @IsOptional() @IsString() country?: string; } export class UpdateBankDto { @IsOptional() @IsString() @MinLength(1) name?: string; @IsOptional() @IsString() country?: string; } export class CreateBankAccountDto { @IsString() @MinLength(1) bankId!: string; @IsString() @MinLength(1) label!: string; /** * Immutable after creation (no field for it on the update DTO): every * movement already booked into the account is denominated in it, so * changing it would silently re-denominate history. */ @IsIn(BANK_CURRENCIES) currency!: BankAccountCurrency; @IsOptional() @IsIn(BANK_BUSINESS_LINES) businessLine?: BankBusinessLine; @IsOptional() @IsBoolean() active?: boolean; } export class UpdateBankAccountDto { @IsOptional() @IsString() @MinLength(1) bankId?: string; @IsOptional() @IsString() @MinLength(1) label?: string; @IsOptional() @IsIn(BANK_BUSINESS_LINES) businessLine?: BankBusinessLine; /** Closing an account hides it from the picker; its movements stay readable. */ @IsOptional() @IsBoolean() active?: boolean; }