From 703d4a6aeebaa87c391910eaa20a9447b08d8763 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Oct 2017 14:02:24 +0200 Subject: [PATCH 1/4] FIX #7648 --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/facture/card.php | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 43f2250b508..7a17de63926 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1499,7 +1499,7 @@ class FactureFournisseur extends CommonInvoice * @param int $id Id of line invoice * @param string $desc Description of line * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) - * @param double $vatrate VAT Rate + * @param double $vatrate VAT Rate (Can be '8.5', '8.5 (ABC)') * @param double $txlocaltax1 LocalTax1 Rate * @param double $txlocaltax2 LocalTax2 Rate * @param double $qty Quantity diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 46eadf97c28..156590fb286 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -810,7 +810,7 @@ if (empty($reshook)) $object->fetch($id); $object->fetch_thirdparty(); - $tva_tx = GETPOST('tva_tx'); + $tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); if (GETPOST('price_ht') != '') { @@ -841,8 +841,16 @@ if (empty($reshook)) $date_start=dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_end=dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); - $localtax1_tx= get_localtax($_POST['tauxtva'], 1, $mysoc,$object->thirdparty); - $localtax2_tx= get_localtax($_POST['tauxtva'], 2, $mysoc,$object->thirdparty); + // Define info_bits + $info_bits = 0; + if (preg_match('/\*/', $tva_tx)) + $info_bits |= 0x01; + + // Define vat_rate + $tva_tx = str_replace('*', '', $tva_tx); + $localtax1_tx= get_localtax($tva_tx, 1, $mysoc,$object->thirdparty); + $localtax2_tx= get_localtax($tva_tx, 2, $mysoc,$object->thirdparty); + $remise_percent=GETPOST('remise_percent'); $pu_ht_devise = GETPOST('multicurrency_subprice'); @@ -857,7 +865,7 @@ if (empty($reshook)) } } - $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise); + $result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units'], $pu_ht_devise); if ($result >= 0) { unset($_POST['label']); From be0cd601a98f054e27799f0efb13fff6f17a5d5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Oct 2017 14:07:54 +0200 Subject: [PATCH 2/4] Fix dead code --- htdocs/fourn/facture/card.php | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 156590fb286..c5e85c7ffe4 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -738,38 +738,6 @@ if (empty($reshook)) { $error++; } - - if (! $error) - { - // If some invoice's lines already known - for ($i = 1 ; $i < 9 ; $i++) - { - $label = $_POST['label'.$i]; - $amountht = price2num($_POST['amount'.$i]); - $amountttc = price2num($_POST['amountttc'.$i]); - $tauxtva = price2num($_POST['tauxtva'.$i]); - $qty = $_POST['qty'.$i]; - $fk_product = $_POST['fk_product'.$i]; - if ($label) - { - if ($amountht) - { - $price_base='HT'; $amount=$amountht; - } - else - { - $price_base='TTC'; $amount=$amountttc; - } - $atleastoneline=1; - - $product=new Product($db); - $product->fetch($_POST['idprod'.$i]); - - $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1); - if ($ret < 0) $error++; - } - } - } } } } From 745c4625a62699501e8a67e290cd47271395a1b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Oct 2017 14:48:42 +0200 Subject: [PATCH 3/4] FIX #7619 --- htdocs/societe/class/api_contacts.class.php | 4 +++- htdocs/societe/class/api_thirdparties.class.php | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index fcfdf4ad084..5f52c2b775c 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -19,6 +19,7 @@ use Luracast\Restler\RestException; //require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; + /** * API class for contacts * @@ -48,7 +49,8 @@ class Contacts extends DolibarrApi global $db, $conf; $this->db = $db; - include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $this->contact = new Contact($this->db); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 292288d9015..2b71e59badf 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -47,6 +47,10 @@ class Thirdparties extends DolibarrApi { global $db, $conf; $this->db = $db; + + require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $this->company = new Societe($this->db); if (! empty($conf->global->SOCIETE_MAIL_REQUIRED)) { From 79279caa2e4d0eec54c2a39d8a908d655670927e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Oct 2017 14:56:00 +0200 Subject: [PATCH 4/4] FIX #7619 --- htdocs/societe/class/api_contacts.class.php | 3 ++- htdocs/societe/class/api_thirdparties.class.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 5f52c2b775c..04bd8d1b054 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -336,7 +336,8 @@ class Contacts extends DolibarrApi * @url GET {id}/categories */ function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - $categories = new Categories(); + require_once DOL_DOCUMENT_ROOT.'/categories/class/api_categories.class.php'; + $categories = new Categories(); // TODO Use Categories object not API object return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'contact', $id); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 2b71e59badf..6d6d9efb3cf 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -271,7 +271,8 @@ class Thirdparties extends DolibarrApi * @url GET {id}/categories */ function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - $categories = new Categories(); + require_once DOL_DOCUMENT_ROOT.'/categories/class/api_categories.class.php'; + $categories = new Categories(); // TODO Use Categories object not API object return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'customer', $id); }