inventory

This commit is contained in:
2025-12-14 23:02:55 +03:30
parent 996cd0016c
commit 0ac1b39100
16 changed files with 453 additions and 30 deletions
@@ -0,0 +1,40 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsArray, ValidateNested, ArrayMinSize, IsString, IsNumber, Min, IsDate } from 'class-validator';
import { Type } from 'class-transformer';
export class BulkReserveFoodItemDto {
@ApiProperty({ example: 'food-123', description: 'Food ID' })
@IsNotEmpty()
@IsString()
foodId!: string;
@ApiProperty({ example: 5, description: 'Quantity to reserve' })
@IsNotEmpty()
@IsNumber()
@Min(1)
@Type(() => Number)
quantity!: number;
@ApiProperty({ example: '2024-12-31T23:59:59Z', description: 'Reservation expiration date' })
@IsNotEmpty()
@IsDate()
@Type(() => Date)
expiresAt!: Date;
}
export class BulkReserveFoodDto {
@ApiProperty({
description: 'Array of food reservations to create',
type: [BulkReserveFoodItemDto],
example: [
{ foodId: 'food-123', quantity: 5, expiresAt: '2024-12-31T23:59:59Z' },
{ foodId: 'food-789', quantity: 3, expiresAt: '2024-12-31T23:59:59Z' },
],
})
@IsNotEmpty()
@IsArray()
@ArrayMinSize(1, { message: 'At least one item is required' })
@ValidateNested({ each: true })
@Type(() => BulkReserveFoodItemDto)
items!: BulkReserveFoodItemDto[];
}
@@ -0,0 +1,27 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsArray, ValidateNested, ArrayMinSize } from 'class-validator';
import { Type } from 'class-transformer';
import { SetStockDto } from './set-stock.dto';
export class BulkSetStockItemDto extends SetStockDto {
@ApiProperty({ example: 'food-123', description: 'Food ID' })
@IsNotEmpty()
foodId!: string;
}
export class BulkSetStockDto {
@ApiProperty({
description: 'Array of stock items to set',
type: [BulkSetStockItemDto],
example: [
{ foodId: 'food-123', totalStock: 100, availableStock: 80 },
{ foodId: 'food-456', totalStock: 50, availableStock: 45 },
],
})
@IsNotEmpty()
@IsArray()
@ArrayMinSize(1, { message: 'At least one item is required' })
@ValidateNested({ each: true })
@Type(() => BulkSetStockItemDto)
items!: BulkSetStockItemDto[];
}
@@ -0,0 +1 @@
export class CreateInventoryDto {}
@@ -0,0 +1,17 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNumber, Min } from 'class-validator';
import { Type } from 'class-transformer';
export class SetStockDto {
@ApiProperty({ example: 100, description: 'Total stock quantity' })
@IsNumber()
@Min(0)
@Type(() => Number)
totalStock!: number;
@ApiProperty({ example: 80, description: 'Available stock quantity' })
@IsNumber()
@Min(0)
@Type(() => Number)
availableStock!: number;
}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger';
import { CreateInventoryDto } from './create-inventory.dto';
export class UpdateInventoryDto extends PartialType(CreateInventoryDto) {}