From 2db5b658f1575ccc0378124866873dfc513c2e94 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Jul 2010 21:16:29 +0000 Subject: [PATCH] Fix: Some errors in vat management with multiprice --- htdocs/comm/propal.php | 4 +- htdocs/comm/propal/class/propal.class.php | 6 +- htdocs/commande/class/commande.class.php | 4 +- htdocs/commande/fiche.php | 2 +- htdocs/compta/facture.php | 4 +- htdocs/compta/facture/class/facture.class.php | 4 +- htdocs/contrat/fiche.php | 8 +-- htdocs/core/class/html.form.class.php | 18 ++--- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/commande/fiche.php | 2 +- htdocs/fourn/facture/fiche.php | 2 +- htdocs/lib/functions.lib.php | 27 ++++--- htdocs/product/fiche.php | 70 +++++++++---------- htdocs/product/price.php | 54 ++++++++------ htdocs/societe/soc.php | 4 +- 15 files changed, 109 insertions(+), 102 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 0dba395729b..a373479fc51 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -701,10 +701,10 @@ if ($_POST['action'] == "addline" && $user->rights->propale->creer) $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - $tva_tx = get_default_tva($mysoc,$propal->client,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$propal->client,$prod->id); $localtax1_tx= get_localtax($tva_tx, 1, $propal->client); //get_default_localtax($mysoc,$propal->client,1,$prod->id); $localtax2_tx= get_localtax($tva_tx, 2, $propal->client); //get_default_localtax($mysoc,$propal->client,2,$prod->id); - $tva_npr = get_default_npr($mysoc,$propal->client,$prod->tva_tx); + $tva_npr = get_default_npr($mysoc,$propal->client,$prod->id); // On defini prix unitaire if ($conf->global->PRODUIT_MULTIPRICES && $propal->client->price_level) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 24f7299ea16..3328f7d9153 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -162,7 +162,7 @@ class Propal extends CommonObject $productdesc = $prod->description; - $tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); // local taxes $localtax1_tx = get_default_localtax($mysoc,$this->client,1,$prod->tva_tx); $localtax2_tx = get_default_localtax($mysoc,$this->client,2,$prod->tva_tx); @@ -271,7 +271,7 @@ class Propal extends CommonObject * \param desc Description de la ligne * \param pu_ht Prix unitaire * \param qty Quantite - * \param txtva Taux de tva force, sinon -1 + * \param txtva Taux de tva * \param txlocaltax1 Local tax 1 rate * \param txlocaltax2 Local tax 2 rate * \param fk_product Id du produit/service predefini @@ -283,7 +283,7 @@ class Propal extends CommonObject * \see add_product * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5bb94d3f604..6ed3121079d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -825,7 +825,7 @@ class Commande extends CommonObject * \see add_product * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ function addline($commandeid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0) @@ -962,7 +962,7 @@ class Commande extends CommonObject $prod=new Product($this->db); $prod->fetch($idproduct); - $tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); $localtax1_tx=get_localtax($tva_tx,1,$this->client); $localtax2_tx=get_localtax($tva_tx,2,$this->client); // multiprix diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index bb02df8db9f..f8f09e42dee 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -394,7 +394,7 @@ if ($_POST['action'] == 'addline' && $user->rights->commande->creer) $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - $tva_tx = get_default_tva($mysoc,$commande->client,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$commande->client,$prod->id); // multiprix if ($conf->global->PRODUIT_MULTIPRICES && $commande->client->price_level) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8ac08547243..8c01897fcda 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -837,8 +837,8 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $ $prod = new Product($db, $_POST['idprod']); $prod->fetch($_POST['idprod']); - $tva_tx = get_default_tva($mysoc,$fac->client,$prod->tva_tx); - $tva_npr = get_default_npr($mysoc,$fac->client,$prod->tva_tx); + $tva_tx = get_default_tva($mysoc,$fac->client,$prod->id); + $tva_npr = get_default_npr($mysoc,$fac->client,$prod->id); // We define price for product if ($conf->global->PRODUIT_MULTIPRICES && $fac->client->price_level) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index d7274f04584..5fe1f87f915 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -298,7 +298,7 @@ class Facture extends CommonObject $prod = new Product($this->db, $_facrec->lignes[$i]->fk_product); $res=$prod->fetch($_facrec->lignes[$i]->fk_product); } - $tva_tx = get_default_tva($mysoc,$soc,($prod->tva_tx?$prod->tva_tx:0)); + $tva_tx = get_default_tva($mysoc,$soc,$prod->id); $localtax1_tx=get_localtax($tva_tx,1,$soc); $localtax2_tx=get_localtax($tva_tx,2,$soc); @@ -1586,7 +1586,7 @@ class Facture extends CommonObject * \return int >0 if OK, <0 if KO * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ function addline($facid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0) diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ec055088942..27e37f86947 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -227,8 +227,8 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer) $prod = new Product($db, $_POST['p_idprod']); $prod->fetch($_POST['p_idprod']); - $tva_tx = get_default_tva($mysoc,$contrat->client,$prod->tva_tx); - $tva_npr = get_default_npr($mysoc,$contrat->client,$prod->tva_npr); + $tva_tx = get_default_tva($mysoc,$contrat->client,$prod->id); + $tva_npr = get_default_npr($mysoc,$contrat->client,$prod->id); // On defini prix unitaire if ($conf->global->PRODUIT_MULTIPRICES && $contrat->client->price_level) @@ -273,7 +273,7 @@ if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer) $localtax1_tx=get_localtax($tva_tx,1,$contrat->client); $localtax2_tx=get_localtax($tva_tx,2,$contrat->client); - + $info_bits=0; if ($tva_npr) $info_bits |= 0x01; @@ -326,7 +326,7 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer && ! $_PO if ($date_start_real_update == '') $date_start_real_update=$contratline->date_ouverture; if ($date_end_real_update == '') $date_end_real_update=$contratline->date_cloture; - + $localtax1_tx=get_localtax($_POST["eltva_tx"],1,$contrat->client); $localtax2_tx=get_localtax($_POST["eltva_tx"],2,$contrat->client); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c98383fecc0..c9af72c865f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2210,19 +2210,19 @@ class Form /** * \brief Output an HTML select vat rate - * \param name Nom champ html - * \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. - * \param societe_vendeuse Objet societe vendeuse - * \param societe_acheteuse Objet societe acheteuse - * \param taux_produit Taux par defaut du produit vendu - * \param info_bits Miscellanous information on line + * \param name Nom champ html + * \param selectedrate Forcage du taux tva pre-selectionne. Mettre '' pour aucun forcage. + * \param societe_vendeuse Objet societe vendeuse + * \param societe_acheteuse Objet societe acheteuse + * \param idprod Id product + * \param info_bits Miscellanous information on line * \remarks Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle. * Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. * Si (vendeur et acheteur dans Communaute europeenne) et bien vendu autre que transport neuf alors la TVA par defaut=TVA du produit vendu. Fin de regle. * Sinon la TVA proposee par defaut=0. Fin de regle. */ - function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $taux_produit='', $info_bits=0) + function load_tva($name='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0) { global $langs,$conf,$mysoc; @@ -2302,8 +2302,8 @@ class Form // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '') if ($defaulttx < 0 || strlen($defaulttx) == 0) { - $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$taux_produit); - $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$taux_produit); + $defaulttx=get_default_tva($societe_vendeuse,$societe_acheteuse,$idprod); + $defaultnpr=get_default_npr($societe_vendeuse,$societe_acheteuse,$idprod); } // Si taux par defaut n'a pu etre determine, on prend dernier de la liste. // Comme ils sont tries par ordre croissant, dernier = plus eleve = taux courant diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a48ac32f45c..c0b5eb91dee 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -713,7 +713,7 @@ class FactureFournisseur extends Facture * \param type Type of line (0=product, 1=service) * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel * de cette methode. Aussi, pour le taux tva, il doit deja avoir ete defini - * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit) + * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,idprod) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ function addline($desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0) diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 6d72ffca03b..ad9acd1fada 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -151,7 +151,7 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer $remise_percent = $_POST["remise_percent"] ? $_POST["remise_percent"] : $_POST["p_remise_percent"]; - $tva_tx = get_default_tva($societe,$mysoc,$product->tva_tx,$product->id); + $tva_tx = get_default_tva($societe,$mysoc,$product->id); $type = $product->type; $result=$commande->addline( diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index f6d6148f556..66cd78c903b 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -329,7 +329,7 @@ if ($_GET['action'] == 'addline') $societe->fetch($facfou->socid); } - $tvatx=get_default_tva($societe,$mysoc,$product->tva_tx); + $tvatx=get_default_tva($societe,$mysoc,$product->id); $type = $product->type; $result=$facfou->addline($label, $product->fourn_pu, $tvatx, $_POST['qty'], $idprod); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index d4ccd085c85..a977280830d 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2517,7 +2517,7 @@ function get_localtax($tva, $local, $societe_acheteuse="") } /** - * \brief Return vat rate of a product in a particular selling country + * Return vat rate of a product in a particular selling country. * TODO May be this should be better as a method of product class */ function get_product_vat_for_country($idprod, $countrycode) @@ -2534,7 +2534,7 @@ function get_product_vat_for_country($idprod, $countrycode) } /** - * \brief Return localtax rate of a product in a particular selling country + * Return localtax rate of a product in a particular selling country * TODO May be this should be better as a method of product class */ function get_product_localtax_for_country($idprod, $local, $countrycode) @@ -2560,16 +2560,15 @@ function get_product_localtax_for_country($idprod, $local, $countrycode) * Sinon TVA proposee par defaut=0. Fin de regle. * \param societe_vendeuse Objet societe vendeuse * \param societe_acheteuse Objet societe acheteuse - * \param taux_produit Taux par defaut du produit vendu (old way to get product vat rate) - * \param idprod Id product (new way to get product vat rate) + * \param idprod Id product * \return float Taux de tva a appliquer, -1 si ne peut etre determine */ -function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $idprod=0) +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 vendeur_assujeti=".$societe_vendeuse->tva_assuj." pays_vendeur=".$societe_vendeuse->pays_code.", seller in cee=".$societe_vendeuse->isInEEC().", pays_acheteur=".$societe_acheteuse->pays_code.", buyer in cee=".$societe_acheteuse->isInEEC().", taux_produit(deprecated)=".$taux_produit.", idprod=".$idprod); + 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); // 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; @@ -2578,11 +2577,10 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $ // Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle. //if (is_object($societe_acheteuse) && ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) && ($societe_acheteuse->tva_assuj == 1 || $societe_acheteuse->tva_assuj == 'reel')) // Le test ci-dessus ne devrait pas etre necessaire. Me signaler l'exemple du cas juridique concerne si le test suivant n'est pas suffisant. - if ($societe_vendeuse->pays_id == $societe_acheteuse->pays_id) + if ($societe_vendeuse->pays_code == $societe_acheteuse->pays_code) // Warning ->pays_id not always defined { if ($idprod) return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code); - if (strlen($taux_produit) == 0) return -1; // Si taux produit = '', on ne peut determiner taux tva - return $taux_produit; + return -1; // Si produit absent, on ne peut determiner taux tva } // Si (vendeur et acheteur dans Communaute europeenne) et (bien vendu = moyen de transports neuf comme auto, bateau, avion) alors TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle. @@ -2605,8 +2603,7 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $ else { if ($idprod) return get_product_vat_for_country($idprod,$societe_vendeuse->pays_code); - if (strlen($taux_produit) == 0) return -1; // Si taux produit = '', on ne peut determiner taux tva - return $taux_produit; + return -1; // Si produit absent, on ne peut determiner taux tva } } @@ -2626,10 +2623,10 @@ function get_default_tva($societe_vendeuse, $societe_acheteuse, $taux_produit, $ * Sinon TVA proposee par defaut=0. Fin de regle. * \param societe_vendeuse Objet societe vendeuse * \param societe_acheteuse Objet societe acheteuse - * \param taux_produit Taux par defaut du produit vendu + * \param idprod Id product * \return float 0 or 1 */ -function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit) +function get_default_npr($societe_vendeuse, $societe_acheteuse, $idprod) { return 0; } @@ -2638,8 +2635,8 @@ function get_default_npr($societe_vendeuse, $societe_acheteuse, $taux_produit) * \brief Function that return localtax of a product line (according to seller, buyer and product vat rate) * \param societe_vendeuse Objet societe vendeuse * \param societe_acheteuse Objet societe acheteuse - * \param local Localtax a traiter - * \param idprod Id product (way to get product localtax1 rate) + * \param local Localtax to process (1 or 2) + * \param idprod Id product * \return float Taux de localtax appliquer, -1 si ne peut etre determine */ function get_default_localtax($societe_vendeuse, $societe_acheteuse, $local, $idprod=0) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 47f60fb8a80..e39c4b25101 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -388,25 +388,22 @@ if ($_POST["action"] == 'addinpropal') } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); + + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - $price_base_type = 'HT'; + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; - // multiprix + // If multiprice if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) { $pu_ht = $prod->multiprices[$soc->price_level]; $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; $price_base_type = $prod->multiprices_base_type[$soc->price_level]; } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -473,23 +470,23 @@ if ($_POST["action"] == 'addincommande') } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); + + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } + + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + // If multiprice + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + { + $pu_ht = $prod->multiprices[$soc->price_level]; + $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; + $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). @@ -557,23 +554,22 @@ if ($_POST["action"] == 'addinfacture' && $user->rights->facture->creer) } $desc = $prod->description; - $tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx); + + $tva_tx = get_default_tva($mysoc, $soc, $prod->id); $localtax1_tx= get_localtax($tva_tx, 1, $soc); $localtax2_tx= get_localtax($tva_tx, 2, $soc); - // multiprix - if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - { - $pu_ht = $prod->multiprices[$soc->price_level]; - $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; - $price_base_type = $prod->multiprices_base_type[$soc->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_base_type = $prod->price_base_type; - } + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_base_type = $prod->price_base_type; + + // If multiprice + if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + { + $pu_ht = $prod->multiprices[$soc->price_level]; + $pu_ttc = $prod->multiprices_ttc[$soc->price_level]; + $price_base_type = $prod->multiprices_base_type[$soc->price_level]; + } // On reevalue prix selon taux tva car taux tva transaction peut etre different // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). diff --git a/htdocs/product/price.php b/htdocs/product/price.php index e2392cf1eaa..220a7b27365 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -196,7 +196,13 @@ if($conf->global->PRODUIT_MULTIPRICES) { for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { - print ''.$langs->trans("SellingPrice").' '.$i.''; + // TVA + if ($i == 1) // We show only price for level 1 + { + print ''.$langs->trans("VATRate").''.vatrate($product->multiprices_tva_tx[1],true).''; + } + + print ''.$langs->trans("SellingPrice").' '.$i.''; if ($product->multiprices_base_type["$i"] == 'TTC') { @@ -228,15 +234,15 @@ if($conf->global->PRODUIT_MULTIPRICES) print price($product->multiprices_min["$i"]).' '.$langs->trans($product->multiprices_base_type["$i"]); } print ''; - - // TVA - print ''.$langs->trans("VATRate").' '.$i.''.vatrate($product->multiprices_tva_tx["$i"],true).''; } } } else { - // Prix + // TVA + print ''.$langs->trans("VATRate").''.vatrate($product->tva_tx,true).''; + + // Price print ''.$langs->trans("SellingPrice").''; if ($product->price_base_type == 'TTC') { @@ -248,7 +254,7 @@ else } print ''; - // Prix mini + // Price minimum print ''.$langs->trans("MinPrice").''; if ($product->price_base_type == 'TTC') { @@ -259,9 +265,6 @@ else print price($product->price_min).' '.$langs->trans($product->price_base_type); } print ''; - - // TVA - print ''.$langs->trans("VATRate").''.vatrate($product->tva_tx,true).''; } // Statut @@ -311,6 +314,11 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> print ''; print ''; + // VAT + print ''; + // Price base print ''; + // Price minimum print ''; - // VAT - print ''; - print ''; print '
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,''); + print '
'; print $langs->trans('PriceBase'); @@ -335,6 +343,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> } print '
' ; $text=$langs->trans('MinPrice') ; print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1); @@ -348,11 +357,6 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> } print '
'.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx",$product->tva_tx,$mysoc,''); - print '
 '; print '
