forked from Wavyzz/dolibarr
NEW VAT rate - Add entity
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* Copyright (C) 2012-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2012-2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2014-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014-2023 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2018-2022 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
@@ -6301,6 +6301,7 @@ class Form
|
||||
$sql .= " FROM " . $this->db->prefix() . "c_tva as t, " . $this->db->prefix() . "c_country as c";
|
||||
$sql .= " WHERE t.fk_pays = c.rowid";
|
||||
$sql .= " AND t.active > 0";
|
||||
$sql .= " AND t.entity IN (".getEntity('c_tva').")";
|
||||
$sql .= " AND c.code IN (" . $this->db->sanitize($country_code, 1) . ")";
|
||||
$sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
|
||||
|
||||
|
||||
@@ -6225,6 +6225,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_sell
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdparty_seller->country_code)."'";
|
||||
$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
|
||||
$sql .= " AND t.entity IN (".getEntity('c_tva').")";
|
||||
if (!empty($vatratecode)) {
|
||||
$sql .= " AND t.code ='".$db->escape($vatratecode)."'"; // If we have the code, we use it in priority
|
||||
} else {
|
||||
@@ -6281,9 +6282,9 @@ function get_localtax_by_third($local)
|
||||
|
||||
$sql = " SELECT t.localtax".$local." as localtax";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux = (";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.entity IN (".getEntity('c_tva').") AND t.taux = (";
|
||||
$sql .= "SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = tt.fk_pays";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1)";
|
||||
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.entity IN (".getEntity('c_tva').") AND tt.active = 1)";
|
||||
$sql .= " AND t.localtax".$local."_type <> '0'";
|
||||
$sql .= " ORDER BY t.rowid DESC";
|
||||
|
||||
@@ -6338,6 +6339,7 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid
|
||||
else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'";*/
|
||||
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($seller->country_code)."'";
|
||||
$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
|
||||
$sql .= " AND t.entity IN (".getEntity('c_tva').")";
|
||||
if ($vatratecode) {
|
||||
$sql .= " AND t.code = '".$db->escape($vatratecode)."'";
|
||||
}
|
||||
@@ -6494,6 +6496,7 @@ function get_product_vat_for_country($idprod, $thirdpartytouse, $idprodfournpric
|
||||
$sql = "SELECT t.taux as vat_rate, t.code as default_vat_code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql .= " WHERE t.active = 1 AND t.fk_pays = c.rowid AND c.code = '".$db->escape($thirdpartytouse->country_code)."'";
|
||||
$sql .= " AND t.entity IN (".getEntity('c_tva').")";
|
||||
$sql .= " ORDER BY t.use_default DESC, t.taux DESC, t.code ASC, t.recuperableonly ASC";
|
||||
$sql .= $db->plimit(1);
|
||||
|
||||
@@ -6573,6 +6576,7 @@ function get_product_localtax_for_country($idprod, $local, $thirdpartytouse)
|
||||
$sql = "SELECT taux as vat_rate, localtax1, localtax2";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
|
||||
$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($thirdpartytouse->country_code)."'";
|
||||
$sql .= " AND t.entity IN (".getEntity('c_tva').")";
|
||||
$sql .= " ORDER BY t.taux DESC, t.recuperableonly ASC";
|
||||
$sql .= $db->plimit(1);
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as cv";
|
||||
$sql .= " WHERE cv.taux = ".((float) $txtva);
|
||||
$sql .= " AND cv.fk_pays = ".((int) $countryid);
|
||||
$sql .= " AND cv.entity IN (".getEntity('c_tva').")";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
Reference in New Issue
Block a user