From e9e526c0320561d7f8d1e403fd064be331c978ea Mon Sep 17 00:00:00 2001 From: Jam Balaya Date: Sun, 19 Jul 2026 22:45:45 +0900 Subject: [PATCH] FIX #35658 leading-zero account numbers dropped from personalized group totals (#39208) In compta/resultat/result.php and clientfourn.php the account number was cast to (int) before being passed to AccountancyCategory::getSumDebitCredit(), which compares it as a string (t.numero_compte = '...'). (int) '0510' -> 510 -> '510' never matches the stored '0510' (numero_compte and account_number are varchar(32), so leading zeros are significant). Accounts whose code starts with 0 were therefore silently excluded from the current-year and per-month totals of a personalized account group, while the previous-year column was already correct because it passes a string array. The (int) cast had no functional purpose: it was added to silence a phan notice in "Qual: Fix phan notices" (#33484). Remove it and pass the raw string, and widen the getSumDebitCredit() @param to string|int|array so the string argument is accepted by static analysis and the cast is not reintroduced. Numeric codes are unaffected (the callee already casts the scalar with (string)). --- htdocs/accountancy/class/accountancycategory.class.php | 2 +- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/compta/resultat/result.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 2c0d985e41e..0f028eb8781 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -624,7 +624,7 @@ class AccountancyCategory // extends CommonObject /** * Function to set the property ->sdc (and ->sdcperaccount) that is the result of an accounting account from the ledger with a direction and a period * - * @param int|array $cpt Accounting account or array of accounting account + * @param string|int|array $cpt Accounting account or array of accounting account * @param int $date_start Date start * @param int $date_end Date end * @param int<0,1> $sens Sens of the account: 0: credit - debit (use this by default), 1: debit - credit diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 66a5130787e..f2de46762cf 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -386,7 +386,7 @@ if ($modecompta == 'BOOKKEEPING') { $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere); foreach ($cpts as $j => $cpt) { - $return = $AccCat->getSumDebitCredit((int) $cpt['account_number'], $date_start, $date_end, (empty($cpt['dc']) ? 0 : $cpt['dc'])); + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, (empty($cpt['dc']) ? 0 : $cpt['dc'])); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultN = 0; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 09328db8ca3..57209912ec3 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -560,7 +560,7 @@ if ($modecompta == 'CREANCES-DETTES') { ) { //var_dump($monthtoprocess.'_'.$yeartoprocess); if (isset($cpt['account_number'])) { - $return = $AccCat->getSumDebitCredit((int) $cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess); + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultM = 0;