add item to invoice

This commit is contained in:
2026-01-24 11:47:44 +03:30
parent 49390ce62e
commit bdc76689a5
4 changed files with 122 additions and 43 deletions
+48 -2
View File
@@ -2,9 +2,10 @@ import {
IsInt, IsArray, IsNumber,
IsNotEmpty,
ArrayMinSize,
IsBoolean
IsBoolean,
IsString
} from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class InvoiceItemDto {
@@ -20,6 +21,33 @@ export class InvoiceItemDto {
@IsNumber()
discount: number
@ApiProperty()
@IsNumber()
quantity: number
}
export class InvoiceNewItemDto {
@IsNumber()
@ApiProperty()
productId: number;
@ApiProperty()
@IsArray()
attributesValues: string[]
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@IsNumber()
discount: number
}
export class CreateInvoiceDto {
@@ -37,9 +65,27 @@ export class CreateInvoiceDto {
@Type(() => InvoiceItemDto)
items: InvoiceItemDto[];
@IsArray()
@ApiProperty({
isArray: true, type: [InvoiceItemDto], example: [
{
orderItemId: 1,
unitPrice: 100,
}
]
})
@Type(() => InvoiceNewItemDto)
newItems: InvoiceNewItemDto[];
@ApiProperty()
@IsBoolean()
enableTax: boolean
@ApiPropertyOptional({ example: [] })
@IsArray()
@IsString({ each: true })
attachments: string[]
}