import { ArrayMaxSize, IsArray, IsEnum, IsIn, IsNumber, IsOptional, IsString, MinLength, ValidateNested, } from "class-validator"; import { Type } from "class-transformer"; import { Currency } from "@jorgecuadros/database"; import { CreateCustomerDto } from "./create-customer.dto"; import { ServiceDto } from "../properties/property.dto"; /** The property, minus the customer it is being created for. */ export class OnboardPropertyDto { @IsOptional() @IsString() addressLine1?: string; @IsOptional() @IsString() addressLine2?: string; @IsOptional() @IsString() phone1?: string; } /** * The opening balance the office takes when an account is opened, captured as * the customer's first payment. Cash issues an EFE receipt; a check posts a * CHECK DEPOSIT against that check number. */ export class OpeningPaymentDto { @IsIn(["CASH", "CHECK"]) method!: "CASH" | "CHECK"; @IsNumber() amount!: number; @IsEnum(Currency) currency!: Currency; @IsString() @MinLength(1) receivedAt!: string; @IsOptional() @IsString() checkNumber?: string; /** Cash only: dollars credited to a pesos ledger. */ @IsOptional() @IsNumber() exchangeRate?: number; @IsOptional() @IsString() concept?: string; } /** One screen: cliente + propiedad + servicios + saldo inicial. */ export class OnboardCustomerDto { @ValidateNested() @Type(() => CreateCustomerDto) customer!: CreateCustomerDto; @IsOptional() @ValidateNested() @Type(() => OnboardPropertyDto) property?: OnboardPropertyDto; @IsOptional() @IsArray() @ArrayMaxSize(12) @ValidateNested({ each: true }) @Type(() => ServiceDto) services?: ServiceDto[]; @IsOptional() @ValidateNested() @Type(() => OpeningPaymentDto) openingPayment?: OpeningPaymentDto; }