diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index d40f00a9c42..887412bc6a4 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -815,7 +815,9 @@ if (! empty($conf->accounting->enabled) && ($modecompta == 'BOOKKEEPING')) $sql = "SELECT b.doc_ref, b.numero_compte, b.subledger_account, b.subledger_label, pcg_type, date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as debit, sum(b.credit) as credit, sum(b.montant) as amount"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_account as aa"; - $sql.= " WHERE b.numero_compte = aa.account_number AND b.entity = ".$conf->entity; + $sql.= " WHERE b.entity = ".$conf->entity; + $sql.= " AND aa.entity = ".$conf->entity; + $sql.= " AND b.numero_compte = aa.account_number"; $sql.= " AND ".$predefinedgroupwhere; $sql.= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'"; if (! empty($date_start) && ! empty($date_end)) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index cd17fbba233..c14bc46ad13 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -194,6 +194,7 @@ elseif ($modecompta=="BOOKKEEPING") $sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.credit) as amount_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj"; $sql.= " WHERE b.entity = ".$conf->entity; + $sql.= " AND aj.entity = ".$conf->entity; $sql.= " AND b.code_journal = aj.code AND aj.nature = 2" ; // @TODO currently count amount in sale journal, but we need to define a category group for turnover }