From e07303d1bfbac179663bd83a166ea276573be823 Mon Sep 17 00:00:00 2001 From: atm-nicolasV Date: Fri, 19 Jun 2026 15:44:36 +0200 Subject: [PATCH 1/2] DOC : DA028241 - document core-patch debt and credit-note scope limitation of getSituationRatio() Make explicit, in the getSituationRatio() docblock and in ChangeLog_loukta, two things flagged during PR #748 review: - O3 (core debt): this method + its consumers in core/lib/pdf.lib.php are a Loukta-local backport of upstream PR Dolibarr#36503 and will be overwritten on the next core upgrade; drop them once #36503 lands upstream. - O4 (scope): the fix only corrects the mode-1 denominator and does NOT handle credit notes (get_prev_progress() still adds credit-note percents), so a situation cycle containing a credit note may still yield a wrong/negative delta. Documentation only, no logic change. Co-Authored-By: Claude Opus 4.8 (1M context) --- ChangeLog_loukta | 1 + htdocs/compta/facture/class/factureligne.class.php | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog_loukta b/ChangeLog_loukta index f5ea567bac3c3..1c92d8430e4f4 100644 --- a/ChangeLog_loukta +++ b/ChangeLog_loukta @@ -1,5 +1,6 @@ ***** ChangeLog for loukta ***** - FIX DA028241 - FactureLigne::getSituationRatio() - wrong denominator (100 instead of situation_percent) in mode 1 caused incorrect line amounts in situation invoice PDFs. - *18/06/2026* +- NOTE DA028241 - getSituationRatio() is a LOCAL CORE PATCH (factureligne.class.php + core/lib/pdf.lib.php), overwritten on each Dolibarr core upgrade; to be dropped once upstream PR Dolibarr#36503 lands. Scope is the mode-1 denominator only - credit notes in a situation cycle are NOT handled (get_prev_progress() still adds credit-note percents), so such a cycle may still yield a wrong/negative delta. - *19/06/2026* - FIX DA027405 - merging PR Dolibarr#36503 in advance for Loukta: PDF for situation invoices uses legacy calculations (cumulative) instead of the new algorithm (delta). Once the community PR is merged, this specific code can be discarded and replaced with the community equivalent. - *03/12/2025* diff --git a/htdocs/compta/facture/class/factureligne.class.php b/htdocs/compta/facture/class/factureligne.class.php index c8134eb8af9c6..e481d4f2b3f9b 100644 --- a/htdocs/compta/facture/class/factureligne.class.php +++ b/htdocs/compta/facture/class/factureligne.class.php @@ -991,6 +991,17 @@ public function getAllPrevProgress($invoiceid, $include_credit_note = true) * New mode = the values on the line already represent the delta between the previous * state and the current state, so we don't need a conversion (we return 1). * + * LOCAL CORE PATCH (technical debt) — DA027405 / DA028241: + * This method and its consumers in core/lib/pdf.lib.php are a Loukta-local backport of + * upstream PR Dolibarr#36503. They modify core files and WILL be overwritten on the next + * Dolibarr core upgrade — re-apply, or preferably drop them, once #36503 is merged upstream. + * + * SCOPE LIMITATION — DA028241: + * This fix only corrects the mode-1 denominator. It does NOT handle credit notes: in + * get_prev_progress() the credit-note percents are still ADDED (+=) to the previous + * progress, so a situation cycle that contains a credit note can still produce a wrong + * (possibly negative) delta here. Credit-note progression is tracked separately. + * * @return int */ public function getSituationRatio() From f4599e819f6ea4901819fdc2dfc2e93b51bea0d7 Mon Sep 17 00:00:00 2001 From: atm-nicolasV Date: Fri, 19 Jun 2026 16:03:20 +0200 Subject: [PATCH 2/2] CHORE : DA028241 - wrap getSituationRatio() with LOUKTA START/END markers Bracket the whole getSituationRatio() method (added as a Loukta-local core backport of upstream PR Dolibarr#36503) with: // LOUKTA DA028241 - START ... // LOUKTA DA028241 - END so the local core patch can be located and removed in one block on the next Dolibarr core upgrade. The markers also cover the previously-merged PR #748 denominator change, which was not wrapped. Comment-only, no logic change. Committed with --no-verify (claudemd gate blocks on missing root CLAUDE.md; bypass authorized by user). Co-Authored-By: Claude Opus 4.8 (1M context) --- htdocs/compta/facture/class/factureligne.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture/class/factureligne.class.php b/htdocs/compta/facture/class/factureligne.class.php index e481d4f2b3f9b..2339b03a53286 100644 --- a/htdocs/compta/facture/class/factureligne.class.php +++ b/htdocs/compta/facture/class/factureligne.class.php @@ -980,6 +980,7 @@ public function getAllPrevProgress($invoiceid, $include_credit_note = true) } } + // LOUKTA DA028241 - START /** * Determines if we are using situation invoices. * If so, determines if we are using the new mode (2) or legacy mode (1). @@ -1022,4 +1023,5 @@ public function getSituationRatio() // or not a situation invoice: no ratio needed either return 1; } + // LOUKTA DA028241 - END }