Merge pull request #11650 from ptibogxiv/patch-217

FIX count negative in stats with credit note
This commit is contained in:
Laurent Destailleur 2019-08-15 19:36:21 +02:00 committed by GitHub
commit 8a126800e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2788,11 +2788,10 @@ class Product extends CommonObject
public function load_stats_facture($socid = 0)
{
// phpcs:enable
global $conf;
global $user;
global $db, $conf, $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(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";