From 30d58f77db555c807251c4dfe1e0eb7ba1a7d486 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 11 Apr 2017 11:33:05 +0200 Subject: [PATCH 01/13] FIX : forgotten parameter for right multicompany use --- htdocs/contact/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 81f9b2a29be..2d8fe5b1d2e 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'contact', $id, '',''); +$result = restrictedArea($user, 'contact', $id, 'socpeople&societe'); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); From 8a373b25ba04c33300ccd38fc5b02ad5c0ce1bd2 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 11 Apr 2017 12:41:19 +0200 Subject: [PATCH 02/13] FIX : global $dateSelector isn't the good one, then date selector on objectline_create tpl was hidden --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index c43380a9e7a..c6f6a638c6c 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -37,7 +37,7 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob $usemargins=1; } -global $dateSelector, $forceall, $senderissupplier, $inputalsopricewithtax; +global $forceall, $senderissupplier, $inputalsopricewithtax; if (empty($dateSelector)) $dateSelector=0; if (empty($forceall)) $forceall=0; if (empty($senderissupplier)) $senderissupplier=0; From 396ea5489419f61b936510c49b010e6abb95974e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 12 Apr 2017 11:09:49 +0200 Subject: [PATCH 03/13] Subprice was null in supplier proposal and line was not transfered to supplier order --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d14591b6b9f..8cbc3882fc4 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2781,7 +2781,7 @@ class SupplierProposalLine extends CommonObject $sql.= " ".price2num($this->localtax2_tx).","; $sql.= " '".$this->localtax1_type."',"; $sql.= " '".$this->localtax2_type."',"; - $sql.= " ".($this->subprice?price2num($this->subprice):"null").","; + $sql.= " ".price2num($this->subprice).","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->info_bits."'":"null").","; $sql.= " ".price2num($this->total_ht).","; From e23a44bcdf49d8e15062ec04d233ae3968604db1 Mon Sep 17 00:00:00 2001 From: Christian Seiler Date: Sun, 16 Apr 2017 11:09:18 +0200 Subject: [PATCH 04/13] Added missing Slashes fixed line where two slashes were missing, that caused an error when creating barcodes. --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 82449ac63cb..6d72a668269 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1074,7 +1074,7 @@ function check_value($mask,$value) // If an offset is asked if (! empty($reg[2]) && preg_match('/^\+/',$reg[2])) $maskoffset=preg_replace('/^\+/','',$reg[2]); - if (! empty($reg[3]) && preg_match('^\+',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); + if (! empty($reg[3]) && preg_match('/^\+/',$reg[3])) $maskoffset=preg_replace('/^\+/','',$reg[3]); // Define $sqlwhere From 433b9e6fe17840ba401415bff7d4f62d1200cec0 Mon Sep 17 00:00:00 2001 From: fappels Date: Tue, 18 Apr 2017 16:22:39 +0200 Subject: [PATCH 05/13] Fix typo in en_US admin tag --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index be60fc5db7c..068e44d920d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -286,7 +286,7 @@ FindPackageFromWebSite=Find a package that provides feature you want (for exampl DownloadPackageFromWebSite=Download package (for example from official web site %s). UnpackPackageInDolibarrRoot=Unpack package files into Dolibarr server directory dedicated to Dolibarr: %s UnpackPackageInModulesRoot=Unpack package files into Dolibarr server directory dedicated to modules: %s -oiSetupIsReadyForUse=Module deployement is finished. You must however enable and setup the module in your application by going on the page to setup modules: %s. +SetupIsReadyForUse=Module deployement is finished. You must however enable and setup the module in your application by going on the page to setup modules: %s. NotExistsDirect=The alternative root directory is not defined.
InfDirAlt=Since version 3 it is possible to define an alternative root directory.This allows you to store, same place, plug-ins and custom templates.
Just create a directory at the root of Dolibarr (eg: custom).
InfDirExample=
Then declare it in the file conf.php
$dolibarr_main_url_root_alt='http://myserver/custom'
$dolibarr_main_document_root_alt='/path/of/dolibarr/htdocs/custom'
*These lines are commented with "#", to uncomment only remove the character. From 54256773c558f5599a2111c6010fc1ab1a8f6335 Mon Sep 17 00:00:00 2001 From: hugome Date: Fri, 21 Apr 2017 10:27:48 +0200 Subject: [PATCH 06/13] FIX: length_accounta return variable name --- htdocs/core/lib/accounting.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 8ec0713b01a..4d32aa899b3 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -151,7 +151,7 @@ function length_accounta($accounta) if ($accounta < 0 || empty($accounta)) return ''; - if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $account; + if (! empty($conf->global->ACCOUNTING_MANAGE_ZERO)) return $accounta; $a = $conf->global->ACCOUNTING_LENGTH_AACCOUNT; if (! empty($a)) { From cd099bf3b1f02681176ec6e384825bb312e6ab32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 12:42:54 +0200 Subject: [PATCH 07/13] Fix bad update of prices --- htdocs/product/admin/product_tools.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 0d3ea7584f1..7e66181fdbc 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -42,8 +42,6 @@ $oldvatrate=GETPOST('oldvatrate'); $newvatrate=GETPOST('newvatrate'); //$price_base_type=GETPOST('price_base_type'); -$objectstatic = new Product($db); -$objectstatic2 = new ProductFournisseur($db); /* @@ -87,6 +85,7 @@ if ($action == 'convert') { $obj = $db->fetch_object($resql); + $objectstatic = new Product($db); // Object init must be into loop to avoid to get value of previous step $ret=$objectstatic->fetch($obj->rowid); if ($ret > 0) { @@ -150,7 +149,8 @@ if ($action == 'convert') if ($ret < 0 || $retm < 0) $error++; else $nbrecordsmodified++; } - + unset($objectstatic); + $i++; } } @@ -176,6 +176,7 @@ if ($action == 'convert') { $obj = $db->fetch_object($resql); + $objectstatic2 = new ProductFournisseur($db); // Object init must be into loop to avoid to get value of previous step $ret=$objectstatic2->fetch_product_fournisseur_price($obj->rowid); if ($ret > 0) { @@ -207,6 +208,8 @@ if ($action == 'convert') if ($ret < 0 || $retm < 0) $error++; else $nbrecordsmodified++; } + unset($objectstatic2); + $i++; } } From a2287fd1830083b998c5274212563c78bf5c1b44 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Apr 2017 13:46:41 +0200 Subject: [PATCH 08/13] Add example of sql request to fix llx_product_price --- htdocs/install/mysql/migration/repair.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 6b9ea2a16f7..b5ed611ea51 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -257,3 +257,14 @@ delete from llx_commande_fournisseur_dispatch where fk_commandefourndet = 0 or f delete from llx_menu where menu_handler = 'smartphone'; +-- Clean product prices +--delete from llx_product_price where date_price between '2017-04-20 06:51:00' and '2017-04-20 06:51:05'; +-- Set product prices into llx_product with last price into llx_product_prices +--update llx_product as p set +-- p.price = (select pp.price from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1), +-- p.price_ttc = (select pp.price_ttc from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1), +-- p.price_min = (select pp.price_min from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1), +-- p.price_min_ttc = (select pp.price_min_ttc from llx_product_price as pp where pp.price_level = 1 and pp.fk_product = p.rowid order by pp.tms desc limit 1), +-- p.tva_tx = 0 +-- where price = 17.5 + From 8f97177dae03aca9df07fc2171d32df608f04bee Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Mon, 24 Apr 2017 14:44:44 +0200 Subject: [PATCH 09/13] FIX 6614 --- htdocs/compta/facture/fiche-rec.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 7217e1eedf7..4adfc24b4dc 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -889,7 +889,6 @@ if ($action == 'create') $object = new Facture($db); // Source invoice $product_static = new Product($db); - $formproject = new FormProjets($db); if ($object->fetch($id, $ref) > 0) { From 4ab5674ffbbeb8af8ada5cc8c2a5b4b7ccd39bee Mon Sep 17 00:00:00 2001 From: Quentin Vial-Gouteyron Date: Tue, 25 Apr 2017 15:10:46 +0200 Subject: [PATCH 10/13] FIX ajax autocomplete on clone --- htdocs/core/class/html.form.class.php | 13 +++++++++---- htdocs/core/lib/ajax.lib.php | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0b5778a512a..b29f7bc5bf3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -965,18 +965,23 @@ class Form } // mode 1 $urloption='htmlname='.$htmlname.'&outjson=1&filter='.$filter; - print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); + $out.=''; if (empty($hidelabel)) print $langs->trans("RefOrLabel").' : '; else if ($hidelabel > 1) { if (! empty($conf->global->MAIN_HTML5_PLACEHOLDER)) $placeholder=' placeholder="'.$langs->trans("RefOrLabel").'"'; else $placeholder=' title="'.$langs->trans("RefOrLabel").'"'; if ($hidelabel == 2) { - print img_picto($langs->trans("Search"), 'search'); + $out.= img_picto($langs->trans("Search"), 'search'); } } - print 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; + $out.= 'global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />'; if ($hidelabel == 3) { - print img_picto($langs->trans("Search"), 'search'); + $out.= img_picto($langs->trans("Search"), 'search'); } } else diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 0193a33b305..e7d8a7cf538 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -181,10 +181,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt }); } console.log("ajax_autocompleter new value selected, we trigger change on original component so field #search_'.$htmlname.'"); + $("#search_'.$htmlname.'").trigger("change"); // We have changed value of the combo select, we must be sure to trigger all js hook binded on this event. This is required to trigger other javascript change method binded on original field by other code. } ,delay: 500 }).data("ui-autocomplete")._renderItem = function( ul, item ) { + return $("
  • ") .data( "ui-autocomplete-item", item ) // jQuery UI > 1.10.0 .append( \'\' + item.label + "" ) From 3917bdfc7941e4dad37ddfc65383bcc44f62e3d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 May 2017 21:27:56 +0200 Subject: [PATCH 11/13] Fix vat_src_code propagation. --- htdocs/comm/propal/card.php | 5 ++++- htdocs/comm/propal/class/propal.class.php | 14 ++++++++++---- htdocs/commande/card.php | 5 ++++- htdocs/commande/class/commande.class.php | 8 +++++++- htdocs/compta/facture.php | 17 ++++++++++++----- htdocs/compta/facture/class/facture.class.php | 7 +++++-- htdocs/core/class/commoninvoice.class.php | 6 ++++++ htdocs/core/class/commonobject.class.php | 5 ++++- htdocs/societe/soc.php | 4 ++-- 9 files changed, 54 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8c1c579b0c2..150abdf5f46 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -492,7 +492,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $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, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b63c59ecad4..4587e960c4c 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -253,6 +253,8 @@ class Propal extends CommonObject $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); @@ -273,6 +275,7 @@ class Propal extends CommonObject $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->fk_unit=$prod->fk_unit; if ($tva_npr) $line->info_bits = 1; @@ -315,6 +318,7 @@ class Propal extends CommonObject $line->fk_propal=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->fk_product=0; // Id produit predefined @@ -698,7 +702,8 @@ class Propal extends CommonObject $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; - $this->line->product_type = $type; + $this->line->product_type = $type; + $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; @@ -708,7 +713,6 @@ class Propal extends CommonObject $this->line->subprice = $pu_ht; $this->line->info_bits = $info_bits; - $this->line->vat_src_code = $vat_src_code; $this->line->total_ht = $total_ht; $this->line->total_tva = $total_tva; $this->line->total_localtax1 = $total_localtax1; @@ -1368,7 +1372,7 @@ class Propal extends CommonObject /* * Lignes propales liees a un produit ou non */ - $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; + $sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= " d.fk_unit,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; @@ -1404,6 +1408,7 @@ class Propal extends CommonObject $line->label = $objp->custom_label; $line->desc = $objp->description; // Description ligne $line->qty = $objp->qty; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3591,7 +3596,7 @@ class PropaleLigne extends CommonObjectLine */ function fetch($rowid) { - $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; $sql.= ' pd.fk_unit,'; @@ -3617,6 +3622,7 @@ class PropaleLigne extends CommonObjectLine $this->qty = $objp->qty; $this->price = $objp->price; // deprecated $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->remise = $objp->remise; // deprecated $this->remise_percent = $objp->remise_percent; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 749f40fef4e..d99aa6a4f46 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -373,7 +373,10 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - $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, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, $lines[$i]->info_bits, $lines[$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $array_options, $lines[$i]->fk_unit, $object->origin, $lines[$i]->rowid); if ($result < 0) { $error++; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 462ba4756c5..c89fc8d11da 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1103,6 +1103,7 @@ class Commande extends CommonOrder $line->desc = $object->lines[$i]->desc; $line->price = $object->lines[$i]->price; $line->subprice = $object->lines[$i]->subprice; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1466,7 +1467,8 @@ class Commande extends CommonOrder $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - + $vat_src_code = ''; // May be defined into tva_tx + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); @@ -1485,6 +1487,7 @@ class Commande extends CommonOrder $line->qty=$qty; $line->subprice=$price; $line->remise_percent=$remise_percent; + $line->vat_src_code=$vat_src_code; $line->tva_tx=$tva_tx; $line->localtax1_tx=$localtax1_tx; $line->localtax2_tx=$localtax2_tx; @@ -1703,6 +1706,7 @@ class Commande extends CommonOrder $line->fk_commande=$this->id; $line->fk_remise_except=$remise->id; $line->desc=$remise->description; // Description ligne + $line->vat_src_code=$remise->vat_src_code; $line->tva_tx=$remise->tva_tx; $line->subprice=-$remise->amount_ht; $line->price=-$remise->amount_ht; @@ -3809,6 +3813,7 @@ class OrderLine extends CommonOrderLine $this->qty = $objp->qty; $this->price = $objp->price; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; @@ -4120,6 +4125,7 @@ class OrderLine extends CommonOrderLine $sql = "UPDATE ".MAIN_DB_PREFIX."commandedet SET"; $sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null"); + $sql.= " , vat_src_code=".(! empty($this->vat_src_code)?"'".$this->db->escape($this->vat_src_code)."'":"''"); $sql.= " , tva_tx=".price2num($this->tva_tx); $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index b71dbe0cc70..05174fd940b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1050,11 +1050,14 @@ if (empty($reshook)) } } + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + $result = $object->addline( $langs->trans('Deposit'), $amountdeposit, // subprice 1, // quantity - $lines[$i]->tva_tx, // vat rate + $tva_tx, // vat rate 0, // localtax1_tx 0, // localtax2_tx (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product @@ -1150,11 +1153,15 @@ if (empty($reshook)) $array_options = $lines[$i]->array_options; } - // View third's localtaxes for now - $localtax1_tx = get_localtax($lines[$i]->tva_tx, 1, $object->thirdparty); - $localtax2_tx = get_localtax($lines[$i]->tva_tx, 2, $object->thirdparty); + $tva_tx = $lines[$i]->tva_tx; + if (! empty($lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$lines[$i]->vat_src_code.')'; + + // View third's localtaxes for NOW and do not use value from origin. + // TODO Is this really what we want ? Yes if source if template invoice but what if proposal or order ? + $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); + $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); - $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_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); + $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $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_options, $lines[$i]->situation_percent, $lines[$i]->fk_prev_id, $lines[$i]->fk_unit); if ($result > 0) { $lineid = $result; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b80919c48b4..bc4cf3626a4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -952,6 +952,7 @@ class Facture extends CommonInvoice $line->total_ht = $object->lines[$i]->total_ht; $line->total_tva = $object->lines[$i]->total_tva; $line->total_ttc = $object->lines[$i]->total_ttc; + $line->vat_src_code = $object->lines[$i]->vat_src_code; $line->tva_tx = $object->lines[$i]->tva_tx; $line->localtax1_tx = $object->lines[$i]->localtax1_tx; $line->localtax2_tx = $object->lines[$i]->localtax2_tx; @@ -1551,6 +1552,7 @@ class Facture extends CommonInvoice $facligne->fk_facture=$this->id; $facligne->fk_remise_except=$remise->id; $facligne->desc=$remise->description; // Description ligne + $facligne->vat_src_code=$remise->vat_src_code; $facligne->tva_tx=$remise->tva_tx; $facligne->subprice=-$remise->amount_ht; $facligne->fk_product=0; // Id produit predefini @@ -2399,7 +2401,7 @@ class Facture extends CommonInvoice * @param string $desc Description of line * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity - * @param double $txtva Force Vat rate, -1 for auto + * @param double $txtva Force Vat rate, -1 for auto (Can contain the vat_src_code too with syntax '9.9 (CODE)') * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id of predefined product/service @@ -4276,7 +4278,7 @@ class FactureLigne extends CommonInvoiceLine */ function fetch($rowid) { - $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.tva_tx,'; + $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; @@ -4304,6 +4306,7 @@ class FactureLigne extends CommonInvoiceLine $this->desc = $objp->description; $this->qty = $objp->qty; $this->subprice = $objp->subprice; + $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; $this->localtax2_tx = $objp->localtax2_tx; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 05cf0b4c3cb..4dc330544ee 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -471,6 +471,12 @@ abstract class CommonInvoiceLine extends CommonObjectLine */ public $fk_product; + /** + * VAT code + * @var string + */ + public $vat_src_code; + /** * VAT % * @var float diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c9acc1f310e..1bf4a95a2c9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3567,7 +3567,7 @@ abstract class CommonObject print ''; print ''.$langs->trans('Ref').''; print ''.$langs->trans('Description').''; - print ''.$langs->trans('VAT').''; + print ''.$langs->trans('VATRate').''; print ''.$langs->trans('PriceUHT').''; if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency').''; print ''.$langs->trans('Qty').''; @@ -3698,7 +3698,10 @@ abstract class CommonObject $this->tpl['description'] = ' '; } + // VAT Rate $this->tpl['vat_rate'] = vatrate($line->tva_tx, true); + if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')'; + $this->tpl['price'] = price($line->subprice); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b5bda51b4ba..b9c962a5168 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1743,7 +1743,7 @@ else //TODO: Place into a function to control showing by country or study better option if($mysoc->localtax1_assuj=="1" && $mysoc->localtax2_assuj=="1") { - print ''.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax1IsUsed",$mysoc->country_code),'localtax1assuj_value').''; print $form->selectyesno('localtax1assuj_value',$object->localtax1_assuj,1); if(! isOnlyOneLocalTax(1)) { @@ -1752,7 +1752,7 @@ else print ''; } - print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; + print ''.fieldLabel($langs->transcountry("LocalTax2IsUsed",$mysoc->country_code),'localtax2assuj_value').''; print $form->selectyesno('localtax2assuj_value',$object->localtax2_assuj,1); if (! isOnlyOneLocalTax(2)) { From 270c3db32ebc861d6714321465a5379f4f6d71d0 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Apr 2017 16:47:06 +0200 Subject: [PATCH 12/13] fix params order for tha addline() function please check to last param "$request_data->fk_remise_except", I couldn't find a corresponding parameter name in the addline() function --- htdocs/comm/propal/class/api_proposals.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 0440793ceac..ec7ca53357a 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -260,12 +260,9 @@ class Proposals extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $request_data->info_bits, - $request_data->fk_remise_except, 'HT', 0, - $request_data->date_start, - $request_data->date_end, + $request_data->info_bits, $request_data->product_type, $request_data->rang, $request_data->special_code, @@ -273,10 +270,14 @@ class Proposals extends DolibarrApi $request_data->fk_fournprice, $request_data->pa_ht, $request_data->label, + $request_data->date_start, + $request_data->date_end, $request_data->array_options, $request_data->fk_unit, $this->element, $request_data->id + // not used anymore ? + // $request_data->fk_remise_except ); if ($updateRes > 0) { From 8318ebc1096d464b6427d0812c6d32c79265b233 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 May 2017 10:45:20 +0200 Subject: [PATCH 13/13] Fix missing field into addline of proposals --- htdocs/comm/propal/class/api_proposals.class.php | 11 ++++++----- htdocs/comm/propal/class/propal.class.php | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index ec7ca53357a..fd508b03256 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -16,9 +16,10 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; + +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; /** * API class for orders @@ -275,9 +276,9 @@ class Proposals extends DolibarrApi $request_data->array_options, $request_data->fk_unit, $this->element, - $request_data->id - // not used anymore ? - // $request_data->fk_remise_except + $request_data->id, + $request_data->pu_ht_devise, + $request_data->fk_remise_except ); if ($updateRes > 0) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 4587e960c4c..a18dbfb86b0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -395,15 +395,16 @@ class Propal extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $origin 'order', ... * @param int $origin_id Id of origin object - * @return int >0 if OK, <0 if KO * @param double $pu_ht_devise Unit price in currency + * @param int $fk_remise_except Id discount if line is from a discount + * @return int >0 if OK, <0 if KO * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise = 0) + function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0, $pu_ht_devise=0, $fk_remise_except=0) { global $mysoc, $conf, $langs; - dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); + dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type, fk_remise_except=".$fk_remise_except); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -519,6 +520,8 @@ class Propal extends CommonObject $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; $this->line->fk_product=$fk_product; + $this->line->product_type=$type; + $this->line->fk_remise_except=$fk_remise_except; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; $this->line->rang=$rangtouse; @@ -528,7 +531,6 @@ class Propal extends CommonObject $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc=$total_ttc; - $this->line->product_type=$type; $this->line->special_code=$special_code; $this->line->fk_parent_line=$fk_parent_line; $this->line->fk_unit=$fk_unit;