fix: decouple act locking from visit verification completion

This commit is contained in:
2026-09-08 09:07:05 -03:00
parent 2506bece76
commit 71d0884557
@@ -277,7 +277,6 @@ export class InspectionClosingService {
this.assertDraftInProgress(act, visit);
await this.assertActorAssigned(manager, visit.id, principal, true);
await this.requireResponsible(manager, actId);
await this.assertVerificationResultsComplete(manager, visit.id);
if (await this.signatureCount(manager, actId)) {
throw new ConflictException({
code: 'INSPECTION_ACT_ALREADY_SIGNED',
@@ -935,22 +934,6 @@ export class InspectionClosingService {
};
}
private async assertVerificationResultsComplete(manager: EntityManager, inspectionId: string): Promise<void> {
const [row] = await manager.query(`
SELECT
COUNT(*)::integer AS total,
COUNT(*) FILTER (WHERE outcome IS NOT NULL)::integer AS completed
FROM inspection_finding_verification_visits
WHERE visit_id=$1
`, [inspectionId]) as Array<{ total: number; completed: number }>;
if (Number(row?.total ?? 0) > 0 && Number(row.completed) !== Number(row.total)) {
throw new ConflictException({
code: 'INSPECTION_VERIFICATION_RESULTS_REQUIRED',
message: 'Registrá el resultado de todas las verificaciones antes de finalizar el acta',
});
}
}
private async deadlinePolicy(manager: EntityManager): Promise<DeadlinePolicy> {
const [row] = await manager.query(`
SELECT