NEW Vat report - Invert constant to show by default zero vat in reports

This commit is contained in:
Alexandre SPANGARO 2020-10-05 20:52:31 +02:00
parent afd6da3b94
commit d83d9895e0
2 changed files with 12 additions and 10 deletions

View File

@ -170,7 +170,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 0"; // Limit to products
$sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
@ -208,7 +208,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 0"; // Limit to products
$sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
}
@ -312,7 +312,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 1"; // Limit to services
$sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
@ -350,7 +350,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 1"; // Limit to services
$sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
}
@ -451,7 +451,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di
if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = -1";
$sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
$sql .= " ORDER BY e.rowid";
if (!$sql)
@ -622,7 +622,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 0"; // Limit to products
$sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
@ -660,7 +660,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 0"; // Limit to products
$sql .= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
}
@ -764,7 +764,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 1"; // Limit to services
$sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture;
} else {
// Count on payments date
@ -802,7 +802,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql .= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = 1"; // Limit to services
$sql .= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)";
$sql .= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
}
@ -903,7 +903,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire
if ($date_start && $date_end) $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
$sql .= " AND (d.product_type = -1";
$sql .= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service
if (empty($conf->global->MAIN_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
if (!empty($conf->global->MAIN_NOT_INCLUDE_ZERO_VAT_IN_REPORTS)) $sql .= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)";
$sql .= " ORDER BY e.rowid";
if (!$sql)

View File

@ -355,3 +355,5 @@ CREATE TABLE llx_ecm_directories_extrafields
ALTER TABLE llx_ecm_directories_extrafields ADD INDEX idx_ecm_directories_extrafields (fk_object);
ALTER TABLE llx_website_page ADD COLUMN object_type varchar(255);
ALTER TABLE llx_website_page ADD COLUMN fk_object varchar(255);
DELETE FROM llx_const WHERE name in ('MAIN_INCLUDE_ZERO_VAT_IN_REPORTS');