Files
CRM_Montzar/apps/api/src/account-balances/dto.ts
T

60 lines
1.1 KiB
TypeScript

import { Type } from 'class-transformer';
import {
IsIn,
IsInt,
IsNumber,
IsObject,
IsOptional,
IsString,
Max,
MaxLength,
Min,
ValidateIf,
ValidateNested,
} from 'class-validator';
export class AccountBalanceRangeBody {
@IsIn(['all_debtors', 'range'])
mode!: 'all_debtors' | 'range';
@ValidateIf((o: AccountBalanceRangeBody) => o.mode === 'range')
@IsNumber()
min?: number;
@ValidateIf((o: AccountBalanceRangeBody) => o.mode === 'range')
@IsNumber()
max?: number;
}
export class UpdateAccountBalanceSettingsDto {
@IsOptional()
@IsString()
@MaxLength(80)
firstStageName?: string;
@IsOptional()
@ValidateIf((_, v) => v !== null)
@ValidateNested()
@Type(() => AccountBalanceRangeBody)
rial?: AccountBalanceRangeBody | null;
@IsOptional()
@IsObject()
weights?: Record<string, AccountBalanceRangeBody | null>;
}
export class EvaluateAccountBalancesDto {
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(0)
offset?: number;
@IsOptional()
@Type(() => Number)
@IsInt()
@Min(1)
@Max(2000)
limit?: number;
}