113 lines
2.6 KiB
TypeScript
113 lines
2.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
IsString,
|
|
IsNumber,
|
|
IsOptional,
|
|
IsUUID,
|
|
IsEnum,
|
|
IsArray,
|
|
ValidateNested,
|
|
Min,
|
|
MaxLength,
|
|
} from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
import { OrderChannel, OrderType, OrderStatus } from '../entities/order.entity';
|
|
|
|
export class OrderItemDto {
|
|
@ApiPropertyOptional({ description: 'ID del producto' })
|
|
@IsOptional()
|
|
@IsUUID()
|
|
productId?: string;
|
|
|
|
@ApiProperty({ description: 'Nombre del producto' })
|
|
@IsString()
|
|
@MaxLength(100)
|
|
productName: string;
|
|
|
|
@ApiProperty({ description: 'Cantidad', example: 2 })
|
|
@IsNumber()
|
|
@Min(0.001)
|
|
quantity: number;
|
|
|
|
@ApiProperty({ description: 'Precio unitario', example: 25.5 })
|
|
@IsNumber()
|
|
@Min(0)
|
|
unitPrice: number;
|
|
|
|
@ApiPropertyOptional({ description: 'Notas del item' })
|
|
@IsOptional()
|
|
@IsString()
|
|
notes?: string;
|
|
}
|
|
|
|
export class CreateOrderDto {
|
|
@ApiPropertyOptional({ description: 'ID del cliente' })
|
|
@IsOptional()
|
|
@IsUUID()
|
|
customerId?: string;
|
|
|
|
@ApiPropertyOptional({ enum: OrderChannel, default: OrderChannel.WHATSAPP })
|
|
@IsOptional()
|
|
@IsEnum(OrderChannel)
|
|
channel?: OrderChannel;
|
|
|
|
@ApiPropertyOptional({ enum: OrderType, default: OrderType.PICKUP })
|
|
@IsOptional()
|
|
@IsEnum(OrderType)
|
|
orderType?: OrderType;
|
|
|
|
@ApiProperty({ type: [OrderItemDto], description: 'Items del pedido' })
|
|
@IsArray()
|
|
@ValidateNested({ each: true })
|
|
@Type(() => OrderItemDto)
|
|
items: OrderItemDto[];
|
|
|
|
@ApiPropertyOptional({ description: 'Cargo por delivery', default: 0 })
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
deliveryFee?: number;
|
|
|
|
@ApiPropertyOptional({ description: 'Descuento', default: 0 })
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
discountAmount?: number;
|
|
|
|
@ApiPropertyOptional({ description: 'Dirección de entrega' })
|
|
@IsOptional()
|
|
@IsString()
|
|
deliveryAddress?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Notas de entrega' })
|
|
@IsOptional()
|
|
@IsString()
|
|
deliveryNotes?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Notas del cliente' })
|
|
@IsOptional()
|
|
@IsString()
|
|
customerNotes?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Método de pago' })
|
|
@IsOptional()
|
|
@IsString()
|
|
paymentMethod?: string;
|
|
}
|
|
|
|
export class UpdateOrderStatusDto {
|
|
@ApiProperty({ enum: OrderStatus, description: 'Nuevo estado' })
|
|
@IsEnum(OrderStatus)
|
|
status: OrderStatus;
|
|
|
|
@ApiPropertyOptional({ description: 'Razón (para cancelación)' })
|
|
@IsOptional()
|
|
@IsString()
|
|
reason?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Notas internas' })
|
|
@IsOptional()
|
|
@IsString()
|
|
internalNotes?: string;
|
|
}
|