From 35a6ed90a04ff841aad672e47b8bd303cecedbbd Mon Sep 17 00:00:00 2001
From: Juanjo Menent <jmenent@2byte.es>
Date: Tue, 7 Apr 2015 20:02:12 +0200
Subject: [PATCH] Solves #2542 Bug: Contracts store localtax preferences

---
 ChangeLog                 | 1 +
 htdocs/compta/facture.php | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bc57dfce49b..a69eab23790 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,7 @@ English Dolibarr ChangeLog
 - Fix: [ bug #2534 ] SQL error when editing a supplier invoice line
 - Fix: [ bug #2535 ] Untranslated string in "Linked objects" page of a project
 - Fix: [ bug #2545 ] Missing object_margin.png in Amarok theme
+- Fix: [ bug #2542 ] Contracts store localtax preferences
 
 ***** ChangeLog for 3.6.2 compared to 3.6.1 *****
 - Fix: fix ErrorBadValueForParamNotAString error message in price customer multiprice.
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index d5c11cf5b63..4a2b13b0069 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -5,7 +5,7 @@
  * Copyright (C) 2005      Marc Barilley / Ocebo <marc@ocebo.com>
  * Copyright (C) 2005-2012 Regis Houssin         <regis.houssin@capnetworks.com>
  * Copyright (C) 2006      Andre Cianfarani      <acianfa@free.fr>
- * Copyright (C) 2010-2013 Juanjo Menent         <jmenent@2byte.es>
+ * Copyright (C) 2010-2015 Juanjo Menent         <jmenent@2byte.es>
  * Copyright (C) 2012-2013 Christophe Battarel   <christophe.battarel@altairis.fr>
  * Copyright (C) 2013      Jean-Francois FERRY   <jfefe@aternatik.fr>
  * Copyright (C) 2013-2014 Florian Henry         <florian.henry@open-concept.pro>
@@ -991,8 +991,12 @@ if (empty($reshook)) {
 											$lines [$i]->fetch_optionals($lines [$i]->rowid);
 											$array_option = $lines [$i]->array_options;
 										}
+										
+										// View third's localtaxes for now
+										$localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->client);
+										$localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->client);
 
-										$result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option);
+										$result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $localtax1_tx, $localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $date_start, $date_end, 0, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $object->origin, $lines [$i]->rowid, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option);
 
 										if ($result > 0) {
 											$lineid = $result;
-- 
GitLab