diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 394d7e8f89f..b5efd93bf6e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2683,9 +2683,8 @@ function get_localtax($tva, $local, $societe_acheteuse="") { global $db, $conf, $mysoc; - // TODO Can we uncomment this ? - //if ($local == 1 && empty($conf->global->FACTURE_LOCAL_TAX1_OPTION)) return; - //if ($local == 2 && empty($conf->global->FACTURE_LOCAL_TAX2_OPTION)) return; + if ($local == 1 && ! $mysoc->localtax1_assuj) return 0; + if ($local == 2 && ! $mysoc->localtax2_assuj) return 0; $code_pays=$mysoc->pays_code; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index a75d183d65c..5fc31efe69f 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -198,8 +198,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $type = $productsupplier->type; // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $mysoc); - $localtax2_tx= get_localtax($tva_tx, 2, $mysoc); + $localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty); $result=$object->addline( $desc, diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index f26b9199c94..1840291be73 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2,9 +2,9 @@ /* Copyright (C) 2002-2005 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles - * Copyright (C) 2005 Marc Barilley - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2011 Juanjo Menent + * Copyright (C) 2005 Marc Barilley + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -413,7 +413,7 @@ elseif ($action == 'update_line') $pu=$_POST['puttc']; $price_base_type='TTC'; } - + if ($_POST['idprod']) { $prod = new Product($db); @@ -422,21 +422,17 @@ elseif ($action == 'update_line') if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc']; $type = $prod->type; - $localtax1tx = $prod->localtax1_tx; - $localtax2tx = $prod->localtax2_tx; } else { - if ($object->socid) - { - $societe=new Societe($db); - $societe->fetch($object->socid); - } + $label = $_POST['desc']; $type = $_POST["type"]?$_POST["type"]:0; - $localtax1tx= get_localtax($_POST['tauxtva'], 1, $mysoc); - $localtax2tx= get_localtax($_POST['tauxtva'], 2, $mysoc); + } + + $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); + $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type); if ($result >= 0) @@ -471,8 +467,8 @@ elseif ($action == 'addline') $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); - $localtax1tx= get_localtax($tvatx, 1, $mysoc); - $localtax2tx= get_localtax($tvatx, 2, $mysoc); + $localtax1tx= get_localtax($tvatx, 1, $object->thirdparty); + $localtax2tx= get_localtax($tvatx, 2, $object->thirdparty); $type = $product->type; @@ -489,8 +485,8 @@ elseif ($action == 'addline') else { $tauxtva = price2num($_POST['tauxtva']); - $localtax1tx= get_localtax($tauxtva, 1, $mysoc); - $localtax2tx= get_localtax($tauxtva, 2, $mysoc); + $localtax1tx= get_localtax($tauxtva, 1, $object->thirdparty); + $localtax2tx= get_localtax($tauxtva, 2, $object->thirdparty); if (! $_POST['dp_desc']) {