From 3e94b3dc59a991ffc209fdcd718e3f1cd9ce8cf9 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 6 Aug 2019 16:54:44 +0200 Subject: [PATCH] FIX count negative in stats whithcredit note --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 11cbfa9ff14..4b685af983d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2792,7 +2792,7 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(fd.qty) as qty"; + $sql.= " COUNT(fd.rowid) as nb_rows, SUM(CASE WHEN type != 2 THEN fd.qty ELSE -(fd.qty) END) as qty"; $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."societe as s";