Fix error management on generation of direct debit or cedit transfer
payment.
This commit is contained in:
parent
ec2c637a90
commit
d4ac4ff01a
3 changed files with 16 additions and 35 deletions
|
|
@ -163,7 +163,7 @@ if (empty($reshook)) {
|
|||
if ($action == 'setinfocredit' && $permissiontocreditdebit) {
|
||||
$dt = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
|
||||
|
||||
if (($object->type != 'bank-transfer' && $object->statut == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
|
||||
if (($object->type != 'bank-transfer' && $object->status == BonPrelevement::STATUS_CREDITED) || ($object->type == 'bank-transfer' && $object->statut == BonPrelevement::STATUS_DEBITED)) {
|
||||
$error = 1;
|
||||
setEventMessages('WithdrawalCantBeCreditedTwice', array(), 'errors');
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1158,7 +1158,7 @@ class BonPrelevement extends CommonObject
|
|||
if ($obj) {
|
||||
$thirdpartyBANId = $obj->fk_societe_rib;
|
||||
|
||||
dol_syslog(__METHOD__ . " Found an BAN ID to use: ".$thirdpartyBANId);
|
||||
dol_syslog(__METHOD__ . " Found a BAN ID to use: ".$thirdpartyBANId);
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
|
@ -1285,13 +1285,15 @@ class BonPrelevement extends CommonObject
|
|||
|
||||
if (count($factures) > 0) {
|
||||
foreach ($factures as $key => $fac) {
|
||||
//var_dump($type, $format, $fac[8], $fac[12]);
|
||||
|
||||
// Check if $fac[8] s.nom is null
|
||||
if ($fac[8] != null) {
|
||||
if ($type != 'bank-transfer') {
|
||||
if ($format == 'FRST' && $fac[12] != 'FRST') {
|
||||
if ($format == 'FRST' && $fac[12] && $fac[12] != 'FRST') {
|
||||
continue;
|
||||
}
|
||||
if ($format == 'RCUR' && $fac[12] != 'RCUR') {
|
||||
if ($format == 'RCUR' && $fac[12] && $fac[12] != 'RCUR') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1373,17 +1375,9 @@ class BonPrelevement extends CommonObject
|
|||
|
||||
// Withdraw invoices in factures_prev array
|
||||
$out = count($factures_prev) . " invoices or salaries will be included.";
|
||||
//print $out."\n";
|
||||
dol_syslog($out);
|
||||
|
||||
// Return warning
|
||||
/*$i=0;
|
||||
foreach ($this->thirdparty_in_error as $key => $val)
|
||||
{
|
||||
if ($i < 10) setEventMessages($val, null, 'warnings');
|
||||
else setEventMessages('More error were discarded...', null, 'warnings');
|
||||
$i++;
|
||||
}*/
|
||||
//var_dump($factures_prev, $this->invoice_in_error, $this->thirdparty_in_error);exit;
|
||||
|
||||
if (count($factures_prev) > 0) {
|
||||
if ($mode == 'real') {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ if ($reshook < 0) {
|
|||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
if ($action == 'create' && $permissiontocreate) {
|
||||
if ($action == 'create' && $permissiontocreate && GETPOSTISSET('createtransferrequest')) {
|
||||
$default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
|
||||
//var_dump($default_account);var_dump(getDolGlobalString($default_account));var_dump($id_bankaccount);exit;
|
||||
|
||||
|
|
@ -144,6 +144,7 @@ if (empty($reshook)) {
|
|||
if (!$error) {
|
||||
// getDolGlobalString('PRELEVEMENT_CODE_BANQUE') and getDolGlobalString('PRELEVEMENT_CODE_GUICHET') should be empty (we don't use them anymore)
|
||||
$result = $bprev->create(getDolGlobalString('PRELEVEMENT_CODE_BANQUE'), getDolGlobalString('PRELEVEMENT_CODE_GUICHET'), $mode, $format, $executiondate, 0, $type, $toselect, 0, $sourcetype);
|
||||
|
||||
if ($result < 0) {
|
||||
$mesg = '';
|
||||
|
||||
|
|
@ -299,13 +300,15 @@ print '<div class="clearboth"></div>';
|
|||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print '<div class="tabsAction">'."\n";
|
||||
|
||||
print '<form id="createBankTransfer" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
|
||||
print '<input type="hidden" name="action" value="create">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<input type="hidden" name="sourcetype" value="'.$sourcetype.'">';
|
||||
//print '<input type="hidden" name="listofselectedids" value="'.$sourcetype.'">';
|
||||
|
||||
print '<div class="tabsAction">'."\n";
|
||||
|
||||
if ($nb) {
|
||||
if ($pricetowithdraw) {
|
||||
|
|
@ -349,14 +352,14 @@ if ($nb) {
|
|||
print '<option value="RCUR"'.($format == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
|
||||
print '</select>';
|
||||
}
|
||||
print '<input type="submit" class="butAction margintoponly marginbottomonly" value="'.$title.'"/>';
|
||||
print '<input type="submit" class="butAction margintoponly marginbottomonly" name="createtransferrequest" value="'.$title.'"/>';
|
||||
} else {
|
||||
$title = $langs->trans("CreateAll");
|
||||
if ($type == 'bank-transfer') {
|
||||
$title = $langs->trans("CreateFileForPaymentByBankTransfer");
|
||||
}
|
||||
print '<input type="hidden" name="format" value="ALL">'."\n";
|
||||
print '<input type="submit" class="butAction margintoponly marginbottomonly" value="'.$title.'">'."\n";
|
||||
print '<input type="submit" class="butAction margintoponly marginbottomonly" name="createtransferrequest" value="'.$title.'">'."\n";
|
||||
}
|
||||
} else {
|
||||
if ($mysoc->isInSEPA()) {
|
||||
|
|
@ -390,22 +393,6 @@ if ($nb) {
|
|||
print "</a>\n";
|
||||
}
|
||||
|
||||
print "</form>\n";
|
||||
|
||||
// Send selected lines to build the transfer file
|
||||
print '<script>
|
||||
$().ready(() => {
|
||||
let form_create_transfer = $("#createBankTransfer");
|
||||
let form_list = $("#searchFormList");
|
||||
form_create_transfer.submit(() => {
|
||||
let selected_lines = Array.from(document.querySelectorAll("input.checkforselect:checked"))
|
||||
selected_lines.map(line => {
|
||||
form_create_transfer.append(line);
|
||||
})
|
||||
})
|
||||
})
|
||||
</script>';
|
||||
|
||||
print "</div>\n";
|
||||
|
||||
// Show errors or warnings
|
||||
|
|
@ -502,8 +489,8 @@ if ($resql) {
|
|||
$param .= "&option=".urlencode($option);
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
//print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
|
||||
//print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
if (!empty($limit)) {
|
||||
print '<input type="hidden" name="limit" value="'.$limit.'"/>';
|
||||
|
|
|
|||
Loading…
Reference in a new issue