Fix: Exclude deposit invoices from reports

This commit is contained in:
Laurent Destailleur 2011-02-22 09:11:10 +00:00
parent d7ea931590
commit e24c9fa076

View File

@ -212,6 +212,10 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
$sql.= " AND f.rowid = d.".$fk_facture;
if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
@ -249,6 +253,10 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
$sql.= " AND f.rowid = d.".$fk_facture;
// $sql.= " AND pf.".$fk_facture2." = f.rowid";
// $sql.= " AND pa.rowid = pf.".$fk_payment;
@ -349,6 +357,10 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Validated or paid (partially or completely)
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
$sql.= " AND f.rowid = d.".$fk_facture;
if ($y) $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
@ -386,7 +398,11 @@ function vat_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction,
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (1,2)"; // Paid (partially or completely)
$sql.= " AND f.rowid = d.".$fk_facture;;
$sql.= " AND (f.type = 0"; // Standard
$sql.= " OR f.type = 1"; // Replacement
$sql.= " OR f.type = 2)"; // Credit note
//$sql.= " OR f.type = 3"; // We do not include deposit
$sql.= " AND f.rowid = d.".$fk_facture;;
$sql.= " AND pf.".$fk_facture2." = f.rowid";
$sql.= " AND pa.rowid = pf.".$fk_payment;
if ($y) $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";