FIX invoice filter

This commit is contained in:
John 2018-03-22 11:37:16 +01:00
parent fd86e90df2
commit b4983d0e6d

View File

@ -3500,13 +3500,12 @@ class Facture extends CommonInvoice
$sqlSit = 'SELECT MAX(fs.rowid)';
$sqlSit.= " FROM ".MAIN_DB_PREFIX."facture as fs";
$sqlSit.= " WHERE fs.entity = ".$conf->entity;
$sqlSit.= " AND fs.type != ".self::TYPE_SITUATION;
$sqlSit.= " AND fs.type = ".self::TYPE_SITUATION;
$sqlSit.= " AND fs.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")";
$sqlSit.= " GROUP BY fs.situation_cycle_ref";
$sqlSit.= " ORDER BY fs.situation_counter";
$sql = "SELECT f.rowid as rowid, f.facnumber, f.fk_statut, f.type, f.paye, pf.fk_paiement";
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
@ -3518,7 +3517,7 @@ class Facture extends CommonInvoice
// $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
$sql.= " AND f.type != ".self::TYPE_CREDIT_NOTE; // Type non 2 si facture non avoir
//$sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir
$sql.= " AND ( f.type != ".self::TYPE_SITUATION . " OR f.rowid IN (".$sqlSit.") )"; // Type non 5 si facture non avoir
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
$sql.= " ORDER BY f.facnumber";