FIX: Restore lost functionality of making a single payment for a withdrawal
This commit is contained in:
parent
773e2da4cc
commit
17e25f5344
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
|
||||
*
|
||||
* 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 '<td align="left">';
|
||||
print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->USTRD.'" size="15" ></td>';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Payment mode
|
||||
print '<tr class="oddeven">';
|
||||
print '<td width="80%">'.$langs->trans("PrelevementDisablePaymentPerCustomer").'</td>';
|
||||
print '<td align="center">';
|
||||
if (!empty($conf->global->WITHDRAWAL_DISABLE_PAYMENT_PER_CUSTOMER))
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisablepaymentpercustomer&value=0">';
|
||||
print img_picto($langs->trans("Activated"),'switch_on');
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setdisablepaymentpercustomer&value=1">';
|
||||
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||
}
|
||||
print '</a></td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2015 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2018 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014-2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
@ -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";
|
||||
|
||||
@ -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.<br>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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user