Fix: function to get localtax1 or 2 value from vat rate return bad value

when countries differs.

Conflicts:
	htdocs/langs/fr_CA/main.lang
This commit is contained in:
Laurent Destailleur 2013-05-31 21:33:48 +02:00
parent da73a8d84c
commit 743da5a214
5 changed files with 46 additions and 8 deletions

View File

@ -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);

View File

@ -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)
{

View File

@ -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 :<br>Si vendeur non assujetti à TPS, TPS par défaut=0. Fin de règle.<br>Si le (pays vendeur= pays acheteur) alors TPS par défaut=TPS du produit vendu. Fin de règle.<br>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.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TPS par défaut=TPS du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TPS par défaut=0. Fin de règle.<br>Sinon TPS proposée par défaut=0. Fin de règle.<br>
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=

View File

@ -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

View File

@ -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
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'.