From 573feed66fecbefd2ed45f2a92d46964a7208e0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 25 Jul 2020 02:59:49 +0200 Subject: [PATCH] FIX locataxes lost on lines when cloning a vendor invoice --- htdocs/core/lib/price.lib.php | 4 ++-- htdocs/fourn/class/fournisseur.facture.class.php | 6 +++++- htdocs/fourn/facture/card.php | 2 +- htdocs/societe/card.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 81c62958418..2cb8d8e30f6 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -40,8 +40,8 @@ * @param float $pu Unit price (HT or TTC selon price_base_type) * @param float $remise_percent_ligne Discount for line * @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array) - * @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. - * @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. + * @param float $uselocaltax1_rate 0=do not use localtax1, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. + * @param float $uselocaltax2_rate 0=do not use localtax2, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1. * @param float $remise_percent_global 0 * @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC * @param int $info_bits Miscellaneous informations on line diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b877cd0b0d6..63ca7e0d88b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -486,7 +486,7 @@ class FactureFournisseur extends CommonInvoice $idligne, $this->lines[$i]->description, $this->lines[$i]->pu_ht, - $this->lines[$i]->tva_tx, + $this->lines[$i]->tva_tx.($this->lines[$i]->vat_src_code ? ' ('.$this->lines[$i]->vat_src_code.')' : ''), $this->lines[$i]->localtax1_tx, $this->lines[$i]->localtax2_tx, $this->lines[$i]->qty, @@ -1945,6 +1945,8 @@ class FactureFournisseur extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); + $reg = array(); + // Clean vat code $vat_src_code = ''; if (preg_match('/\((.*)\)/', $vatrate, $reg)) @@ -2648,6 +2650,8 @@ class FactureFournisseur extends CommonInvoice $object->id = 0; $object->statut = self::STATUS_DRAFT; + $object->fetch_thirdparty(); // We need it to recalculate VAT localtaxes according to main sale taxes and vendor + // Clear fields $object->ref_supplier = (empty($this->ref_supplier) ? $langs->trans("CopyOf").' '.$object->ref_supplier : $this->ref_supplier); $object->author = $user->id; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 2113d7ebb12..10cf8ee1b6f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2013 Regis Houssin diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 97226314209..2ac6d0d33f3 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2044,7 +2044,7 @@ else print ''; } print ''; - if ($conf->browser->layout == 'phone') print ''; + print ''; print ''.$form->editfieldkey($langs->transcountry("LocalTax2IsUsed", $mysoc->country_code), 'localtax2assuj_value', '', $object, 0).''; print $form->selectyesno('localtax2assuj_value', $object->localtax2_assuj, 1); if (!isOnlyOneLocalTax(2))