From 743da5a2140f26454725e72125c62aa2bf65e9fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 May 2013 21:33:48 +0200 Subject: [PATCH] Fix: function to get localtax1 or 2 value from vat rate return bad value when countries differs. Conflicts: htdocs/langs/fr_CA/main.lang --- htdocs/core/lib/functions.lib.php | 12 +++++++----- htdocs/core/lib/price.lib.php | 6 ++++-- htdocs/langs/fr_CA/admin.lang | 18 ++++++++++++++++++ htdocs/langs/fr_CA/companies.lang | 7 +++++++ htdocs/langs/fr_CA/main.lang | 11 ++++++++++- 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 htdocs/langs/fr_CA/admin.lang create mode 100644 htdocs/langs/fr_CA/companies.lang diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 531fb2f52fa..2b461206f2d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2793,7 +2793,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") if (empty($thirdparty_seller) || ! is_object($thirdparty_seller)) $thirdparty_seller=$mysoc; - dol_syslog("get_localtax tva=".$tva." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')." thirdparty_seller id=".$thirdparty_seller->id); + dol_syslog("get_localtax tva=".$tva." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer)?$thirdparty_buyer->id:'')."/country_code=".(is_object($thirdparty_buyer)?$thirdparty_buyer->country_code:'')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj." thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj); // Some test to guess with no need to make database access if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe @@ -2819,16 +2819,18 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="") } //if ($local == 0 && ! $thirdparty_seller->localtax1_assuj && ! $thirdparty_seller->localtax2_assuj) return array('localtax1'=>0,'localtax2'=>0); - $code_country=$thirdparty_seller->country_code; + // Do not enabled this. We want localtax that match the vat rate. + // If we forced a vat, we must also force local tax + /* if (is_object($thirdparty_buyer)) { - if ($code_country != $thirdparty_buyer->country_code) return 0; - } + if ($thirdparty_seller->country_code != $thirdparty_buyer->country_code) return 0; + }*/ // Search local taxes $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$code_country."'"; + $sql .= " WHERE t.fk_pays = p.rowid AND p.code = '".$thirdparty_seller->country_code."'"; $sql .= " AND t.taux = ".$tva." AND t.active = 1"; dol_syslog("get_localtax sql=".$sql); diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index c3af3e2e973..5b4fbee52ff 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -79,7 +79,9 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $seller=$mysoc; // If sell is done to a customer, $seller is not provided, we use $mysoc //var_dump($seller->country_id);exit; } - + // Too verbose. Enable for debug only + //dol_syslog("calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate); + $countryid=$seller->country_id; if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -91,7 +93,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 = ".$txtva; $sql.= " AND cv.fk_pays = ".$countryid; - dol_syslog("search vat information sql=".$sql); + dol_syslog("calcul_price_total search vat information sql=".$sql); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/langs/fr_CA/admin.lang b/htdocs/langs/fr_CA/admin.lang new file mode 100644 index 00000000000..69e2630bc9c --- /dev/null +++ b/htdocs/langs/fr_CA/admin.lang @@ -0,0 +1,18 @@ +# Dolibarr language file - Source file is en_US - admin +CHARSET=UTF-8 +VATManagement=Gestion TPS +VATIsUsedDesc=Le taux de TPS proposé par défaut lors de la création de proposition commerciale, facture, commande, etc... répond à la règle standard suivante :
Si vendeur non assujetti à TPS, TPS par défaut=0. Fin de règle.
Si le (pays vendeur= pays acheteur) alors TPS par défaut=TPS du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TPS par défaut=0 (La TPS doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TPS par défaut=TPS du produit vendu. Fin de règle.
Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TPS par défaut=0. Fin de règle.
Sinon TPS proposée par défaut=0. Fin de règle.
+VATIsNotUsedDesc=Le taux de TPS proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés. +VATIsUsedExampleFR=En France, il s'agit des sociétés ou organismes ayant choisi un régime fiscale réel (Réel simplifié ou Réel normal), régime dans lequel la TVA est déclarée. +VATIsNotUsedExampleFR=En France, il s'agit des associations ne déclarant pas de TVA ou sociétés, organismes ou professions libérales ayant choisi le régime fiscal micro entreprise (TVA en franchise) et payant une TVA en franchise sans faire de déclaration de TVA. Ce choix fait de plus apparaître la mention "TVA non applicable - art-293B du CGI" sur les factures. +##### Local Taxes ##### +LocalTax1IsUsed=Assujeti +LocalTax1IsNotUsed=Non assujeti +LocalTax1IsUsedDesc=Utilisation de 2ème type taxe (TVQ) +LocalTax1IsNotUsedDesc=Pas d'utilisation de 2ème type taxe (TVQ) +LocalTax1Management=Gestion TVQ +LocalTax1ManagementCA= Gestion TVQ +LocalTax1IsUsedDescCA= +LocalTax1IsNotUsedDescCA= +LocalTax1IsUsedExampleCA= +LocalTax1IsNotUsedExampleCA= diff --git a/htdocs/langs/fr_CA/companies.lang b/htdocs/langs/fr_CA/companies.lang new file mode 100644 index 00000000000..b3028ccfe5a --- /dev/null +++ b/htdocs/langs/fr_CA/companies.lang @@ -0,0 +1,7 @@ +# Dolibarr language file - en_US - companies +CHARSET=UTF-8 +VATIsUsed=Assujetti à la TPS +VATIsNotUsed=Non assujetti à la TPS +##### Local Taxes ##### +LocalTax1IsUsedES= Assujetti à TVQ +LocalTax1IsNotUsedES= Non assujetti à TVQ \ No newline at end of file diff --git a/htdocs/langs/fr_CA/main.lang b/htdocs/langs/fr_CA/main.lang index ca4b13b8480..cb3893d45fc 100644 --- a/htdocs/langs/fr_CA/main.lang +++ b/htdocs/langs/fr_CA/main.lang @@ -13,4 +13,13 @@ FormatDateTextShort=%d %b %Y FormatDateText=%d %B %Y FormatDateHourShort=%d.%m.%Y %H:%M FormatDateHourTextShort=%d %b %Y %H:%M -FormatDateHourText=%d %B %Y %H:%M \ No newline at end of file +FormatDateHourText=%d %B %Y %H:%M +AmountVAT=Montant TPS +AmountLT1=Montant TVQ +TotalVAT=Total TPS +TotalLT1=Total TVQ +IncludedVAT=Dont TPS +VAT=TPS +LT1CA=TVQ +VATRate=Taux TPS +ErrorNoVATRateDefinedForSellerCountry=Erreur, aucun taux de taxe défini pour le pays '%s'. \ No newline at end of file