From 17e25f5344b40ea1938f5974ac568eab1c863a3d Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 9 Nov 2018 14:01:41 +0100 Subject: [PATCH 1/5] FIX: Restore lost functionality of making a single payment for a withdrawal --- htdocs/admin/prelevement.php | 39 ++++++++++++++- .../class/bonprelevement.class.php | 49 +++++++++++++------ htdocs/langs/en_US/withdrawals.lang | 1 + 3 files changed, 74 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index cdfcd451f2c..37ee8f3064b 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2014 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2018 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,6 +121,24 @@ if ($action == "deletenotif") exit; } +//Activate "Disable prospect/customer type" +if ($action=="setdisablepaymentpercustomer") { + $setdisablepaymentcustomer = GETPOST('value','int'); + $res = dolibarr_set_const($db, "WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER", $setdisablepaymentcustomer,'yesno',0,'',$conf->entity); + if ((!$res) > 0) { + $error++; + } + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + /* if ($action == 'specimen') { @@ -243,6 +261,25 @@ print ''; print ''; print ''; + +// Payment mode +print ''; +print ''.$langs->trans("PrelevementDisablePaymentPerCustomer").''; +print ''; +if (!empty($conf->global->WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER)) +{ + print ''; + print img_picto($langs->trans("Activated"),'switch_on'); +} +else +{ + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); +} +print ''; +print ''; + + print ''; print '
'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 9d2b828b3eb..99c7e7d5490 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2010-2018 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014-2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI @@ -473,20 +473,44 @@ class BonPrelevement extends CommonObject } } - // Make one payment per customer - foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) - { + if (empty($conf->global->WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER)) { + + // Make one payment per customer + foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) { + $paiement = new Paiement($this->db); + $paiement->datepaye = $date; + $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice + $paiement->paiementid = 3; // + $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->id_prelevement = $this->id; + + $paiement_id = $paiement->create($user); + if ($paiement_id < 0) { + dol_syslog(get_class($this) . "::set_infocredit AddPayment Error"); + $error++; + } else { + $result = $paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); + if ($result < 0) { + dol_syslog(get_class($this) . "::set_infocredit AddPaymentToBank Error"); + $error++; + } + } + //var_dump($paiement->amounts); + //var_dump($thirdpartyid); + //var_dump($cursoramounts); + } + } else { $paiement = new Paiement($this->db); - $paiement->datepaye = $date; - $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref; // Set ref of direct debit note + $paiement->datepaye = $date ; + $paiement->amounts = $amounts; + $paiement->paiementid = 3; // + $paiement->num_paiement = $this->ref ; $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); if ($paiement_id < 0) { - dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); + dol_syslog("BonPrelevement::set_credite AddPayment Error"); $error++; } else @@ -494,15 +518,12 @@ class BonPrelevement extends CommonObject $result=$paiement->addPaymentToBank($user,'payment','(WithdrawalPayment)',$bankaccount,'',''); if ($result < 0) { - dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); + dol_syslog("BonPrelevement::set_credite AddPaymentToBank Error"); $error++; } } - //var_dump($paiement->amounts); - //var_dump($thirdpartyid); - //var_dump($cursoramounts); - } + } // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; diff --git a/htdocs/langs/en_US/withdrawals.lang b/htdocs/langs/en_US/withdrawals.lang index c2c384793c4..9597e32ed18 100644 --- a/htdocs/langs/en_US/withdrawals.lang +++ b/htdocs/langs/en_US/withdrawals.lang @@ -67,6 +67,7 @@ NumeroNationalEmetter=National Transmitter Number WithBankUsingRIB=For bank accounts using RIB WithBankUsingBANBIC=For bank accounts using IBAN/BIC/SWIFT BankToReceiveWithdraw=Bank account to receive direct debit +PrelevementDisablePaymentPerCustomer=Disable make one payment per customer of witdhdrawal.
If the option is active a single payment will be made for the entire withdrawal CreditDate=Credit on WithdrawalFileNotCapable=Unable to generate withdrawal receipt file for your country %s (Your country is not supported) ShowWithdraw=Show Withdraw From cdb2f825b766ce96d4ab779ad2fca3f61db59a29 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 9 Nov 2018 14:04:38 +0100 Subject: [PATCH 2/5] FIX: Restore lost functionality of making a single payment for a withdrawal --- htdocs/admin/prelevement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 37ee8f3064b..f5955314c1f 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -121,7 +121,7 @@ if ($action == "deletenotif") exit; } -//Activate "Disable prospect/customer type" +//Activate or Disable one payment by customer if ($action=="setdisablepaymentpercustomer") { $setdisablepaymentcustomer = GETPOST('value','int'); $res = dolibarr_set_const($db, "WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER", $setdisablepaymentcustomer,'yesno',0,'',$conf->entity); From 38bb046abb1baa28ddfea03912505783a2e01d9f Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 26 Jul 2019 12:38:49 +0200 Subject: [PATCH 3/5] NEW: Add hidden option SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT for add possibility to update supplier buying price in the reception on a supplier order --- htdocs/fourn/commande/dispatch.php | 58 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 48599a5bbf2..6e1bd41ea24 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2019 Juanjo Menent * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017 Ferran Marcet @@ -239,6 +239,16 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2]; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + if (! empty($dto)) { + $unit_price = price2num(GETPOST("pu_" . $reg[1]) * (100 - $dto) / 100, 'MU'); + } + $saveprice = "saveprice_" . $reg[1] . '_' . $reg[2]; + } + } + // We ask to move a qty if (GETPOST($qty) != 0) { if (! (GETPOST($ent, 'int') > 0)) { @@ -254,6 +264,24 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) setEventMessages($object->error, $object->errors, 'errors'); $error ++; } + + if (! $error && ! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); + //update supplier price + if (isset($_POST[$saveprice])) { + // TODO Use class + $sql = "UPDATE " . MAIN_DB_PREFIX . "product_fournisseur_price"; + $sql .= " SET unitprice='" . GETPOST($pu) . "'"; + $sql .= ", price=" . GETPOST($pu) . "*quantity"; + $sql .= ", remise_percent='" . $dto . "'"; + $sql .= " WHERE fk_soc=" . $object->socid; + $sql .= " AND fk_product=" . GETPOST($prod, 'int'); + + $resql = $db->query($sql); + } + } + } } } } @@ -552,6 +580,15 @@ if ($id > 0 || ! empty($ref)) { print '' . $langs->trans("QtyDispatchedShort") . ''; print '' . $langs->trans("QtyToDispatchShort") . ''; print ''; + + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + print '' . $langs->trans("Price") . ''; + print '' . $langs->trans("ReductionShort") . ' (%)'; + print '' . $langs->trans("UpdatePrice") . ''; + } + } + print '' . $langs->trans("Warehouse") . ''; // Enable hooks to append additional columns @@ -760,6 +797,25 @@ if ($id > 0 || ! empty($ref)) { print ''; + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { + if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { + // Price + print ''; + print ''; + print ''; + + // Discount + print ''; + print ''; + print ''; + + // Save price + print ''; + print ''; + print ''; + } + } + // Warehouse print ''; if (count($listwarehouses) > 1) { From f67f99099caf793c96a835d0790c1d17193723a2 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 26 Jul 2019 12:45:46 +0200 Subject: [PATCH 4/5] NEW: Add hidden option SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT for add possibility to update supplier buying price in the reception on a supplier order --- .../class/bonprelevement.class.php | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 52b9ac8ac27..1a98c33ab02 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1,7 +1,7 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2018 Juanjo Menent + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2010-2015 Juanjo Menent * Copyright (C) 2010-2014 Laurent Destailleur * Copyright (C) 2014-2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI @@ -473,44 +473,20 @@ class BonPrelevement extends CommonObject } } - if (empty($conf->global->WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER)) { - - // Make one payment per customer - foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) { - $paiement = new Paiement($this->db); - $paiement->datepaye = $date; - $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref; // Set ref of direct debit note - $paiement->id_prelevement = $this->id; - - $paiement_id = $paiement->create($user); - if ($paiement_id < 0) { - dol_syslog(get_class($this) . "::set_infocredit AddPayment Error"); - $error++; - } else { - $result = $paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); - if ($result < 0) { - dol_syslog(get_class($this) . "::set_infocredit AddPaymentToBank Error"); - $error++; - } - } - //var_dump($paiement->amounts); - //var_dump($thirdpartyid); - //var_dump($cursoramounts); - } - } else { + // Make one payment per customer + foreach ($amountsperthirdparty as $thirdpartyid => $cursoramounts) + { $paiement = new Paiement($this->db); - $paiement->datepaye = $date ; - $paiement->amounts = $amounts; - $paiement->paiementid = 3; // - $paiement->num_paiement = $this->ref ; + $paiement->datepaye = $date; + $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice + $paiement->paiementid = 3; // + $paiement->num_paiement = $this->ref; // Set ref of direct debit note $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); if ($paiement_id < 0) { - dol_syslog("BonPrelevement::set_credite AddPayment Error"); + dol_syslog(get_class($this)."::set_infocredit AddPayment Error"); $error++; } else @@ -518,12 +494,15 @@ class BonPrelevement extends CommonObject $result=$paiement->addPaymentToBank($user, 'payment', '(WithdrawalPayment)', $bankaccount, '', ''); if ($result < 0) { - dol_syslog("BonPrelevement::set_credite AddPaymentToBank Error"); + dol_syslog(get_class($this)."::set_infocredit AddPaymentToBank Error"); $error++; } } - + //var_dump($paiement->amounts); + //var_dump($thirdpartyid); + //var_dump($cursoramounts); } + // Update withdrawal line // TODO: Translate to ligneprelevement.class.php $sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes"; From aba9eafeea4bedb693f02709a0d3d0f902744048 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 30 Jul 2019 21:42:53 +0200 Subject: [PATCH 5/5] Update dispatch.php --- htdocs/fourn/commande/dispatch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 6e1bd41ea24..df29d329e0d 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -239,7 +239,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $pu = "pu_" . $reg[1] . '_' . $reg[2]; // This is unit price including discount $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2]; - if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { $dto = GETPOST("dto_" . $reg[1] . '_' . $reg[2]); if (! empty($dto)) { @@ -581,7 +581,7 @@ if ($id > 0 || ! empty($ref)) { print '' . $langs->trans("QtyToDispatchShort") . ''; print ''; - if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT )) { + if (! empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) { if (empty($conf->multicurrency->enabled) && empty($conf->dynamicprices->enabled)) { print '' . $langs->trans("Price") . ''; print '' . $langs->trans("ReductionShort") . ' (%)';