## S-10c · Close the ZGW zaak on document-timeout expiry (closes #106) Completes the S-10a/S-10b boundary flagged in ADR-0017: when a registration's 30-day document term lapses, the domain now cancels the **ZGW zaak** as well as marking the aggregate `Verlopen`, so OpenZaak and the register no longer diverge. ### What it does On expiry the `ExpireRegistrationWorker` calls the ACL to set the zaak to a distinct, non-terminal **`Geannuleerd`** status with a **`Vervallen`** resultaat (vs the approval `Afgehandeld` + `Geregistreerd`), resolved **by omschrijving** in the ACL — the ACL-first ordering mirrors approval so a failed ZGW call leaves the job for redelivery rather than diverging the two. **Path:** Flowable P30D timer → `RegistratieVerlopen` job → domain `ExpireRegistrationWorker` → ACL `POST /annuleringen` → ZGW `resultaten` + `statussen` (Geannuleerd) → aggregate `Verlopen`. ### Layers touched (each red→green) - **ACL gateway** — `SetZaakToCancellationStatusAsync` (Geannuleerd + Vervallen by name); approval now resolves its `Geregistreerd` resultaat by name too (a second resultaattype now exists). - **ACL service/API** — `AclService.CancelZaakAsync` + `POST /annuleringen`. - **Domain** — `IAclClient.CancelZaakAsync` + client; expiry worker cancels the zaak before advancing to `Verlopen`, guarded against redelivery double-cancel. - **Seed** — non-terminal `Geannuleerd` statustype (volgnummer 2; `Afgehandeld` → 3) + `Vervallen` resultaattype, both idempotent by omschrijving and sharing the zaaktype's procestype. - **Verify/integration** — ACL↔OpenZaak integration test (live `Geannuleerd` + resultaat); `run-domain-check.sh` fires the real P30D timer and asserts the zaak reaches `Geannuleerd` end-to-end; BDD scenario asserts cancel-on-timeout vs untouched-when-in-time. - **Docs** — ADR-0019 (cancellation modelling decision), demo-script, BACKLOG. ### Design note (ADR-0019) ZGW allows only one eindstatus per zaaktype, so `Geannuleerd` is modelled as a **non-terminal** status (it records a cancellation status + resultaat but does not set `einddatum`). This follows the issue's explicit "distinct statustype + resultaat" outcome; the shared-eindstatus alternative is recorded in the ADR. ### Tests Unit + acceptance all green locally (Acl 38, Big 134, Acceptance 17, Bff 33, EventSubscriber 19). Integration + verify-stack run in CI (need live OpenZaak + selectielijst egress). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #109
82 lines
3.3 KiB
C#
82 lines
3.3 KiB
C#
namespace Acl.Application;
|
|
|
|
/// <summary>The ACL's single operation: open a zaak from a domain payload,
|
|
/// default-filling the ZGW-mandatory fields (ADR-0003).</summary>
|
|
public sealed class AclService(IZaakGateway gateway, AclDefaults defaults, IClock clock)
|
|
{
|
|
public Task<Uri> OpenZaakAsync(DomainRegistration registration, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(registration);
|
|
|
|
var request = new ZaakRequest(
|
|
defaults.Bronorganisatie,
|
|
defaults.VerantwoordelijkeOrganisatie,
|
|
defaults.Vertrouwelijkheidaanduiding,
|
|
defaults.ZaaktypeUrl,
|
|
clock.Today,
|
|
registration.Reference);
|
|
|
|
return gateway.OpenZaakAsync(request, ct);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Approve a zaak: set it to the eindstatus of the configured BIG zaaktype (ADR-0003 default). The
|
|
/// domain hands over only the zaak URL; the ACL owns which statustype means "approved" (§8.1).
|
|
/// </summary>
|
|
public Task ApproveZaakAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
return gateway.SetZaakToEindstatusAsync(zaakUrl, defaults.ZaaktypeUrl, clock.Today, ct);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cancel a zaak on document-timeout expiry (S-10c): set it to the configured BIG zaaktype's
|
|
/// cancellation statustype + resultaat. The domain hands over only the zaak URL; the ACL owns which
|
|
/// statustype/resultaat means "cancelled" (§8.1).
|
|
/// </summary>
|
|
public Task CancelZaakAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
return gateway.SetZaakToCancellationStatusAsync(zaakUrl, defaults.ZaaktypeUrl, clock.Today, ct);
|
|
}
|
|
|
|
/// <summary>The zaak's reference (its ZGW identificatie), for the read projection (#78).</summary>
|
|
public Task<string> GetZaakReferenceAsync(Uri zaakUrl, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
|
|
return gateway.GetZaakIdentificatieAsync(zaakUrl, ct);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Store an uploaded diploma against the zaak (S-10b): default-fill the ZGW-mandatory document
|
|
/// fields (informatieobjecttype, bronorganisatie, vertrouwelijkheidaanduiding, taal, creatiedatum)
|
|
/// and hand the file to the gateway, which creates the informatieobject and relates it to the zaak.
|
|
/// The domain supplies only the zaak, the bytes, and the file's name/type (§8.1).
|
|
/// </summary>
|
|
public Task<Uri> StoreDiplomaAsync(Uri zaakUrl, byte[] content, string fileName, string contentType, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(zaakUrl);
|
|
ArgumentNullException.ThrowIfNull(content);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(fileName);
|
|
ArgumentException.ThrowIfNullOrWhiteSpace(contentType);
|
|
|
|
var request = new DocumentRequest(
|
|
defaults.Bronorganisatie,
|
|
defaults.InformatieobjecttypeUrl,
|
|
defaults.Vertrouwelijkheidaanduiding,
|
|
zaakUrl,
|
|
clock.Today,
|
|
Titel: "Diploma",
|
|
Auteur: "zorgprofessional",
|
|
Taal: "nld",
|
|
Bestandsnaam: fileName,
|
|
Formaat: contentType,
|
|
Inhoud: content);
|
|
|
|
return gateway.StoreDocumentAsync(request, ct);
|
|
}
|
|
}
|