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