From 0f98572c2b614747d9931fd4fe057326c85dff81 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Wed, 25 Oct 2017 14:04:36 +0200 Subject: [PATCH] FIX Filter didn't work for credit note Modify the SQL request to be able to filter on credit note --- htdocs/societe/class/api_thirdparties.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index c7b6d882514..9adc76462f5 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -369,11 +369,11 @@ class Thirdparties extends DolibarrApi } - $sql = "SELECT f.facnumber, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture"; + $sql = "SELECT f.facnumber, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line"; $sql .= " FROM llx_societe_remise_except as re, llx_facture as f"; $sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id; - if ($filter == "available") $sql .= " AND re.fk_facture IS NULL"; - if ($filter == "used") $sql .= " AND re.fk_facture IS NOT NULL"; + if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL"; + if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)"; $sql.= $this->db->order($sortfield, $sortorder);