feat: make the parent relation of every record correctable after entry
An inspection, treatment, feeding, varroa measurement or swarm control check filed against the wrong colony could not be repaired: the colony was frozen at creation time, and with no delete endpoint either, the only remedy was leaving a wrong record in the colony's history. The same held for a harvest booked against the wrong apiary or with a colony forgotten, for an extraction linked to the wrong harvests, and for a honey batch whose number or source extraction was mistyped. Backend: - The five colony-scoped update DTOs now cover the full create DTO, colonyId included. - Harvest update accepts apiaryId and colonyIds, extraction update accepts harvestIds. Both validate the ids first and replace the whole join-row set inside the existing transaction; the join rows carry no data of their own, so replacing beats diffing. - Honey batch update accepts batchNumber, extractionId and status. Status was previously only ever set to BOTTLED by the bottling module, so SOLD and CONSUMED were unreachable through the API. - Colony and storage container codes, and a task's relatedType/relatedId, are editable. - apiaryId on a colony and storageContainerId on a honey batch stay out of PATCH on purpose: both have dedicated endpoints that also write the history entry (ColonyApiaryHistory, HoneyBatchRelocation) the traceability chain depends on. - AllExceptionsFilter now also translates Prisma P2003 to a 400 and P2025 to a 404. Services write straight against the foreign keys with no application level existence check, so before this a stale or mistyped relation id came back as a bare 500 and filled the log with fake server errors. Frontend: - New shared fields: ColonySelectField (used by all five colony-scoped edit dialogs), HarvestSelectField (both extraction dialogs) and TaskRelatedField. - Re-filing a record invalidates the lists of both the colony it left and the one it joined, otherwise one of the two stays stale. - The harvest dialog gained an apiary select and a colony checklist that keeps already-linked colonies visible even when they moved or were dissolved; the honey batch dialog gained batch number, source extraction and status. - Extraction and harvest forms refuse to submit an empty relation set instead of letting the backend reject it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
2b15795a60
commit
bee2199647
44 files changed
+958
-156
No files matched your search
@@ -47,6 +47,7 @@ export interface CreateColonyInput {
|
||||
}
|
||||
|
||||
export interface UpdateColonyInput {
|
||||
code?: string;
|
||||
hiveType?: string;
|
||||
originText?: string;
|
||||
colonyType?: ColonyType;
|
||||
|
||||
@@ -35,6 +35,8 @@ export interface CreateExtractionInput {
|
||||
}
|
||||
|
||||
export interface UpdateExtractionInput {
|
||||
/** Replaces the whole set of source harvests. */
|
||||
harvestIds?: string[];
|
||||
date?: string;
|
||||
amount?: number;
|
||||
room?: string;
|
||||
|
||||
@@ -31,6 +31,8 @@ export interface CreateFeedingInput {
|
||||
}
|
||||
|
||||
export interface UpdateFeedingInput {
|
||||
/** Re-files the feeding under a different colony. */
|
||||
colonyId?: string;
|
||||
date?: string;
|
||||
feedType?: FeedType;
|
||||
product?: string;
|
||||
|
||||
@@ -33,6 +33,9 @@ export interface CreateHarvestInput {
|
||||
}
|
||||
|
||||
export interface UpdateHarvestInput {
|
||||
apiaryId?: string;
|
||||
/** Replaces the whole set of participating colonies. */
|
||||
colonyIds?: string[];
|
||||
date?: string;
|
||||
honeyType?: string;
|
||||
honeySuperCount?: number;
|
||||
|
||||
@@ -90,9 +90,12 @@ export interface CreateHoneyBatchInput {
|
||||
}
|
||||
|
||||
export interface UpdateHoneyBatchInput {
|
||||
batchNumber?: string;
|
||||
extractionId?: string;
|
||||
honeyType?: string;
|
||||
amount?: number;
|
||||
waterContent?: number;
|
||||
status?: HoneyBatchStatus;
|
||||
}
|
||||
|
||||
export interface CreateHoneyMeasurementInput {
|
||||
|
||||
@@ -50,6 +50,8 @@ export interface CreateInspectionInput {
|
||||
}
|
||||
|
||||
export interface UpdateInspectionInput {
|
||||
/** Re-files the inspection under a different colony. */
|
||||
colonyId?: string;
|
||||
date?: string;
|
||||
weather?: string;
|
||||
temperature?: number;
|
||||
|
||||
@@ -42,6 +42,7 @@ export interface CreateStorageContainerInput {
|
||||
}
|
||||
|
||||
export interface UpdateStorageContainerInput {
|
||||
code?: string;
|
||||
containerType?: string;
|
||||
capacity?: number;
|
||||
location?: string;
|
||||
|
||||
@@ -32,6 +32,8 @@ export interface CreateSwarmControlCheckInput {
|
||||
}
|
||||
|
||||
export interface UpdateSwarmControlCheckInput {
|
||||
/** Re-files the check under a different colony. */
|
||||
colonyId?: string;
|
||||
date?: string;
|
||||
queenCellsFound?: number;
|
||||
queenCellsCapped?: boolean;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TaskPriority, TaskStatus } from "./types";
|
||||
import { TaskPriority, TaskRelatedType, TaskStatus } from "./types";
|
||||
|
||||
export const TASK_STATUSES: TaskStatus[] = ["OPEN", "IN_PROGRESS", "DONE", "CANCELLED"];
|
||||
|
||||
@@ -17,3 +17,21 @@ export const TASK_PRIORITY_LABELS: Record<TaskPriority, string> = {
|
||||
HIGH: "Hoch",
|
||||
URGENT: "Dringend",
|
||||
};
|
||||
|
||||
export const TASK_RELATED_TYPES: TaskRelatedType[] = [
|
||||
"GENERAL",
|
||||
"COLONY",
|
||||
"APIARY",
|
||||
"QUEEN",
|
||||
"HONEY_BATCH",
|
||||
"STORAGE",
|
||||
];
|
||||
|
||||
export const TASK_RELATED_TYPE_LABELS: Record<TaskRelatedType, string> = {
|
||||
GENERAL: "Allgemein",
|
||||
COLONY: "Volk",
|
||||
APIARY: "Bienenstand",
|
||||
QUEEN: "Königin",
|
||||
HONEY_BATCH: "Honigcharge",
|
||||
STORAGE: "Lagerbehälter",
|
||||
};
|
||||
@@ -44,4 +44,6 @@ export interface UpdateTaskInput {
|
||||
dueDate?: string;
|
||||
assignedUserId?: string;
|
||||
status?: TaskStatus;
|
||||
relatedType?: TaskRelatedType;
|
||||
relatedId?: string;
|
||||
}
|
||||
@@ -32,6 +32,8 @@ export interface CreateTreatmentInput {
|
||||
}
|
||||
|
||||
export interface UpdateTreatmentInput {
|
||||
/** Re-files the treatment under a different colony. */
|
||||
colonyId?: string;
|
||||
date?: string;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
|
||||
@@ -30,6 +30,8 @@ export interface CreateVarroaMeasurementInput {
|
||||
}
|
||||
|
||||
export interface UpdateVarroaMeasurementInput {
|
||||
/** Re-files the measurement under a different colony. */
|
||||
colonyId?: string;
|
||||
date?: string;
|
||||
method?: VarroaMethod;
|
||||
durationMinutes?: number;
|
||||
|
||||
Reference in new issue
Block a user