Files
ApiCore/ApiCore-Backend/src/veterinary-medicines/dto/create-movement.dto.ts
T
Nick SzaunigandClaude Opus 5.5 c18860c75c
Backend Image / build-and-push (push) Successful in 6m34s
Frontend Image / build-and-push (push) Successful in 10m17s
feat: T6 wave 2 – medicine book, document rights, label particulars, herd events
- Veterinary medicine catalogue, lots and append-only movement ledger
  (rest always computed; corrections as counter-bookings; inactive
  medicines take no new stock; unit must match on lot moves).
- Documents of medicine lots, authority notices and restrictions need the
  domain right on top of documents:* (403 before any lookup).
- Label particulars: pure checkLabel with six mandatory gaps and four
  warnings, AFM font metrics, Berlin-day dates, geometric reading order
  for split addresses, new master-data fields with row-locked updates.
- Herd events ColonyCreated, ColonyMoved, ApiaryChanged and
  TskReferenceDayReached (ids only, never forwarded to webhooks); CSV
  import emits ColonyCreated with audit.
- ARCHITECTURE.md §12 Compliance (T6), Annahmen 59–70.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-15 13:43:44 +02:00

51 lines
1.5 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
IsIn,
IsNotEmpty,
IsNumber,
IsPositive,
IsString,
Matches,
Min,
MaxLength,
ValidateIf,
} from 'class-validator';
export const MANUAL_MOVEMENT_TYPES = ['CORRECTION', 'DISPOSAL'] as const;
export type ManualMovementType = (typeof MANUAL_MOVEMENT_TYPES)[number];
export const MAX_REASON_LENGTH = 500;
const FINITE = { allowNaN: false, allowInfinity: false } as const;
/**
* CORRECTION (inventory): the rest counted in the box. DISPOSAL: a positive
* quantity that leaves the lot, with a reason. TREATMENT bookings come only
* from a treatment.
*/
export class CreateMovementDto {
@ApiProperty({ enum: MANUAL_MOVEMENT_TYPES })
@IsIn(MANUAL_MOVEMENT_TYPES)
type!: ManualMovementType;
@ApiPropertyOptional({ description: 'CORRECTION: der tatsächliche Rest' })
@ValidateIf((dto: CreateMovementDto) => dto.type === 'CORRECTION')
@IsNumber(FINITE)
@Min(0)
actualRemaining?: number;
@ApiPropertyOptional({ description: 'DISPOSAL: Menge, positiv' })
@ValidateIf((dto: CreateMovementDto) => dto.type === 'DISPOSAL')
@IsNumber(FINITE)
@IsPositive()
quantity?: number;
@ApiPropertyOptional({ description: 'DISPOSAL: Pflicht' })
@ValidateIf(
(dto: CreateMovementDto) => dto.type === 'DISPOSAL' || dto.reason != null,
)
@IsString()
@IsNotEmpty()
@Matches(/\S/, { message: 'reason darf nicht nur aus Leerzeichen bestehen' })
@MaxLength(MAX_REASON_LENGTH)
reason?: string;
}