From 04329c38b317d0ecf4a7829ca423206b0590dda0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 11 Sep 2020 06:42:22 +0200 Subject: [PATCH] FIX - Accountancy balance Error SQL on entity --- htdocs/accountancy/bookkeeping/balance.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 456da29d954..ee51560818f 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -267,8 +267,12 @@ if ($action != 'export_csv') $sous_total_credit = 0; $displayed_account = ""; - $sql = "select t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance from ".MAIN_DB_PREFIX."accounting_bookkeeping as t where entity in ".$conf->entity; - $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."' GROUP BY t.numero_compte"; + $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; + $sql .= " WHERE t.entity IN (".getEntity('accountancy').")"; + $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; + $sql .= " GROUP BY t.numero_compte"; + $resql = $db->query($sql); $nrows = $resql->num_rows; $opening_balances = array(); @@ -289,10 +293,10 @@ if ($action != 'export_csv') } print ''; - // Permet d'afficher le compte comptable + // Display the accounting account if (empty($displayed_account) || $root_account_description != $displayed_account) { - // Affiche un Sous-Total par compte comptable + // Display a sub-total per account if ($displayed_account != "") { print ''.$langs->trans("SubTotal").':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_credit - $sous_total_debit)).''; print " \n"; @@ -321,7 +325,7 @@ if ($action != 'export_csv') print ''; print "\n"; - // Comptabilise le sous-total + // Records the sub-total $sous_total_debit += $line->debit; $sous_total_credit += $line->credit; }