Files
negareh-api/src/modules/invoice/dto/create-invoice.dto.ts
T
2026-02-18 23:58:03 +03:30

63 lines
1.2 KiB
TypeScript

import {
IsString,
IsInt,
IsArray,
IsNumber,
IsOptional,
IsBoolean,
IsDateString,
ArrayMinSize,
Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class CreateInvoiceItemDto {
@IsString()
@ApiProperty({ description: 'Product ID' })
productId!: string;
@IsInt()
@Min(1)
@ApiProperty({ example: 1 })
quantity!: number;
@IsNumber()
@Min(0)
@ApiProperty({ example: 10000 })
unitPrice: number;
@IsOptional()
@IsNumber()
@Min(0)
@ApiPropertyOptional({ example: 0 })
discount?: number;
@IsOptional()
@IsString()
@ApiPropertyOptional()
description?: string;
}
export class CreateInvoiceDto {
@IsString()
@ApiProperty({ description: 'Request ID to create invoice for' })
requestId!: string;
@IsArray()
@ArrayMinSize(1)
@Type(() => CreateInvoiceItemDto)
@ApiProperty({ type: [CreateInvoiceItemDto] })
items!: CreateInvoiceItemDto[];
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({ example: false })
enableTax?: boolean;
@IsOptional()
@IsDateString()
@ApiPropertyOptional({ description: 'Approval deadline (ISO date string)' })
approvalDeadline?: string;
}