From 26dc3ef1b0aacae520e86824e096a03073db205f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 16 Mar 2021 18:56:10 +0100 Subject: [PATCH] FIX Filter on debit/credit Conflicts: htdocs/compta/bank/bankentries_list.php --- htdocs/compta/bank/bankentries_list.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 63021eb3b07..7abd2c6a2b7 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -515,13 +515,17 @@ if ($search_description) } $sql .= natural_search("b.label", $search_description_to_use); // Warning some text are just translation keys, not translated strings } -if ($search_bid > 0) $sql .= " AND b.rowid=l.lineid AND l.fk_categ=".$search_bid; -if (!empty($search_type)) $sql .= " AND b.fk_type = '".$db->escape($search_type)."' "; +if ($search_bid > 0) $sql .= " AND b.rowid=l.lineid AND l.fk_categ=".((int) $search_bid); +if (!empty($search_type)) $sql .= " AND b.fk_type = '".$db->escape($search_type)."'"; // Search criteria amount -$search_debit = price2num(str_replace('-', '', $search_debit)); -$search_credit = price2num(str_replace('-', '', $search_credit)); -if ($search_debit) $sql .= natural_search('- b.amount', $search_debit, 1); -if ($search_credit) $sql .= natural_search('b.amount', $search_credit, 1); +if ($search_debit) { + $sql .= natural_search('ABS(b.amount)', $search_debit, 1); + $sql .= ' AND b.amount <= 0'; +} +if ($search_credit) { + $sql .= natural_search('b.amount', $search_credit, 1); + $sql .= ' AND b.amount >= 0'; +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';