92 lines
1.7 KiB
TypeScript
92 lines
1.7 KiB
TypeScript
import {
|
|
IsArray, IsNumber,
|
|
IsNotEmpty,
|
|
ArrayMinSize,
|
|
IsBoolean,
|
|
IsString
|
|
} from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Type } from 'class-transformer';
|
|
|
|
export class InvoiceOrderItemDto {
|
|
@IsNumber()
|
|
@ApiProperty()
|
|
orderItemId: number;
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
unitPrice: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
discount: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
quantity: number
|
|
|
|
}
|
|
|
|
export class InvoiceOrderNewItemDto {
|
|
@IsNumber()
|
|
@ApiProperty()
|
|
productId: number;
|
|
|
|
@ApiProperty()
|
|
@IsArray()
|
|
attributesValues: string[]
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
quantity: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
unitPrice: number
|
|
|
|
@ApiProperty()
|
|
@IsNumber()
|
|
discount: number
|
|
|
|
}
|
|
|
|
export class UpdateInvoicedOrderDto {
|
|
@IsArray()
|
|
@ApiProperty({
|
|
isArray: true, type: [InvoiceOrderItemDto], example: [
|
|
{
|
|
orderItemId: 1,
|
|
unitPrice: 100,
|
|
}
|
|
]
|
|
})
|
|
@IsNotEmpty()
|
|
@ArrayMinSize(1, { message: 'At least one product is required' })
|
|
@Type(() => InvoiceOrderItemDto)
|
|
items: InvoiceOrderItemDto[];
|
|
|
|
@IsArray()
|
|
@ApiProperty({
|
|
isArray: true, type: [InvoiceOrderNewItemDto], example: [
|
|
{
|
|
orderItemId: 1,
|
|
unitPrice: 100,
|
|
}
|
|
]
|
|
})
|
|
@Type(() => InvoiceOrderNewItemDto)
|
|
newItems: InvoiceOrderNewItemDto[];
|
|
|
|
@ApiProperty()
|
|
@IsBoolean()
|
|
enableTax: boolean
|
|
|
|
|
|
@ApiPropertyOptional({ example: [] })
|
|
@IsArray()
|
|
@IsString({ each: true })
|
|
attachments: string[]
|
|
|
|
}
|
|
|