Merge pull request #199 from simnandez/develop

Fix:[ bug #399 ] Bad calculation of local taxes in update line products
This commit is contained in:
Regis Houssin 2012-05-09 03:14:33 -07:00
commit 646a0eaf1e
3 changed files with 17 additions and 22 deletions

View File

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

View File

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

View File

@ -2,9 +2,9 @@
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley <marc@ocebo.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2005 Marc Barilley <marc@ocebo.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
*
* 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'])
{