- Treatments book their dose from a medicine lot (delta booking on edit, bulk all-or-nothing, idempotent); Bestandsbuch columns from the lot, FEHLT exactly where treatmentLogGaps reports a gap; Bestandsbuch export needs veterinary-medicines:read. - Label printing: 409 LABEL_PARTICULARS_MISSING on gaps, proof print with watermark, PRINT audit before the PDF, check endpoints; digit rules only from the seeded ComplianceSettings row (fail closed). - Restricted zone (Berlin day): create, update, move, merge and CSV import blocked inside an active restriction; override with reason and compliance:manage, audited, never stored on the colony; split, harvest and dissolve stay free; restriction details only with compliance:read. - Authority notices: settings, herd snapshot, registration/herd change/TSK notices with one open draft per kind under the settings lock. - Label check refinements (geometric reading order, number|unit pairs). - ARCHITECTURE.md §12.6–12.8, Annahmen 71–77; spec §5.6 Berlin day. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
26 lines
916 B
TypeScript
26 lines
916 B
TypeScript
const MONTH_DAY_PATTERN = /^(\d{2})-(\d{2})$/;
|
|
// Days per month of a non-leap year: 02-29 is not a valid reference day, so
|
|
// the reference day exists in every year.
|
|
const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
|
|
/** MM-TT with a real month and a day that exists in a non-leap year. */
|
|
export function isValidMonthDay(value: string): boolean {
|
|
const match = MONTH_DAY_PATTERN.exec(value);
|
|
if (!match) {
|
|
return false;
|
|
}
|
|
const month = Number(match[1]);
|
|
const day = Number(match[2]);
|
|
return (
|
|
month >= 1 && month <= 12 && day >= 1 && day <= DAYS_IN_MONTH[month - 1]
|
|
);
|
|
}
|
|
|
|
/** The reference day (YYYY-MM-DD) of a year for a stored MM-TT. */
|
|
export function tskReferenceDayOf(year: number, monthDay: string): string {
|
|
if (!isValidMonthDay(monthDay)) {
|
|
throw new Error(`Invalid month-day: ${monthDay}`);
|
|
}
|
|
return `${String(year).padStart(4, '0')}-${monthDay}`;
|
|
}
|