This commit is contained in:
2026-01-25 16:26:47 +03:30
parent 55856a40f1
commit b85ae3604c
7 changed files with 287 additions and 225 deletions
@@ -1,91 +0,0 @@
import {
IsInt, IsArray, IsNumber,
IsNotEmpty,
ArrayMinSize,
IsBoolean,
IsString
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class InvoiceItemDto {
@IsNumber()
@ApiProperty()
orderItemId: number;
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@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 {
@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[];
@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[]
}
+1 -1
View File
@@ -16,7 +16,7 @@ export class CreateOrderItemDto {
@ApiProperty()
@IsNumber()
quantity: number
// TODO : find a way to save attribute and value
@ApiProperty()
@IsArray()
attributesValues: string[]
@@ -0,0 +1,6 @@
import { PartialType } from '@nestjs/swagger';
import { CreateOrderItemDto } from './create-order.dto';
export class UpdateOrderItemDto extends PartialType(CreateOrderItemDto) { }
+91 -1
View File
@@ -1 +1,91 @@
export class UpdateOrderDto {}
import {
IsArray, IsNumber,
IsNotEmpty,
ArrayMinSize,
IsBoolean,
IsString
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
export class ItemDto {
@IsNumber()
@ApiProperty()
orderItemId: number;
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@IsNumber()
discount: number
@ApiProperty()
@IsNumber()
quantity: number
}
export class NewItemDto {
@IsNumber()
@ApiProperty()
productId: number;
@ApiProperty()
@IsArray()
attributesValues: string[]
@ApiProperty()
@IsNumber()
quantity: number
@ApiProperty()
@IsNumber()
unitPrice: number
@ApiProperty()
@IsNumber()
discount: number
}
export class UpdateNewOrderDto {
@IsArray()
@ApiProperty({
isArray: true, type: [ItemDto], example: [
{
orderItemId: 1,
unitPrice: 100,
}
]
})
@IsNotEmpty()
@ArrayMinSize(1, { message: 'At least one product is required' })
@Type(() => ItemDto)
items: ItemDto[];
@IsArray()
@ApiProperty({
isArray: true, type: [ItemDto], example: [
{
orderItemId: 1,
unitPrice: 100,
}
]
})
@Type(() => NewItemDto)
newItems: NewItemDto[];
@ApiProperty()
@IsBoolean()
enableTax: boolean
@ApiPropertyOptional({ example: [] })
@IsArray()
@IsString({ each: true })
attachments: string[]
}