From 598d1fc9143c28b75ee2e311a9e1651d987cc177 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 5 Mar 2019 16:53:36 +0100 Subject: [PATCH 1/8] FIX : extrafields always visible on view mode --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5bb557cac2c..c16ee425cad 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6299,6 +6299,7 @@ abstract class CommonObject } if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + elseif($mode == 'view' && empty($visibility)) continue; if (empty($perms)) continue; // Load language if required From c06d2f6c3b019a976458e3bc89d8dd1ffb398435 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Mar 2019 18:22:03 +0100 Subject: [PATCH 2/8] Remove warning --- htdocs/install/upgrade2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index b1f0fc68254..4e5e116a599 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -186,7 +186,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 { // Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE // Version to install is DOL_VERSION - $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:$conf->global->MAIN_VERSION_LAST_INSTALL); + $dolibarrlastupgradeversionarray=preg_split('/[\.-]/',isset($conf->global->MAIN_VERSION_LAST_UPGRADE)?$conf->global->MAIN_VERSION_LAST_UPGRADE:(isset($conf->global->MAIN_VERSION_LAST_INSTALL)?$conf->global->MAIN_VERSION_LAST_INSTALL:'')); // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec // dans la 1ere colonne, la description de l'action a faire From e163849d05ec8f28c64bdc94f4cb9cb04f80b71e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 19:13:59 +0100 Subject: [PATCH 3/8] Fix label --- htdocs/langs/en_US/blockedlog.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index 5081b1c0384..9e8771ad68b 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -14,9 +14,9 @@ OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to prev AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority ShowDetails=Show stored details -logPAYMENT_VARIOUS_CREATE=Payment (not assigned to invoice) created -logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to invoice) modified -logPAYMENT_VARIOUS_DELETE=Payment (not assigned to invoice) logical deletion +logPAYMENT_VARIOUS_CREATE=Payment (not assigned to an invoice) created +logPAYMENT_VARIOUS_MODIFY=Payment (not assigned to an invoice) modified +logPAYMENT_VARIOUS_DELETE=Payment (not assigned to an invoice) logical deletion logPAYMENT_ADD_TO_BANK=Payment added to bank logPAYMENT_CUSTOMER_CREATE=Customer payment created logPAYMENT_CUSTOMER_DELETE=Customer payment logical deletion From 31c296f44b795503858b9aa26682b05f6dd29430 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 20:01:21 +0100 Subject: [PATCH 4/8] Fix bad tooltip to rm file --- htdocs/admin/system/filecheck.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index ba8307792fc..f00164698e8 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -339,8 +339,8 @@ if (! $error && $xml) $out.=''.$i.'' . "\n"; $out.=''.$file['filename']; if (! preg_match('/^win/i',PHP_OS)) { - $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'); + $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } $out.='' . "\n"; $out.=''.$file['expectedmd5'].'' . "\n"; From b15e00cae798c8792a7b5c7aef104bdfa94f665b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Mar 2019 21:39:09 +0100 Subject: [PATCH 5/8] FIX Autodetect buy price for invoices autogenerated with templates. --- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 31 +++++++++++++++++-- htdocs/product/class/product.class.php | 7 +++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 1df96583ce3..e37d2c3d2a9 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1129,7 +1129,7 @@ if (empty($reshook)) // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); - $id = $object->create($user); // This include recopy of links from recurring invoice and invoice lines + $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index dda877d0a1f..86ee5482261 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -723,7 +723,7 @@ class Facture extends CommonInvoice } /* - * Insert lines of predefined invoices + * Insert lines of template invoices */ if (! $error && $this->fac_rec > 0) { @@ -749,6 +749,31 @@ class Facture extends CommonInvoice $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; + $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price; + $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice; + // If buyprice not defined from template invoice, we try to guess the best value + if (! $buyprice && $_facrec->lines[$i]->fk_product > 0) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $producttmp = new ProductFournisseur($this->db); + $producttmp->fetch($_facrec->lines[$i]->fk_product); + + // If margin module defined on costprice, we try the costprice + // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price + // else we get the best supplier price + if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + else { + if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) + { + if ($producttmp->product_fourn_price_id > 0) + { + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU'); + } + } + } + } + $result_insert = $this->addline( $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, @@ -771,8 +796,8 @@ class Facture extends CommonInvoice '', 0, 0, - null, - 0, + $fk_product_fournisseur_price, + $buyprice, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 316a911d5a3..88b410da7fa 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1528,8 +1528,8 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Read price used by a provider. - * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. + * Read price used by a provider. + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. * This also set some properties on product like ->buyprice, ->fourn_pu, ... * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price @@ -1537,7 +1537,8 @@ class Product extends CommonObject * @param int $product_id Filter on a particular product id * @param string $fourn_ref Filter on a supplier price ref. 'none' to exclude ref in search. * @param int $fk_soc If of supplier - * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) + * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) + * @see find_min_price_product_fournisseur() */ function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) { From c5131167171cd9c1f977599c47ea18fc88e5f722 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 10:56:48 +0100 Subject: [PATCH 6/8] FIX missing vat_src_code when inserting an expense report line --- htdocs/expensereport/class/expensereport.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a8e5f80244c..dd2818f28bf 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1729,6 +1729,7 @@ class ExpenseReport extends CommonObject $tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type); $this->line->value_unit = $up; + $this->line->vat_src_code = $vat_src_code; $this->line->vatrate = price2num($vatrate); $this->line->total_ttc = $tmp[2]; $this->line->total_ht = $tmp[0]; From 2cd09aaf0929181894da2660e46e3deed8df9901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 10:57:15 +0100 Subject: [PATCH 7/8] Prepare version 9.0.2 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b2213c5d03c..03f949c6fe6 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.2'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 96d4e2847324d093a1fd7709ea637ef0f750e8a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 11:08:01 +0100 Subject: [PATCH 8/8] FIX Vat src code lost after editing expense report line --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index eb71a30e083..fab70b1200a 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2137,7 +2137,7 @@ else // VAT print ''; - print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, ''); + print $form->load_tva('vatrate', (isset($_POST["vatrate"])?$_POST["vatrate"]:$line->vatrate), $mysoc, '', 0, 0, '', false, 1); print ''; // Unit price