Try to complete fix

This commit is contained in:
Laurent Destailleur 2021-12-19 01:04:24 +01:00
parent 3282a89d3f
commit 477e9ddd4c

View File

@ -638,13 +638,15 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange
if ($j > 12) { if ($j > 12) {
$j -= 12; $j -= 12;
} }
$sql .= ' SUM('.$db->ifsql('MONTH(f.datef)='.$j, $sql .= " SUM(".$db->ifsql("MONTH(f.datef)=".$j,
' ('.$db->ifsql('fd.total_ht < 0', " (".$db->ifsql("fd.total_ht < 0",
' (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))', " (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
' (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))').')', " (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").")",
0).') AS month'.str_pad($j, 2, '0', STR_PAD_LEFT).','; 0).") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
} }
$sql .= " SUM((fd.total_ht-(fd.qty * fd.buy_price_ht))) as total"; $sql .= " SUM(".$db->ifsql("fd.total_ht < 0",
" (-1 * (abs(fd.total_ht) - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100))))",
" (fd.total_ht - (fd.buy_price_ht * fd.qty * (fd.situation_percent / 100)))").") as total";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture";