Merge branch 'develop' of https://github.com/Dolibarr/dolibarr into mko559

This commit is contained in:
Maxime Kohlhaas 2012-11-09 13:46:50 +01:00
commit 332c077d77
10 changed files with 222 additions and 75 deletions

View File

@ -70,7 +70,7 @@
<Keywords>dolibarr, erp, crm, invoices, commercial proposals, orders, accounting, stock, products, agenda, bank, business, company, foundation, management, sme, doliwamp</Keywords>
<Char_Desc_45>Dolibarr ERP &amp; CRM</Char_Desc_45>
<Char_Desc_80>Dolibarr ERP &amp; CRM, the easy to use open source software to manage your activity</Char_Desc_80>
<Char_Desc_250>Dolibarr ERP &amp; CRM, the easy to use open source software to manage your activity (invoices, customers, suppliers, contracts, agenda, emailings...) and any other things a small or mid-sized business or a foundation needs to follow.</Char_Desc_250>
<Char_Desc_250>Dolibarr ERP &amp; CRM, the easy to use open source software to manage your activity (invoices, customers, suppliers, contracts, agenda, emailings...) and any other things a small or mid-sized business or a foundation needs to manage.</Char_Desc_250>
<Char_Desc_450>Dolibarr ERP &amp; CRM is a software built by modules addition (you enable only features you need), to manage small or medium companies, freelancers or foundations. We can say Dolibarr is an ERP or CRM. Dolibarr is also available with an auto-installer for Windows users with no technical knowledge to install Dolibarr and all its prerequisites (Apache, Mysql, PHP) with just one auto-exe file. See DoliWamp software for this.</Char_Desc_450>
<Char_Desc_2000>Dolibarr ERP &amp; CRM is a software built by modules addition (you enable only features you need), to manage small or mid-sized businesses, freelancers or foundations. We can say Dolibarr is an ERP or CRM (or both depending on activated modules). It's an OpenSource project base on a WAMP, MAMP or LAMP server (Apache, Mysql, PHP for all Operating Systems). Dolibarr differs from other ERP or CRM softwares (like OpenAguila, OpenBravo, OpenERP, Neogia, Compiere, etc) because everything was made to be more simple:
Simple to install
@ -83,8 +83,8 @@ Note that Dolibarr is also available with an auto-installer for Windows or Ubunt
<Char_Desc_45>Dolibarr ERP &amp; CRM</Char_Desc_45>
<Char_Desc_80>Dolibarr ERP &amp; CRM, le gestionnaire simple pour gérer votre activité</Char_Desc_80>
<Char_Desc_250>Dolibarr ERP &amp; CRM, le logiciel simple et OpenSource pour gérer votre activité (factures, devis, facturation, commandes, compta, trésorerie, stocks, produits, agenda, comptes bancaires, associations)</Char_Desc_250>
<Char_Desc_450>Dolibarr ERP/CRM est un logiciel modulaire (on n'active que les fonctions que l'on désire) de gestions de TPE/PME, d'indépendants, d'entrepreneurs ou d'associations. En terme plus techniques, c'est un ERP et CRM. C'est un projet OpenSource qui s'exécute au sein d'un serveur Web et peut donc être accessible depuis n'importe quel lieu disposant d'une connexion Internet (Projet basé sur un serveur WAMP, MAMP ou LAMP: Apache, MySQL, PHP).</Char_Desc_450>
<Char_Desc_2000>Dolibarr ERP/CRM est un logiciel modulaire (on n'active que les fonctions que l'on désire) de gestions de TPE/PME, d'indépendants, d'entrepreneurs ou d'associations. En terme plus techniques, c'est un ERP et CRM. C'est un projet OpenSource qui s'exécute au sein d'un serveur Web et peut donc être accessible depuis n'importe quel lieu disposant d'une connexion Internet (Projet basé sur un serveur WAMP, MAMP ou LAMP: Apache, MySQL, PHP). Dolibarr vient compléter les offres déjà nombreuses de logiciels de cette catégorie (comme OpenBravo, OpenERP, SugarCRM, Neogia, Compiere, etc.) mais se démarque par le fait qu'ici tout est fait pour offrir de la simplicité (règle des 3 S):
<Char_Desc_450>Dolibarr ERP &amp; CRM est un logiciel modulaire (on n'active que les fonctions que l'on désire) de gestions de TPE/PME, d'indépendants, d'entrepreneurs ou d'associations. En terme plus techniques, c'est un ERP et CRM. C'est un projet OpenSource qui s'exécute au sein d'un serveur Web et peut donc être accessible depuis n'importe quel lieu disposant d'une connexion Internet (Projet basé sur un serveur WAMP, MAMP ou LAMP: Apache, MySQL, PHP).</Char_Desc_450>
<Char_Desc_2000>Dolibarr ERP &amp; CRM est un logiciel modulaire (on n'active que les fonctions que l'on désire) de gestions de TPE/PME, d'indépendants, d'entrepreneurs ou d'associations. En terme plus techniques, c'est un ERP et CRM. C'est un projet OpenSource qui s'exécute au sein d'un serveur Web et peut donc être accessible depuis n'importe quel lieu disposant d'une connexion Internet (Projet basé sur un serveur WAMP, MAMP ou LAMP: Apache, MySQL, PHP). Dolibarr vient compléter les offres déjà nombreuses de logiciels de cette catégorie (comme OpenBravo, OpenERP, SugarCRM, Neogia, Compiere, etc.) mais se démarque par le fait qu'ici tout est fait pour offrir de la simplicité (règle des 3 S):
Simple pour l'installation (avec au choix des installeurs clé en main pour ceux qui ignorent comment installer un serveur Web, ou une installation manuelle)
Simple pour l'utilisation (fonctions modulaires pour ne pas surcharger les menus, informations claires à la saisie)
Simple pour le développement (pas de frameworks lourds).

