add order item
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
IsArray, IsNumber,
|
||||
IsNotEmpty,
|
||||
ArrayMinSize
|
||||
} from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class InvoiceItemDto {
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
productId: number;
|
||||
|
||||
@ApiProperty()
|
||||
@IsArray()
|
||||
attributesValues: string[]
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
quantity: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
unitPrice: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
discount: number
|
||||
|
||||
}
|
||||
|
||||
export class AddOrderItemDto {
|
||||
@IsArray()
|
||||
@ApiProperty({
|
||||
isArray: true, type: [InvoiceItemDto], example: [
|
||||
{
|
||||
orderItemId: 1,
|
||||
unitPrice: 100,
|
||||
}
|
||||
]
|
||||
})
|
||||
@IsNotEmpty()
|
||||
@ArrayMinSize(1, { message: 'At least one product is required' })
|
||||
@Type(() => InvoiceItemDto)
|
||||
items: InvoiceItemDto[];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ export class InvoiceItemDto {
|
||||
@IsNumber()
|
||||
unitPrice: number
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
discount: number
|
||||
|
||||
}
|
||||
|
||||
export class CreateInvoiceDto {
|
||||
@@ -32,8 +36,6 @@ export class CreateInvoiceDto {
|
||||
@Type(() => InvoiceItemDto)
|
||||
items: InvoiceItemDto[];
|
||||
|
||||
@ApiProperty()
|
||||
@IsNumber()
|
||||
discount: number
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user