Fix:[ bug #399 ] Bad calculation of local taxes in update line products

This commit is contained in:
simnandez 2012-05-09 10:29:12 +02:00
parent f47d6c71ed
commit 84a09808fc
3 changed files with 17 additions and 22 deletions

View File

@ -2682,9 +2682,8 @@ function get_localtax($tva, $local, $societe_acheteuse="")
{ {
global $db, $conf, $mysoc; global $db, $conf, $mysoc;
// TODO Can we uncomment this ? if ($local == 1 && ! $mysoc->localtax1_assuj) return 0;
//if ($local == 1 && empty($conf->global->FACTURE_LOCAL_TAX1_OPTION)) return; if ($local == 2 && ! $mysoc->localtax2_assuj) return 0;
//if ($local == 2 && empty($conf->global->FACTURE_LOCAL_TAX2_OPTION)) return;
$code_pays=$mysoc->pays_code; $code_pays=$mysoc->pays_code;

View File

@ -176,8 +176,8 @@ else if ($action == 'addline' && $user->rights->fournisseur->commande->creer)
$type = $productsupplier->type; $type = $productsupplier->type;
// Local Taxes // Local Taxes
$localtax1_tx= get_localtax($tva_tx, 1, $mysoc); $localtax1_tx= get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx= get_localtax($tva_tx, 2, $mysoc); $localtax2_tx= get_localtax($tva_tx, 2, $object->thirdparty);
$result=$object->addline( $result=$object->addline(
$desc, $desc,

View File

@ -2,9 +2,9 @@
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr> * Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
* Copyright (C) 2005 Marc Barilley <marc@ocebo.fr> * Copyright (C) 2005 Marc Barilley <marc@ocebo.fr>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -422,22 +422,18 @@ elseif ($action == 'update_line')
if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc']; if (trim($_POST['desc']) != trim($label)) $label=$_POST['desc'];
$type = $prod->type; $type = $prod->type;
$localtax1tx = $prod->localtax1_tx;
$localtax2tx = $prod->localtax2_tx;
} }
else else
{ {
if ($object->socid)
{
$societe=new Societe($db);
$societe->fetch($object->socid);
}
$label = $_POST['desc']; $label = $_POST['desc'];
$type = $_POST["type"]?$_POST["type"]:0; $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); $result=$object->updateline($_GET['lineid'], $label, $pu, $_POST['tauxtva'], $localtax1tx, $localtax2tx, $_POST['qty'], $_POST['idprod'], $price_base_type, 0, $type);
if ($result >= 0) if ($result >= 0)
{ {
@ -471,8 +467,8 @@ elseif ($action == 'addline')
$tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']); $tvatx=get_default_tva($object->thirdparty, $mysoc, $product->id, $_POST['idprodfournprice']);
$localtax1tx= get_localtax($tvatx, 1, $mysoc); $localtax1tx= get_localtax($tvatx, 1, $object->thirdparty);
$localtax2tx= get_localtax($tvatx, 2, $mysoc); $localtax2tx= get_localtax($tvatx, 2, $object->thirdparty);
$type = $product->type; $type = $product->type;
@ -489,8 +485,8 @@ elseif ($action == 'addline')
else else
{ {
$tauxtva = price2num($_POST['tauxtva']); $tauxtva = price2num($_POST['tauxtva']);
$localtax1tx= get_localtax($tauxtva, 1, $mysoc); $localtax1tx= get_localtax($tauxtva, 1, $object->thirdparty);
$localtax2tx= get_localtax($tauxtva, 2, $mysoc); $localtax2tx= get_localtax($tauxtva, 2, $object->thirdparty);
if (! $_POST['dp_desc']) if (! $_POST['dp_desc'])
{ {