From b20e1eb0c182f68626efb92463f614f207ef4735 Mon Sep 17 00:00:00 2001 From: atm-jonathan Date: Tue, 16 Jun 2026 11:37:16 +0200 Subject: [PATCH 1/2] FIX : DA028241 - FactureLigne::getSituationRatio() - wrong denominator in mode 1 situation invoices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In INVOICE_USE_SITUATION=1 (legacy cumulative mode), total_ht is stored as subprice * qty * situation_percent / 100. The ratio to extract the period delta must therefore be (sp - pp) / sp, not (sp - pp) / 100. The wrong denominator caused pdf_getlinetotalexcltax() to display incorrect values in the 'Total HT sit. n°X' column for lines where situation_percent != 100. --- htdocs/compta/facture/class/factureligne.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/factureligne.class.php b/htdocs/compta/facture/class/factureligne.class.php index 5271789b92dcd..c8134eb8af9c6 100644 --- a/htdocs/compta/facture/class/factureligne.class.php +++ b/htdocs/compta/facture/class/factureligne.class.php @@ -996,12 +996,15 @@ public function getAllPrevProgress($invoiceid, $include_credit_note = true) public function getSituationRatio() { if (getDolGlobalInt('INVOICE_USE_SITUATION') === 1) { - // in legacy mode, the situation invoice line stores the (cumulative) state of the - // cycle at the current situation. To get the delta, we need to subtract the - // state at the previous situation (if applicable). + // Legacy mode: line stores the cumulative state (e.g. 70%). To get the delta ratio + // we divide by situation_percent, not by 100 — because total_ht is already scaled + // by situation_percent/100, so the multiplier must cancel that factor out. + if (empty($this->situation_percent)) { + return 0; + } $prevProgress = $this->get_prev_progress($this->fk_facture); - return ($this->situation_percent - $prevProgress) / 100; + return ($this->situation_percent - $prevProgress) / $this->situation_percent; } // new mode (INVOICE_USE_SITUATION == 2): // no ratio needed (data stored on line is already a delta) From 7b039016c44c969a9b1cd86595cce0829d1da6f0 Mon Sep 17 00:00:00 2001 From: atm-jonathan Date: Thu, 18 Jun 2026 16:33:35 +0200 Subject: [PATCH 2/2] FIX : DA028241 - update ChangeLog_loukta --- ChangeLog_loukta | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog_loukta b/ChangeLog_loukta index 5a304a2ac7161..f5ea567bac3c3 100644 --- a/ChangeLog_loukta +++ b/ChangeLog_loukta @@ -1,4 +1,5 @@ ***** 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* - 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*