feat: implement save receipt functionality with transaction handling and DTOs
Test Suite / test (24.15.0) (push) Has been cancelled
Test Suite / test (24.15.0) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
import { IsNumber, IsOptional, IsString, IsBoolean, IsArray, ValidateNested, IsIn, Min, MaxLength } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class SaveReceiptItemDto {
|
||||
@IsString()
|
||||
@MaxLength(191)
|
||||
rawName!: string;
|
||||
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
quantity!: number;
|
||||
|
||||
@IsString()
|
||||
unit!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
price?: number | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
brand?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(100)
|
||||
origin?: string | null;
|
||||
|
||||
@IsIn(['inventory', 'pantry'])
|
||||
destination!: 'inventory' | 'pantry';
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
productId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(191)
|
||||
createProductName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
categoryId?: number | null;
|
||||
|
||||
// Paketfält (kan editeras i UI)
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
packQuantity?: number | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
packUnit?: string | null;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
packageCount?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
learnAlias?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
learnUnitMapping?: boolean;
|
||||
}
|
||||
|
||||
export class SaveReceiptDto {
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => SaveReceiptItemDto)
|
||||
items!: SaveReceiptItemDto[];
|
||||
|
||||
@IsOptional()
|
||||
@IsBoolean()
|
||||
isAdminLearning?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user