From ff50085340b8e77dbb7c0f260106b8b1d5517639 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Sep 2010 14:11:43 +0000 Subject: [PATCH] Fix: A lot of feature was lost because global variables were not propagated into templates. --- htdocs/core/class/html.form.class.php | 35 +++++++++++++++------------ htdocs/lib/functions.lib.php | 4 +-- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f0171d32b4a..acc8a795ee8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2431,7 +2431,7 @@ class Form } //var_dump($societe_acheteuse); - //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." idprod=$idprod, info_bits=$info_bits type=$type"; + //print "name=$name, selectedrate=$selectedrate, seller=".$societe_vendeuse->pays_code." buyer=".$societe_acheteuse->pays_code." buyer is company=".$societe_acheteuse->isACompany()." idprod=$idprod, info_bits=$info_bits type=$type"; //exit; // Get list of all VAT rates to show @@ -2444,27 +2444,30 @@ class Form { $code_pays="'".$mysoc->pays_code."'"; // Pour compatibilite ascendente } - if (! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) && is_object($societe_acheteuse)) + if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) // If option to have vat for end customer for services is on { - // We also add the buyer - if (is_numeric($type)) + if (! $societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && ! $societe_acheteuse->isACompany()) { - if ($type == 1) // We know product is a service + // We also add the buyer + if (is_numeric($type)) + { + if ($type == 1) // We know product is a service + { + $code_pays.=",'".$societe_acheteuse->pays_code."'"; + } + } + else if (! $idprod) // We don't know type of product { $code_pays.=",'".$societe_acheteuse->pays_code."'"; } - } - else if (! $idprod) // We don't know type of product - { - $code_pays.=",'".$societe_acheteuse->pays_code."'"; - } - else - { - $prodstatic=new Product($this->db); - $prodstatic->fetch($idprod); - if ($prodstatic->type == 1) // We know product is a service + else { - $code_pays.=",'".$societe_acheteuse->pays_code."'"; + $prodstatic=new Product($this->db); + $prodstatic->fetch($idprod); + if ($prodstatic->type == 1) // We know product is a service + { + $code_pays.=",'".$societe_acheteuse->pays_code."'"; + } } } } diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index d9d34d9f38f..642106b6547 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2634,7 +2634,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0) if (!is_object($societe_vendeuse)) return -1; if (!is_object($societe_acheteuse)) return -1; - dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", SERVICES_ARE_ECOMMERCE_200238EC=".$conf->global->SERVICES_ARE_ECOMMERCE_200238EC); + dol_syslog("get_default_tva: seller use vat=".$societe_vendeuse->tva_assuj.", seller country=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", buyer country=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", idprod=".$idprod.", SERVICE_ARE_ECOMMERCE_200238EC=".$conf->global->SERVICES_ARE_ECOMMERCE_200238EC); // Si vendeur non assujeti a TVA (tva_assuj vaut 0/1 ou franchise/reel) if (is_numeric($societe_vendeuse->tva_assuj) && ! $societe_vendeuse->tva_assuj) return 0; @@ -2668,7 +2668,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $idprod=0) // If services are eServices according to EU Council Directive 2002/38/EC (ec.europa.eu/taxation_customs/taxation/v.../article_1610_en.htm) // we use the buyer VAT. - if (! empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC)) + if (! empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) { //print "eee".$societe_acheteuse->isACompany();exit; if (! $societe_vendeuse->isInEEC() && $societe_acheteuse->isInEEC() && ! $societe_acheteuse->isACompany())