Files
bigcapital/packages/server/src/modules/BillLandedCosts/dtos/AllocateBillLandedCost.dto.ts
2026-01-17 21:42:27 +02:00

46 lines
901 B
TypeScript

import {
IsInt,
IsIn,
IsOptional,
IsArray,
ValidateNested,
IsString,
IsNumber,
} from 'class-validator';
import { Type } from 'class-transformer';
import { ToNumber } from '@/common/decorators/Validators';
import { LandedCostTransactionType } from '../types/BillLandedCosts.types';
export class AllocateBillLandedCostItemDto {
@IsInt()
@ToNumber()
entryId: number;
@IsNumber()
@ToNumber()
cost: number;
}
export class AllocateBillLandedCostDto {
@IsInt()
@ToNumber()
transactionId: number;
@IsIn(['Expense', 'Bill'])
transactionType: LandedCostTransactionType;
@IsInt()
transactionEntryId: number;
@IsIn(['value', 'quantity'])
allocationMethod: string;
@IsOptional()
@IsString()
description?: string | null;
@IsArray()
@ValidateNested({ each: true })
@Type(() => AllocateBillLandedCostItemDto)
items: AllocateBillLandedCostItemDto[];
}