Backlog t78 (release blocker for the Leistungsbeschreibungen / contract documents). AGB § 10 Abs. 1 allows restricting access only "trotz Mahnung und angemessener Nachfrist". The owner decided on 06.11.: read-only at the earliest 14 days after the Mahnung, suspension after a further 14 days, export stays available (§ 10 Abs. 3).
Before
sales_invoice.overdue webhook and reconcile: restricted from 14 days after the due date, halted from 30.
Any warning escalated to restricted after 14 days by time alone.
After
Overdue invoice without a Mahnung:warning only, however long overdue. The webhook path is capped at warning too.
Mahnung: the reconcile pass (every 15 min) reads the customer's submitted, unresolved ERPNext Dunnings (docstatus=1, status != Resolved). The earliest one that names a still-open overdue invoice (overdue_payments[].sales_invoice) sets the clock:
restricted (read-only) ERP_RESTRICT_AFTER_DAYS (14) after its posting_date;
halted by the existing timer a further 14 days after the restriction (ERP_HALT_AFTER_DAYS default 30 → 28).
A Mahnung never halts directly. A tenant is always read-only first, so a Mahnung seen late (back-dated, or ERPNext unreachable) errs in the customer's favour.
Mahnungen that don't count: a Mahnung for paid invoices, a draft, and a resolved one.
A failed Dunning read keeps the tenant on warning and shows up in the reconcile report (<slug>: erp dunnings: …).
No longer generated: the grace_over warning → restricted step. Old audit sources are still recognised for the settle-back path.
Day counting: days are counted as calendar days in Europe/Berlin, rounded, so a DST switch doesn't lose a day.
Field names and permissions were checked against ERPNext v15 dunning.json / overdue_payment.json:
customer, posting_date, status (Draft/Resolved/Unresolved/Cancelled), overdue_payments → Overdue Payment.sales_invoice;
Accounts User (held by the registry's API user) has read.
Side effect
Expired trials are now read-only for 14 days instead of 16 before they are halted (same spacing as late payment).
Before prod
One read-only GET /api/resource/Dunning as the registry's API user on the live ERP, to confirm access. Staging runs the mock, so stage can't prove this.
List the tenants in warning/restricted on prod. One restricted under the old due-date rule would still be halted by the timer without a Mahnung.
ERP has no Dunning Type or Mahnung letter yet. Until Mahnungen are issued in ERPNext, nobody gets restricted for late payment. Plattform LB § 9(2) says the Mahnung names the consequences, so the letter text is a follow-up for the owner.
The customer texts (product-docs billing table, portal status notes) describing this rule should go to prod together with or after this change, not before.
Tests
TestOverdueStep: no Mahnung, Mahnung 13/14/40 days, never halted directly.
TestReconcile_overdueInvoicesDriveTheLadder: 40 days overdue without a Mahnung stays warning; a draft, a resolved Mahnung and one for a paid invoice don't count; a Mahnung 13 days ago stays warning, 14 days ago → restricted (read-only); a paid invoice → active.
Backlog t78 (release blocker for the Leistungsbeschreibungen / contract documents). AGB § 10 Abs. 1 allows restricting access only "trotz Mahnung und angemessener Nachfrist". The owner decided on 06.11.: read-only at the earliest 14 days after the Mahnung, suspension after a further 14 days, export stays available (§ 10 Abs. 3).
## Before
- `sales_invoice.overdue` webhook and reconcile: restricted from 14 days after the **due date**, halted from 30.
- Any `warning` escalated to `restricted` after 14 days by time alone.
## After
- **Overdue invoice without a Mahnung:** `warning` only, however long overdue. The webhook path is capped at warning too.
- **Mahnung:** the reconcile pass (every 15 min) reads the customer's submitted, unresolved ERPNext **Dunnings** (`docstatus=1`, `status != Resolved`). The earliest one that names a still-open overdue invoice (`overdue_payments[].sales_invoice`) sets the clock:
- `restricted` (read-only) `ERP_RESTRICT_AFTER_DAYS` (14) after its `posting_date`;
- `halted` by the existing timer a further 14 days after the restriction (`ERP_HALT_AFTER_DAYS` default 30 → **28**).
- **A Mahnung never halts directly.** A tenant is always read-only first, so a Mahnung seen late (back-dated, or ERPNext unreachable) errs in the customer's favour.
- **Mahnungen that don't count:** a Mahnung for paid invoices, a draft, and a resolved one.
- **A failed Dunning read** keeps the tenant on warning and shows up in the reconcile report (`<slug>: erp dunnings: …`).
- **No longer generated:** the `grace_over` warning → restricted step. Old audit sources are still recognised for the settle-back path.
- **Day counting:** days are counted as calendar days in Europe/Berlin, rounded, so a DST switch doesn't lose a day.
Field names and permissions were checked against ERPNext v15 `dunning.json` / `overdue_payment.json`:
- `customer`, `posting_date`, `status` (Draft/Resolved/Unresolved/Cancelled), `overdue_payments` → `Overdue Payment.sales_invoice`;
- **Accounts User** (held by the registry's API user) has read.
## Side effect
Expired trials are now read-only for **14 days instead of 16** before they are halted (same spacing as late payment).
## Before prod
- One read-only `GET /api/resource/Dunning` as the registry's API user on the live ERP, to confirm access. Staging runs the mock, so stage can't prove this.
- List the tenants in `warning`/`restricted` on prod. One restricted under the old due-date rule would still be halted by the timer without a Mahnung.
- ERP has no Dunning Type or Mahnung letter yet. Until Mahnungen are issued in ERPNext, nobody gets restricted for late payment. Plattform LB § 9(2) says the Mahnung names the consequences, so the letter text is a follow-up for the owner.
- The customer texts (product-docs billing table, portal status notes) describing this rule should go to prod together with or after this change, not before.
## Tests
- `TestOverdueStep`: no Mahnung, Mahnung 13/14/40 days, never halted directly.
- `TestReconcile_overdueInvoicesDriveTheLadder`: 40 days overdue without a Mahnung stays warning; a draft, a resolved Mahnung and one for a paid invoice don't count; a Mahnung 13 days ago stays warning, 14 days ago → restricted (read-only); a paid invoice → active.
- `TestReconcile_dunningReadFailureStaysWarning`: Dunning 403 → warning, error reported.
- `TestReconcile_ladderEscalation`: a warning no longer escalates by time; trial read-only 13 days → still restricted, 14 → halted.
- `go test ./...`, `go vet`, golangci-lint: clean.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
AGB § 10 allows restricting access only "trotz Mahnung und angemessener
Nachfrist". The ladder counted from the due date (restricted after 14,
halted after 30 days overdue) and escalated any warning after 14 days.
Now an overdue invoice alone means warning. The reconcile pass reads the
customer's submitted, unresolved ERPNext Dunnings; the earliest one that
names a still-open invoice sets the clock: restricted 14 days after its
posting date, halted a further 14 days after the restriction. A Mahnung
never halts directly, so a late-seen one errs in the customer's favour.
A failed Dunning read keeps the tenant on warning and is reported.
ERP_HALT_AFTER_DAYS defaults to 28 (was 30), so an expired trial is
read-only for 14 days instead of 16 before it is halted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CODEOWNERS rules
requested review from Benjamin_Boenisch 2026-11-17 08:04:12 +00:00
sharang
merged commit 2f0d2f035a into main2026-11-17 08:23:54 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Backlog t78 (release blocker for the Leistungsbeschreibungen / contract documents). AGB § 10 Abs. 1 allows restricting access only "trotz Mahnung und angemessener Nachfrist". The owner decided on 06.11.: read-only at the earliest 14 days after the Mahnung, suspension after a further 14 days, export stays available (§ 10 Abs. 3).
Before
sales_invoice.overduewebhook and reconcile: restricted from 14 days after the due date, halted from 30.warningescalated torestrictedafter 14 days by time alone.After
warningonly, however long overdue. The webhook path is capped at warning too.docstatus=1,status != Resolved). The earliest one that names a still-open overdue invoice (overdue_payments[].sales_invoice) sets the clock:restricted(read-only)ERP_RESTRICT_AFTER_DAYS(14) after itsposting_date;haltedby the existing timer a further 14 days after the restriction (ERP_HALT_AFTER_DAYSdefault 30 → 28).<slug>: erp dunnings: …).grace_overwarning → restricted step. Old audit sources are still recognised for the settle-back path.Field names and permissions were checked against ERPNext v15
dunning.json/overdue_payment.json:customer,posting_date,status(Draft/Resolved/Unresolved/Cancelled),overdue_payments→Overdue Payment.sales_invoice;Side effect
Expired trials are now read-only for 14 days instead of 16 before they are halted (same spacing as late payment).
Before prod
GET /api/resource/Dunningas the registry's API user on the live ERP, to confirm access. Staging runs the mock, so stage can't prove this.warning/restrictedon prod. One restricted under the old due-date rule would still be halted by the timer without a Mahnung.Tests
TestOverdueStep: no Mahnung, Mahnung 13/14/40 days, never halted directly.TestReconcile_overdueInvoicesDriveTheLadder: 40 days overdue without a Mahnung stays warning; a draft, a resolved Mahnung and one for a paid invoice don't count; a Mahnung 13 days ago stays warning, 14 days ago → restricted (read-only); a paid invoice → active.TestReconcile_dunningReadFailureStaysWarning: Dunning 403 → warning, error reported.TestReconcile_ladderEscalation: a warning no longer escalates by time; trial read-only 13 days → still restricted, 14 → halted.go test ./...,go vet, golangci-lint: clean.🤖 Generated with Claude Code