More robust various payment when data are corrupted

This commit is contained in:
Laurent Destailleur 2023-03-13 19:45:42 +01:00
parent 01698aba6b
commit a6dae99f56
2 changed files with 13 additions and 7 deletions

View File

@ -1082,6 +1082,8 @@ class Account extends CommonObject
$this->db->begin();
// @TODO Check there is no child into llx_payment_various, ... to allow deletion ?
// Delete link between tag and bank account
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_account";

View File

@ -638,20 +638,24 @@ if ($id) {
print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $user->rights->banque->modifier), 'string', '', 0);
print '</td></tr>';
$bankaccountnotfound = 0;
if (isModEnabled('banque')) {
print '<tr>';
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
print '<td colspan="3">';
if ($object->fk_account > 0) {
if ($object->fk_bank > 0) {
$bankline = new AccountLine($db);
$bankline->fetch($object->fk_bank);
if ($object->fk_bank > 0) {
$bankline = new AccountLine($db);
$result = $bankline->fetch($object->fk_bank);
print $bankline->getNomUrl(1, 0, 'showall');
if ($result <= 0) {
$bankaccountnotfound = 1;
} else {
print '<span class="opacitymedium">'.$langs->trans("NoRecordfound").'</span>';
print $bankline->getNomUrl(1, 0, 'showall');
}
} else {
$bankaccountnotfound = 1;
print '<span class="opacitymedium">'.$langs->trans("NoRecordfound").'</span>';
}
print '</td>';
@ -685,7 +689,7 @@ if ($id) {
}
// Delete
if (empty($object->rappro)) {
if (empty($object->rappro) || $bankaccountnotfound) {
if (!empty($user->rights->banque->modifier)) {
if ($alreadyaccounted) {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';