- RawMaterialLot (beeswax, propolis) in grams with origin (apiary, harvest); stock in the same movement ledger: withdrawals, inventory counts, and the new movement type CONSUMPTION. - Production batches take inputs (raw lot + grams); batch and consumption are one transaction, never more than a lot has left. Deleting a mistaken batch gives the material back as its own movement. - Traceability both ways: batch -> inputs, raw lot -> usedIn. - Movement belongs to exactly one of bottling / production / raw lot (CHECK); raw material changes do not trigger the shop webhook. - Permissions raw-material:*, granted to roles that maintain production batches. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
import {
|
|
IsDateString,
|
|
IsInt,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsPositive,
|
|
IsString,
|
|
MaxLength,
|
|
ValidateIf,
|
|
} from 'class-validator';
|
|
|
|
/**
|
|
* Corrects a raw material lot entered with a typo. The kind stays fixed -
|
|
* wax that went into candles does not turn into propolis afterwards.
|
|
* `apiaryId: null` / `harvestId: null` remove the origin.
|
|
*/
|
|
export class UpdateRawMaterialLotDto {
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(100)
|
|
lotNumber?: string;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsDateString()
|
|
date?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Gewonnene Menge in Gramm' })
|
|
@IsOptional()
|
|
@IsInt()
|
|
@IsPositive()
|
|
quantity?: number;
|
|
|
|
@ApiPropertyOptional({ nullable: true })
|
|
@IsOptional()
|
|
@ValidateIf((_object, value) => value !== null)
|
|
@IsString()
|
|
apiaryId?: string | null;
|
|
|
|
@ApiPropertyOptional({ nullable: true })
|
|
@IsOptional()
|
|
@ValidateIf((_object, value) => value !== null)
|
|
@IsString()
|
|
harvestId?: string | null;
|
|
|
|
@ApiPropertyOptional()
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(2000)
|
|
notes?: string;
|
|
}
|