'; @@ -360,13 +364,27 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> } else { - for($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) + for ($i=1; $i<=$conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { print '
'; print ''; print ''; print ''; print ''; + + // VAT + if ($i == 1) + { + print ''; + } + else + { // We always use the vat rate of price level 1 (A vat rate does not depends on customer) + print ''; + } + + // Selling price print ''; + // Min price print ''; - // VAT - print ''; - print ''; print '
'.$langs->trans("VATRate").''; + print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,''); + print '
'; $text=$langs->trans('SellingPrice').' '.$i; print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1); @@ -382,6 +400,7 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> print $html->select_PriceBaseType($product->multiprices_base_type["$i"], "multiprices_base_type_".$i); print '
'; $text=$langs->trans('MinPrice').' '.$i; print $html->textwithpicto($text,$langs->trans("PrecisionUnitIsLimitedToXDecimals",$conf->global->MAIN_MAX_DECIMALS_UNIT),$direction=1,$usehelpcursor=1); @@ -395,11 +414,6 @@ if ($_GET["action"] == 'edit_price' && ($user->rights->produit->creer || $user-> } print '
'.$langs->trans("VATRate").''; - print $html->select_tva("tva_tx_".$i,$product->multiprices_tva_tx["$i"],$mysoc,''); - print '
 '; print '
'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 91940d47305..38faa37f96b 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -209,14 +209,14 @@ if ((! $_POST["getcustomercode"] && ! $_POST["getsuppliercode"]) if ( $soc->client == 1 ) { - Header("Location: comm/fiche.php?socid=".$soc->id); + Header("Location: ".DOL_URL_ROOT."/comm/fiche.php?socid=".$soc->id); return; } else { if ( $soc->fournisseur == 1 ) { - Header("Location: fourn/fiche.php?socid=".$soc->id); + Header("Location: ".DOL_URL_ROOT."/fourn/fiche.php?socid=".$soc->id); return; } else