Debug SEPA payment module

This commit is contained in:
Laurent Destailleur 2021-12-09 12:42:04 +01:00
parent 7ea8b7851a
commit ecf98530bb
3 changed files with 56 additions and 39 deletions

View File

@ -1067,12 +1067,12 @@ if ($action == 'create') {
if ($conf->prelevement->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("StandingOrder").')</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.$object->ics.'"></td></tr>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics" value="'.(GETPOSTISSET('ics') ? GETPOST('ics', 'alpha') : $object->ics).'"></td></tr>';
}
if ($conf->paymentbybanktransfer->enabled) {
print '<tr><td>'.$langs->trans("ICS").' ('.$langs->trans("BankTransfer").')</td>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics_transfer" value="'.$object->ics_transfer.'"></td></tr>';
print '<td><input class="minwidth150 maxwidth200onsmartphone" maxlength="32" type="text" class="flat" name="ics_transfer" value="'.(GETPOSTISSET('ics_transfer') ? GETPOST('ics_transfer', 'alpha') : $object->ics_transfer).'"></td></tr>';
}
print '<tr><td>'.$langs->trans("BankAccountDomiciliation").'</td><td>';

View File

@ -45,9 +45,12 @@ $type = GETPOST('type', 'aZ09');
$action = GETPOST('action', 'aZ09');
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real';
$format = GETPOST('format', 'aZ09');
$id_bankaccount = GETPOST('id_bankaccount', 'int');
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
@ -67,6 +70,8 @@ if ($type == 'bank-transfer') {
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
}
$error = 0;
/*
* Actions
@ -92,8 +97,10 @@ if (empty($reshook)) {
if ($action == 'create') {
$default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
if ($id_bankaccount != $conf->global->{$default_account}) {
$res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); //Set as default
//var_dump($default_account);var_dump($conf->global->$default_account);var_dump($id_bankaccount);exit;
if ($id_bankaccount != $conf->global->$default_account) {
$res = dolibarr_set_const($db, $default_account, $id_bankaccount, 'chaine', 0, '', $conf->entity); // Set as default
}
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
@ -104,44 +111,39 @@ if (empty($reshook)) {
) {
$errormessage = str_replace('{url}', $bank->getNomUrl(1, '', '', -1, 1), $langs->trans("ErrorICSmissing", '{url}'));
setEventMessages($errormessage, null, 'errors');
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/create.php');
exit;
$action = '';
$error++;
}
$delayindays = 0;
if ($type != 'bank-transfer') {
$delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
} else {
$delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
}
$bprev = new BonPrelevement($db);
$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
if ($result < 0) {
setEventMessages($bprev->error, $bprev->errors, 'errors');
} elseif ($result == 0) {
$mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
setEventMessages($mesg, null, 'errors');
$mesg .= '<br>'."\n";
foreach ($bprev->invoice_in_error as $key => $val) {
$mesg .= '<span class="warning">'.$val."</span><br>\n";
}
} else {
if ($type != 'bank-transfer') {
$texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
$texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
setEventMessages($texttoshow, null);
if (!$error) {
// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
if ($result < 0) {
setEventMessages($bprev->error, $bprev->errors, 'errors');
} elseif ($result == 0) {
$mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
setEventMessages($mesg, null, 'errors');
$mesg .= '<br>'."\n";
foreach ($bprev->invoice_in_error as $key => $val) {
$mesg .= '<span class="warning">'.$val."</span><br>\n";
}
} else {
$texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
$texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
setEventMessages($texttoshow, null);
}
if ($type != 'bank-transfer') {
$texttoshow = $langs->trans("DirectDebitOrderCreated", '{s}');
$texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
setEventMessages($texttoshow, null);
} else {
$texttoshow = $langs->trans("CreditTransferOrderCreated", '{s}');
$texttoshow = str_replace('{s}', $bprev->getNomUrl(1), $texttoshow);
setEventMessages($texttoshow, null);
}
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id);
exit;
header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.urlencode($bprev->id).'&type='.urlencode($type));
exit;
}
}
}
$objectclass = "BonPrelevement";
@ -250,11 +252,25 @@ if ($nb) {
}
print $title;
print img_picto('', 'bank_account');
print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1);
$default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT');
print $form->select_comptes($conf->global->$default_account, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1);
print ' - ';
if (empty($executiondate)) {
$delayindays = 0;
if ($type != 'bank-transfer') {
$delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
} else {
$delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
}
$executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd');
}
print $langs->trans('ExecutionDate').' ';
$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$datere = $executiondate;
print $form->selectDate($datere, 're');
@ -276,7 +292,8 @@ if ($nb) {
if ($type == 'bank-transfer') {
$title = $langs->trans("CreateFileForPaymentByBankTransfer");
}
print '<a type="submit" class="butAction" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
print '<input type="hidden" name="format" value="ALL">'."\n";
print '<input type="submit" class="butAction" value="'.$title.'">'."\n";
}
} else {
if ($mysoc->isInEEC()) {

View File

@ -80,7 +80,7 @@ StatusMotif7=Judicial Decision
StatusMotif8=Other reason
CreateForSepaFRST=Create direct debit file (SEPA FRST)
CreateForSepaRCUR=Create direct debit file (SEPA RCUR)
CreateAll=Create direct debit file (all)
CreateAll=Create direct debit file
CreateFileForPaymentByBankTransfer=Create file for credit transfer
CreateSepaFileForPaymentByBankTransfer=Create credit transfer file (SEPA)
CreateGuichet=Only office