feat: allow correcting honey measurements and queen evaluations
Both records could be created but never changed. A water-content reading decides whether a batch may be sold as honey at all, and queen ratings drive breeding decisions - a slipped digit in either is exactly the kind of wrong value that must not be left standing. - New PATCH /honey-batches/measurements/:measurementId behind honey-batches:measure, and PATCH /queens/evaluations/:evaluationId behind queens:evaluate. Both are addressed by the child record's own id, so the routes take two path segments and do not collide with PATCH /:id. - Both log before and after data, like every other correction. - The measurement list on the honey batch page and the rating list on the queen page gained an edit dialog; the rating dialog reuses the existing criteria list rather than restating it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
b0e05daa42
commit
42ceb33844
14 files changed
+503
-15
No files matched your search
@@ -13,6 +13,7 @@ import { CreateQueenDto } from './dto/create-queen.dto';
|
||||
import { UpdateQueenDto } from './dto/update-queen.dto';
|
||||
import { AssignColonyDto } from './dto/assign-colony.dto';
|
||||
import { CreateQueenEvaluationDto } from './dto/create-queen-evaluation.dto';
|
||||
import { UpdateQueenEvaluationDto } from './dto/update-queen-evaluation.dto';
|
||||
|
||||
export interface QueenFilter {
|
||||
status?: QueenStatus;
|
||||
@@ -227,6 +228,32 @@ export class QueensService {
|
||||
});
|
||||
}
|
||||
|
||||
async updateEvaluation(
|
||||
evaluationId: string,
|
||||
dto: UpdateQueenEvaluationDto,
|
||||
actingUserId: string,
|
||||
) {
|
||||
const before = await this.prisma.queenEvaluation.findUnique({
|
||||
where: { id: evaluationId },
|
||||
});
|
||||
if (!before) {
|
||||
throw new NotFoundException('Queen evaluation not found');
|
||||
}
|
||||
const evaluation = await this.prisma.queenEvaluation.update({
|
||||
where: { id: evaluationId },
|
||||
data: { ...dto, date: dto.date ? new Date(dto.date) : undefined },
|
||||
});
|
||||
await this.auditLog.record({
|
||||
entityType: 'QueenEvaluation',
|
||||
entityId: evaluationId,
|
||||
action: 'UPDATE',
|
||||
userId: actingUserId,
|
||||
beforeData: before,
|
||||
afterData: evaluation,
|
||||
});
|
||||
return evaluation;
|
||||
}
|
||||
|
||||
async addEvaluation(
|
||||
id: string,
|
||||
dto: CreateQueenEvaluationDto,
|
||||
|
||||
Reference in new issue
Block a user