diff --git a/htdocs/lib/tax.lib.php b/htdocs/lib/tax.lib.php index b6d1ff71b38..c9cfc2e3a00 100644 --- a/htdocs/lib/tax.lib.php +++ b/htdocs/lib/tax.lib.php @@ -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'";