From 6b0b975ffda214f73c65a5679c2730025e2400b5 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 29 May 2018 10:50:20 +0200 Subject: [PATCH 1/6] FIX : Keep supplier proposal price for supplier order --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4eccc21cd93..3edb70b1ed6 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1430,7 +1430,7 @@ class CommandeFournisseur extends CommonOrder // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc - if ($result > 0) + if ($result > 0 && $origin !== 'supplier_proposal') { $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice From b65b545e0f498c5bd46d1c3c098ba6ff30410ed4 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 29 May 2018 16:29:14 +0200 Subject: [PATCH 2/6] add hook on balence pages --- htdocs/compta/recap-compta.php | 47 ++++++++++++++++++---------------- htdocs/fourn/recap-fourn.php | 8 +++--- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index c3231ecccdd..07dfa0d738e 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -54,9 +54,12 @@ if (! $sortorder) $sortorder="DESC"; $arrayfields=array( 'f.datef'=>array('label'=>"Date", 'checked'=>1), - //... + //... ); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('supplierbalencelist','globalcard')); + /* * Actions */ @@ -87,13 +90,13 @@ if ($id > 0) dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 1); dol_fiche_end(); - + if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { // Invoice list print load_fiche_titre($langs->trans("CustomerPreview")); - print ''; + print '
'; print ''; if (! empty($arrayfields['f.datef']['checked'])) print_liste_field_titre($arrayfields['f.datef']['label'],$_SERVER["PHP_SELF"],"f.datef","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); print ''; @@ -103,7 +106,7 @@ if ($id > 0) print ''; print ''; print ''; - + $TData = array(); $TDataSort = array(); @@ -135,10 +138,10 @@ if ($id > 0) continue; } $totalpaye = $fac->getSommePaiement(); - + $userstatic->id=$objf->userid; $userstatic->login=$objf->login; - + $TData[] = array( 'date' => $fac->date, 'link' => $fac->getNomUrl(1), @@ -168,13 +171,13 @@ if ($id > 0) while ($j < $nump) { $objp = $db->fetch_object($resqlp); - + $paymentstatic = new Paiement($db); $paymentstatic->id = $objp->rowid; - + $userstatic->id=$objp->userid; $userstatic->login=$objp->login; - + $TData[] = array( 'date' => $db->jdate($objp->dp), 'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1), @@ -199,11 +202,11 @@ if ($id > 0) { dol_print_error($db); } - + if(empty($TData)) { print ''; } else { - + // Sort array by date asort($TDataSort); array_multisort($TData,$TDataSort); @@ -213,37 +216,37 @@ if ($id > 0) $balance += $data1['amount']; $data1['balance'] += $balance; } - + // Reverse array to have last elements on top $TData = dol_sort_array($TData, 'date', $sortorder); - - + + $totalDebit = 0; $totalCredit = 0; - + // Display array foreach($TData as $data) { - + print ''; - + print "\n"; print '\n"; - + print ''; print '\n"; $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; print '\n"; $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); print '\n"; - + // Author print ''; - + print "\n"; } - + print ''; print ''; print ''; @@ -252,7 +255,7 @@ if ($id > 0) print ''; print "\n"; } - + print "
'.$langs->trans("Element").''.$langs->trans("Balance").''.$langs->trans("Author").'
'.$langs->trans("NoInvoice").'
".dol_print_date($data['date'],'day')."'.$data['link']."'.$data['status'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."'; print $data['author']; print '
 '.price($totalDebit).'
"; } } diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 470e6c64cc4..fc5821b96f8 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -38,6 +38,8 @@ if ($user->societe_id > 0) } +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('supplierbalencelist','globalcard')); /* * View @@ -67,7 +69,7 @@ if ($socid > 0) // Invoice list print load_fiche_titre($langs->trans("SupplierPreview")); - print ''; + print '
'; $sql = "SELECT s.nom, s.rowid as socid, f.ref_supplier, f.amount, f.datef as df,"; $sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; @@ -114,7 +116,7 @@ if ($socid > 0) } $totalpaye = $fac->getSommePaiement(); - + print ''; print "\n"; @@ -182,7 +184,7 @@ if ($socid > 0) { dol_print_error($db); } - + print "
".dol_print_date($fac->date)."
"; } } From 48a315f6cdc3f9a08530e10a3dc0dbd4d15d9e73 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 30 May 2018 10:14:34 +0200 Subject: [PATCH 3/6] FIX : Bad substitution key used for default send proposal email --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 49ebd901b05..b39693aa667 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -80,7 +80,7 @@ PredefinedMailTest=__(Hello)__\nThis is a test mail sent to __EMAIL__.\nThe two PredefinedMailTestHtml=__(Hello)__\nThis is a test mail (the word test must be in bold).
The two lines are separated by a carriage return.

__USER_SIGNATURE__ PredefinedMailContentSendInvoice=__(Hello)__\n\nYou will find here the invoice __REF__\n\nThis is the link to make your online payment if this invoice is not already payed:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendInvoiceReminder=__(Hello)__\n\nWe would like to warn you that the invoice __REF__ seems to not be payed. So this is the invoice in attachment again, as a reminder.\n\nThis is the link to make your online payment:\n__ONLINE_PAYMENT_URL__\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ -PredefinedMailContentSendProposal=__(Hello)__\n\nYou will find here the commercial proposal __PREF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ +PredefinedMailContentSendProposal=__(Hello)__\n\nYou will find here the commercial proposal __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendSupplierProposal=__(Hello)__\n\nYou will find here the price request __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendOrder=__(Hello)__\n\nYou will find here the order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ PredefinedMailContentSendSupplierOrder=__(Hello)__\n\nYou will find here our order __REF__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__ From e57ceab5de4fad7a54c6f8b613cf0dfdd2ce8857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 May 2018 10:45:06 +0200 Subject: [PATCH 4/6] Update fournisseur.commande.class.php --- htdocs/fourn/class/fournisseur.commande.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3edb70b1ed6..e84815a828e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1430,15 +1430,13 @@ class CommandeFournisseur extends CommonOrder // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc - if ($result > 0 && $origin !== 'supplier_proposal') + if ($result > 0 && $origin == 'commande') // If supplier order created from customer order, we take best supplier price { $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice // is remise percent not keyed but present for the product we add it if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent =$prod->remise_percent; - - } if ($result == 0) // If result == 0, we failed to found the supplier reference price { From 02da9b69921ac37aeab5cb06f8432e8f5e507af6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 May 2018 11:04:44 +0200 Subject: [PATCH 5/6] FIX #8893 to get formatted price as substitution vars --- htdocs/core/lib/functions.lib.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 78010725086..aa65cbd58e0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5549,6 +5549,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__AMOUNT_VAT__'] = is_object($object)?($object->total_vat?$object->total_vat:$object->total_tva):''; if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?($object->total_localtax1?$object->total_localtax1:$object->total_localtax1):''; if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?($object->total_localtax2?$object->total_localtax2:$object->total_localtax2):''; + $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; + $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; + $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency_code):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency_code)):''; + if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)?price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; + if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)?price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; /* TODO Add key for multicurrency $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency_code):''; From 60321aabd89e38b77cfbf68cc4793b2970d5cb4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 May 2018 11:59:23 +0200 Subject: [PATCH 6/6] Fix regression --- htdocs/fourn/class/fournisseur.commande.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e84815a828e..f00392f1377 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1374,7 +1374,7 @@ class CommandeFournisseur extends CommonOrder $error = 0; - dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit"); + dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit, $pu_ht_devise, $origin, $origin_id"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -1430,13 +1430,14 @@ class CommandeFournisseur extends CommonOrder // We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc - if ($result > 0 && $origin == 'commande') // If supplier order created from customer order, we take best supplier price + // If supplier order created from customer order, we take best supplier price + // If $pu (defined previously from pu_ht or pu_ttc) is not defined at all, we also take the best supplier price + if ($result > 0 && ($origin == 'commande' || $pu === '')) { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice - // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) - $remise_percent =$prod->remise_percent; + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) $remise_percent = $prod->remise_percent; } if ($result == 0) // If result == 0, we failed to found the supplier reference price {