View File

@ -0,0 +1 @@
http://www.taxrates.cc/index.html

View File

@ -502,9 +502,9 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$result = $db->query($sql);
if ($result) // Add is ok
{
$oldid=$id;
$_POST=array('id'=>$oldid); // Clean $_POST array, we keep only
$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
//$oldid=$id;
//$_POST=array('id'=>$oldid); // Clean $_POST array, we keep only
//$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
}
else
{
@ -558,12 +558,12 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
}
if ($msg) $msg='<div class="error">'.$msg.'</div>';
$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if (GETPOST('actioncancel'))
{
$_GET["id"]=$_POST["id"]; // Force affichage dictionnaire en cours d'edition
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
}
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
@ -778,7 +778,7 @@ if ($id)
}
$tmpaction = 'create';
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$_GET["id"]]);
$parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
$reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=$hookmanager->errors;
@ -947,69 +947,69 @@ if ($id)
$valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
$valuetoshow=nl2br($valuetoshow);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_pays') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_pays') {
$key=$langs->trans("Country".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_availability') {
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_availability') {
$langs->load("propal");
$key=$langs->trans("AvailabilityType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_actioncomm') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_actioncomm') {
$key=$langs->trans("Action".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if (! empty($obj->code_iso) && $fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') {
else if (! empty($obj->code_iso) && $fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_currencies') {
$key=$langs->trans("Currency".strtoupper($obj->code_iso));
$valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_typent') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_typent') {
$key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_prospectlevel') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_prospectlevel') {
$key=$langs->trans(strtoupper($obj->code));
$valuetoshow=($key != strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_civilite') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_civilite') {
$key=$langs->trans("Civility".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_type_contact') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_type_contact') {
$key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_payment_term') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_payment_term') {
$langs->load("bills");
$key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_paiement') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paiement') {
$langs->load("bills");
$key=$langs->trans("PaymentType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_reason') {
else if ($fieldlist[$field]=='label' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_reason') {
$key=$langs->trans("DemandReasonType".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_method') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_input_method') {
$langs->load("orders");
$key=$langs->trans($obj->code);
$valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field];
}
else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_shipment_mode') {
else if ($fieldlist[$field]=='libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_shipment_mode') {
$langs->load("sendings");
$key=$langs->trans("SendingMethod".strtoupper($obj->code));
$valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code)?$key:$obj->$fieldlist[$field]);
}
else if ($fieldlist[$field] == 'libelle' && $tabname[$_GET['id']]==MAIN_DB_PREFIX.'c_paper_format')
else if ($fieldlist[$field] == 'libelle' && $tabname[$id]==MAIN_DB_PREFIX.'c_paper_format')
{
$key = $langs->trans('PaperFormat'.strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$fieldlist[$field]);
}
else if ($fieldlist[$field] == 'libelle' && $tabname[$_GET['id']] == MAIN_DB_PREFIX.'c_type_fees')
else if ($fieldlist[$field] == 'libelle' && $tabname[$id] == MAIN_DB_PREFIX.'c_type_fees')
{
$langs->load('trips');
$key = $langs->trans(strtoupper($obj->code));
@ -1022,7 +1022,7 @@ if ($id)
$valuetoshow = getCurrencySymbol($obj->code);
}
else if (($fieldlist[$field] == 'unit') && ($tabname[$_GET['id']] == MAIN_DB_PREFIX.'c_paper_format'))
else if (($fieldlist[$field] == 'unit') && ($tabname[$id] == MAIN_DB_PREFIX.'c_paper_format'))
{
$key = $langs->trans('SizeUnit'.strtolower($obj->unit));
$valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$fieldlist[$field]);
@ -1269,7 +1269,7 @@ function fieldList($fieldlist,$obj='',$tabname='')
elseif ($fieldlist[$field] == 'localtax1_type' || $fieldlist[$field] == 'localtax2_type')
{
print '<td align="center">';
print $form->selectarray($fieldlist[$field], $localtax_typeList,$obj->$fieldlist[$field]);
print $form->selectarray($fieldlist[$field], $localtax_typeList, (! empty($obj->$fieldlist[$field])?$obj->$fieldlist[$field]:''));
print '</td>';
}
else

View File

@ -281,7 +281,7 @@ else if ($action == 'setconditions' && $user->rights->facture->creer)
$object->cond_reglement_id=0; // To clean property
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int'));
if ($result < 0) dol_print_error($db,$object->error);
$old_date_lim_reglement=$object->date_lim_reglement;
$new_date_lim_reglement=$object->calculate_date_lim_reglement();
if ($new_date_lim_reglement > $old_date_lim_reglement) $object->date_lim_reglement=$new_date_lim_reglement;
@ -2834,7 +2834,7 @@ else if ($id > 0 || ! empty($ref))
print '</table>';
// Margin Infos
if (! empty($conf->margin->enabled))
if (! empty($conf->margin->enabled))
{
print '<br>';
$object->displayMarginInfos($object->statut > 0);

View File

@ -2681,13 +2681,15 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
}
/**
* Return localtaxe rate for a particular vat
* Return localtax rate for a particular vat, when selling a product with vat $tva, from a $thirdparty_buyer to a $thirdparty_seller
* Note: It applies same rule than get_default_tva
*
* @param float $tva Vat taxe
* @param int $local Local tax to search and return (1 or 2 return only tax rate 1 or tax rate 2)
* @param Societe $thirdparty_buyer Object of buying third party
* @param Societe $thirdparty_seller Object of selling third party
* @return int 0 if not found, localtax if found
* @see get_default_tva
*/
function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
{
@ -2706,9 +2708,7 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
if (is_object($thirdparty_buyer))
{
if ($code_country!=$thirdparty_buyer->country_code) return 0;
if ($local==1 && !$thirdparty_buyer->localtax1_assuj) return 0; // TODO Not sure this is good
elseif ($local==2 && !$thirdparty_buyer->localtax2_assuj) return 0; // TODO Not sure this is good
if ($code_country != $thirdparty_buyer->country_code) return 0;
}
// Search local taxes
@ -2731,14 +2731,13 @@ function get_localtax($tva, $local, $thirdparty_buyer="", $thirdparty_seller="")
}
/**
* Return vat rate of a product in a particular selling country or default country
* vat if product is unknown
* Return vat rate of a product in a particular selling country or default country vat if product is unknown
*
* @param int $idprod Id of product or 0 if not a predefined product
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @param int $idprodfournprice Id product_fournisseur_price (for supplier order/invoice)
* @return int <0 if KO, Vat rate if OK
* TODO May be this should be better as a method of product class
* @see get_product_localtax_for_country
*/
function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice=0)
{
@ -2804,25 +2803,71 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
}
/**
* Return localtax rate of a product in a particular selling country
* Return localtax vat rate of a product in a particular selling country or default country vat if product is unknown
*
* @param int $idprod Id of product
* @param int $local 1 for localtax1, 2 for localtax 2
* @param string $countrycode Country code (FR, US, IT, ...)
* @return int <0 if KO, Vat rate if OK
* TODO May be this should be better as a method of product class
* @param int $idprod Id of product
* @param int $local 1 for localtax1, 2 for localtax 2
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
* @return int <0 if KO, Vat rate if OK
* @see get_product_vat_for_country
*/
function get_product_localtax_for_country($idprod, $local, $countrycode)
function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
{
global $db;
global $db,$mysoc;
$product=new Product($db);
$product->fetch($idprod);
if (! class_exists('Product')) {
require DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
}
if ($local==1) return $product->localtax1_tx;
elseif ($local==2) return $product->localtax2_tx;
$ret=0;
$found=0;
return -1;
if ($idprod > 0)
{
// Load product
$product=new Product($db);
$result=$product->fetch($idprod);
if ($mysoc->country_code == $thirdparty_seller->country_code) // If selling country is ours
{
/* Not defined yet, so we don't use this
if ($local==1) $ret=$product->localtax1_tx;
elseif ($local==2) $ret=$product->localtax2_tx;
$found=1;
*/
}
else
{
// TODO Read default product vat according to countrycode and product
}
}
if (! $found)
{
// If vat of product for the country not found or not defined, we return higher vat of country.
$sql = "SELECT taux as vat_rate, localtax1, localtax2";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
$sql.= " WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$thirdparty_seller->country_code."'";
$sql.= " ORDER BY t.taux DESC, t.recuperableonly ASC";
$sql.= $db->plimit(1);
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
if ($obj)
{
if ($local==1) $ret=$obj->localtax1;
elseif ($local==2) $ret=$obj->localtax2;
}
}
else dol_print_error($db);
}
dol_syslog("get_product_localtax_for_country: ret=".$ret);
return $ret;
}
/**
@ -2839,6 +2884,7 @@ function get_product_localtax_for_country($idprod, $local, $countrycode)
* @param int $idprod Id product
* @param int $idprodfournprice Id product_fournisseur_price (for supplier order/invoice)
* @return float Taux de tva a appliquer, -1 si ne peut etre determine
* @see get_default_localtax
*/
function get_default_tva($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
{
@ -2926,36 +2972,40 @@ function get_default_npr($thirdparty_seller, $thirdparty_buyer, $idprod)
/**
* Function that return localtax of a product line (according to seller, buyer and product vat rate)
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors TVA par defaut=TVA du produit vendu. Fin de regle.
* Sinon TVA proposee par defaut=0. Fin de regle.
*
* @param Societe $thirdparty_seller Objet societe vendeuse
* @param Societe $thirdparty_buyer Objet societe acheteuse
* @param int $local Localtax to process (1 or 2)
* @param int $idprod Id product
* @return float Taux de localtax appliquer, -1 si ne peut etre determine
* @return float localtax, -1 si ne peut etre determine
* @see get_default_tva
*/
function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod=0)
{
if (!is_object($thirdparty_seller)) return -1;
if (!is_object($thirdparty_buyer)) return -1;
if ($thirdparty_seller->country_id=='ES' || $thirdparty_seller->country_code=='ES')
if ($local==1) //RE
{
if ($local==1) //RE
{
// Si achatteur non assujeti a RE, localtax1 par default=0
if (is_numeric($thirdparty_buyer->localtax1_assuj) && ! $thirdparty_buyer->localtax1_assuj) return 0;
if (! is_numeric($thirdparty_buyer->localtax1_assuj) && $thirdparty_buyer->localtax1_assuj=='localtax1off') return 0;
}
elseif ($local==2) //IRPF
{
// Si vendeur non assujeti a IRPF, localtax2 par default=0
if (is_numeric($thirdparty_seller->localtax2_assuj) && ! $thirdparty_seller->localtax2_assuj) return 0;
if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') return 0;
} else return -1;
if ($idprod) return get_product_localtax_for_country($idprod, $local, $thirdparty_seller->country_code);
else return -1;
// Si vendeur non assujeti a RE, localtax1 par default=0
if (is_numeric($thirdparty_seller->localtax1_assuj) && ! $thirdparty_seller->localtax1_assuj) return 0;
if (! is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj=='localtax1off') return 0;
}
elseif ($local==2) //IRPF
{
// Si vendeur non assujeti a IRPF, localtax2 par default=0
if (is_numeric($thirdparty_seller->localtax2_assuj) && ! $thirdparty_seller->localtax2_assuj) return 0;
if (! is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj=='localtax2off') return 0;
}
if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code)
{
return get_product_localtax_for_country($idprod, $local, $thirdparty_seller);
}
return 0;
}

View File

@ -99,7 +99,9 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface
if (!$filefd && ! defined("SYSLOG_FILE_NO_ERROR"))
{
throw new Exception('Failed to open log file '.$logfile);
// Do not break dolibarr usage if log fails
//throw new Exception('Failed to open log file '.basename($logfile));
print 'Failed to open log file '.basename($logfile);
}
$logLevels = array(

View File

@ -202,9 +202,9 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (20
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (204,20, '0','0','VAT Rate 0', 1);
-- SWITZERLAND (id country=6)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 61, 6, '7.6','0','VAT standard rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 62, 6, '3.6','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 63, 6, '2.4','0','VAT super-reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 61, 6, '8','0','VAT standard rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 62, 6, '3.8','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 63, 6, '2.5','0','VAT super-reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 64, 6, '0','0','VAT Rate 0', 1);
-- TUNISIA (id country=10)

View File

@ -262,6 +262,12 @@ UPDATE llx_c_tva SET localtax2_type = '1' WHERE rowid = 41 AND fk_pays = 4 AND l
UPDATE llx_c_tva SET localtax2_type = '1' WHERE rowid = 42 AND fk_pays = 4 AND localtax2_type = '0';
UPDATE llx_c_tva SET localtax2_type = '1' WHERE rowid = 43 AND fk_pays = 4 AND localtax2_type = '0';
-- update localtax values for spain
UPDATE llx_c_tva set localtax1 = '5.2', localtax2 = '-15' where rowid= 41 and fk_pays= 4 AND localtax1_type='3';
UPDATE llx_c_tva set localtax1 = '1.4', localtax2 = '-15' where rowid= 42 and fk_pays= 4 AND localtax1_type='3';
UPDATE llx_c_tva set localtax1 = '0.5', localtax2 = '-15' where rowid= 43 and fk_pays= 4 AND localtax1_type='3';
-- update type of localtax for tunisia
UPDATE llx_c_tva set localtax1 = 1, localtax1_type = '4', localtax2 = 0.4, localtax2_type = '7' where rowid= 101 and fk_pays= 10 AND localtax1_type='0';
UPDATE llx_c_tva set localtax1 = 1, localtax1_type = '4', localtax2 = 0.4, localtax2_type = '7' where rowid= 102 and fk_pays= 10 AND localtax1_type='0';
UPDATE llx_c_tva set localtax1 = 1, localtax1_type = '4', localtax2 = 0.4, localtax2_type = '7' where rowid= 103 and fk_pays= 10 AND localtax1_type='0';

View File

@ -2,4 +2,5 @@ User-agent: *
Allow: /public/agenda/agendaexport.php
Allow: /public/demo/
Allow: /index.php
Disallow: /
#Allow: /$
Disallow: /

View File

@ -530,9 +530,9 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$companyfr->country_code='FR';
$companyfr->tva_assuj=1;
$companymo=new Societe($db);
$companymo->country_code='MC';
$companymo->tva_assuj=1;
$companymc=new Societe($db);
$companymc->country_code='MC';
$companymc->tva_assuj=1;
$companyit=new Societe($db);
$companyit->country_code='IT';
@ -551,7 +551,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$companyus->tva_intra='';
// Test RULE 1-2
$vat=get_default_tva($companyfrnovat,$companymo,0);
$vat=get_default_tva($companyfrnovat,$companymc,0);
$this->assertEquals(0,$vat);
// Test RULE 3 (FR-FR)
@ -559,7 +559,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$this->assertEquals(19.6,$vat);
// Test RULE 3 (FR-MC)
$vat=get_default_tva($companyfr,$companymo,0);
$vat=get_default_tva($companyfr,$companymc,0);
$this->assertEquals(19.6,$vat);
// Test RULE 4 (FR-IT)
@ -577,5 +577,92 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$vat=get_default_tva($companyfr,$companyus,0);
$this->assertEquals(0,$vat);
}
/**
* testGetDefaultTva
*
* @return void
*/
public function testGetDefaultLocalTax()
{
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$companyfrnovat=new Societe($db);
$companyfrnovat->country_code='FR';
$companyfrnovat->tva_assuj=0;
$companyfrnovat->localtax1_assuj=0;
$companyfrnovat->localtax2_assuj=0;
$companyes=new Societe($db);
$companyes->country_code='ES';
$companyes->tva_assuj=1;
$companyes->localtax1_assuj=1;
$companyes->localtax2_assuj=1;
$companymc=new Societe($db);
$companymc->country_code='MC';
$companymc->tva_assuj=1;
$companymc->localtax1_assuj=0;
$companymc->localtax2_assuj=0;
$companyit=new Societe($db);
$companyit->country_code='IT';
$companyit->tva_assuj=1;
$companyit->tva_intra='IT99999';
$companyit->localtax1_assuj=0;
$companyit->localtax2_assuj=0;
$notcompanyit=new Societe($db);
$notcompanyit->country_code='IT';
$notcompanyit->tva_assuj=1;
$notcompanyit->tva_intra='';
$notcompanyit->typent_code='TE_PRIVATE';
$notcompanyit->localtax1_assuj=0;
$notcompanyit->localtax2_assuj=0;
$companyus=new Societe($db);
$companyus->country_code='US';
$companyus->tva_assuj=1;
$companyus->tva_intra='';
$companyus->localtax1_assuj=0;
$companyus->localtax2_assuj=0;
// Test RULE FR-MC
$vat1=get_default_localtax($companyfrnovat,$companymc,1,0);
$vat2=get_default_localtax($companyfrnovat,$companymc,2,0);
$this->assertEquals(0,$vat1);
$this->assertEquals(0,$vat2);
// Test RULE ES-ES
$vat1=get_default_localtax($companyes,$companyes,1,0);
$vat2=get_default_localtax($companyes,$companyes,2,0);
$this->assertEquals(5.2,$vat1);
$this->assertEquals(-15,$vat2);
// Test RULE ES-IT
$vat1=get_default_localtax($companyes,$companyit,1,0);
$vat2=get_default_localtax($companyes,$companyit,2,0);
$this->assertEquals(0,$vat1);
$this->assertEquals(0,$vat2);
// Test RULE ES-IT
$vat1=get_default_localtax($companyes,$notcompanyit,1,0);
$vat2=get_default_localtax($companyes,$notcompanyit,2,0);
$this->assertEquals(0,$vat1);
$this->assertEquals(0,$vat2);
// Test RULE FR-IT
// Not tested
// Test RULE ES-US
$vat1=get_default_localtax($companyes,$companyus,1,0);
$vat2=get_default_localtax($companyes,$companyus,2,0);
$this->assertEquals(0,$vat1);
$this->assertEquals(0,$vat2);
}
}
?>