Skip to content

feat(mahnwesen): expose {FRIST}, {DATUMRECHNUNG}, {MAHNDATUM}, {TAGE} placeholders#271

Open
Avatarsia wants to merge 1 commit into
OpenXE-org:masterfrom
Avatarsia:mahnfenster
Open

feat(mahnwesen): expose {FRIST}, {DATUMRECHNUNG}, {MAHNDATUM}, {TAGE} placeholders#271
Avatarsia wants to merge 1 commit into
OpenXE-org:masterfrom
Avatarsia:mahnfenster

Conversation

@Avatarsia
Copy link
Copy Markdown
Contributor

Closes #270

Summary

  • Erweitert das Platzhalter-Mapping in MahnwesenMessage() um {FRIST}, {DATUMRECHNUNG}, {MAHNDATUM}, {TAGE} — Werte stammen aus den System-Einstellungen → Mahnwesen (mahnwesen.tage) und der rechnung-Tabelle.
  • Ersetzt das No-op if(\$tage<=0)\$tage=0; (Use-before-define) durch eine saubere Zuweisung \$tage = max(0, (int)\$rechnungarr['mahn_tage']).
  • Berechnet {FRIST} PHP-seitig (date('d.m.Y', strtotime(...))) statt DB-Roundtrip.
  • Guard für 0000-00-00 als Reset-Sentinel von mahnwesen_datum.

Diff

@@ -675,7 +675,12 @@ class Mahnwesen {
           \$offen = \$this->app->erp->GetSaldoDokument(\$rechnung_id, 'rechnung');
 
-          if(\$tage <=0) \$tage = 0;
+          \$tage = max(0, (int)\$rechnungarr['mahn_tage']);
+
+          \$mahnwesen_datum_valid = !empty(\$mahnwesen_datum) && \$mahnwesen_datum !== '0000-00-00';
+          \$frist_de = \$mahnwesen_datum_valid
+              ? date('d.m.Y', strtotime(\$mahnwesen_datum.' +'.\$tage.' days'))
+              : '';
@@ -726,6 +731,10 @@ class Mahnwesen {
             'datum' => \$datum_sql,
+            'datumrechnung' => \$datum_sql,
+            'frist' => \$frist_de,
+            'mahndatum' => \$mahnwesen_datum_deutsch,
+            'tage' => \$tage,

Code-Review

Drei Codex-Review-Runden durchlaufen:

  • Runde 1: Drei Blocker identifiziert ($datum_sql ist bereits deutsch, $tage nicht definiert, 0000-00-00-Guard fehlt) → adressiert
  • Runde 2: Use-before-define an Zeile 678 → adressiert (Konsolidierung an einer Stelle)
  • Runde 3: GO

Test plan

  • In den System-Einstellungen → Mahnwesen für eine Mahnstufe Tage und Gebühr setzen
  • Briefpapier-Vorlage z.B. mit Frist bis zum {FRIST} editieren
  • Mahnung manuell auslösen
  • Verifizieren: {FRIST} ist im versendeten Brief korrekt durch mahnwesen_datum + Tage ersetzt (deutsches Format dd.mm.yyyy)
  • Verifizieren: Andere bestehende Platzhalter ({DATUM}, {OFFEN}, {MAHNGEBUEHR}) funktionieren weiterhin
  • Edge-Case: Rechnung mit mahnwesen_datum = '0000-00-00'{FRIST} bleibt leer statt unsinniges Datum

Out of scope

  • Der parallele SQL-Injection-Bug in DokumentCreate (Escaping in class.erpapi.php:16041) wird in diesem PR nicht behandelt.
  • Deutscher Hinweistext in geschaeftsbrief_vorlagen.tpl für die neuen Platzhalter — kann in Folge-PR ergänzt werden.

🤖 Generated with Claude Code

Avatarsia pushed a commit to Avatarsia/OpenXE that referenced this pull request Apr 30, 2026
Adds the mahnfenster branch (upstream PR OpenXE-org#271) to the integration
manifest under "Upstream bug-fix PRs". Single-file fix to
www/pages/mahnwesen.php that exposes {FRIST}, {DATUMRECHNUNG},
{MAHNDATUM}, {TAGE} placeholders for dunning templates and
fixes a use-before-define on $tage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Avatarsia Avatarsia force-pushed the mahnfenster branch 2 times, most recently from bd43e58 to 61b3bf1 Compare May 7, 2026 20:18
@Avatarsia
Copy link
Copy Markdown
Contributor Author

Force-Push-Hinweis: Branch wurde direkt auf upstream/master rebased, sodass der Diff jetzt nur noch den eigentlichen Fix zeigt — ohne die ~150 Fork-internen Commits, die vorher mitliefen. Code-Endstand byte-identisch, nur die Commit-SHAs sind neu.

Bestehende Inline-Kommentare auf alten SHAs erscheinen jetzt als „outdated" — gerne nochmal kommentieren auf den neuen Commits, falls noch was offen ist.

Avatarsia pushed a commit to Avatarsia/OpenXE that referenced this pull request May 20, 2026
Adds the mahnfenster branch (upstream PR OpenXE-org#271) to the integration
manifest under "Upstream bug-fix PRs". Single-file fix to
www/pages/mahnwesen.php that exposes {FRIST}, {DATUMRECHNUNG},
{MAHNDATUM}, {TAGE} placeholders for dunning templates and
fixes a use-before-define on $tage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… placeholders

The mahnwesen template engine previously only exposed {DATUM}, {BELEGNR},
{OFFEN}, {MAHNGEBUEHR}, {HEUTE}, {RECHNUNG} via the ParseVars mapping.
The legacy block computing {DATUM*}/{TAGE}/{MAHNDATUM} is commented out,
so dunning templates referencing a calendar-bound deadline ("bis zum X")
had no working placeholder for the deadline date.

This adds:
- {FRIST}        = mahnwesen_datum + mahn_tage (mahnwesen.tage from system
                   settings), formatted dd.mm.yyyy
- {DATUMRECHNUNG} = invoice date (alias to {DATUM} for clarity)
- {MAHNDATUM}    = current dunning issue date in dd.mm.yyyy
- {TAGE}         = configured grace days for the current dunning level

Also fixes a use-before-define on $tage at line 678 by replacing the
no-op `if($tage<=0)$tage=0;` with a single `max(0,(int)mahn_tage)`
assignment that pulls from the mahnwesen table (system settings).

Guards 0000-00-00 mahnwesen_datum to avoid bogus future-date arithmetic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mahnwesen: fehlende Platzhalter {FRIST}, {DATUMRECHNUNG}, {MAHNDATUM}, {TAGE}

1 participant