feat(acl,domain): cancel the ZGW zaak on document-timeout expiry (S-10c, closes #106) #109

Merged
not merged 11 commits from feat/106-close-zaak-on-timeout into main 2026-07-21 13:58:16 +00:00
Showing only changes of commit f95ee623f4 - Show all commits
@@ -31,6 +31,14 @@ public sealed class ExpireRegistrationWorker(IRegistrationStore store, IAclClien
if (registration.Status is not (RegistrationStatus.Ingediend or RegistrationStatus.InBehandeling))
return;
// Cancel the ZGW zaak before advancing the aggregate (mirrors the approval path): if the ACL
// call fails it throws, the aggregate stays open, and the job is redelivered (§8.6) — rather
// than leaving the aggregate VERLOPEN while the zaak stays open. The status guard above stops a
// redelivered job from cancelling the zaak twice (a second resultaat would be a 400). A
// registration expired before its zaak was opened has nothing to cancel.
if (registration.ZaakUrl is not null)
await acl.CancelZaakAsync(registration.ZaakUrl, ct);
registration.Expire();
await store.SaveAsync(registration, ct);
}