From e907abd201ac87d6b4e986a63db0ce075d293e55 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Feb 2026 21:27:31 +0100 Subject: [PATCH] NEW Add status canceled on direct debit payment --- htdocs/compta/prelevement/card.php | 31 ++++++++++++++----- .../class/bonprelevement.class.php | 6 ++++ htdocs/core/lib/functions.lib.php | 2 ++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index b4a277d74fd..987202c5646 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -183,6 +183,14 @@ if (empty($reshook)) { } } + if ($action == 'setcancel' && $permissiontocreditdebit) { + $savtype = $object->type; + $res = $object->setStatut(BonPrelevement::STATUS_CANCELED); + if ($res <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + if ($action == 'confirm_delete' && $permissiontodelete) { $savtype = $object->type; $res = $object->delete($user); @@ -436,6 +444,16 @@ if ($id > 0 || $ref) { } } + if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) { + if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) { + if ($object->type == 'bank-transfer') { + print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); + } else { + print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit')); + } + } + } + if ($object->status == BonPrelevement::STATUS_TRANSFERED) { if ($object->type == 'bank-transfer') { print dolGetButtonAction($langs->trans("ClassDebited"), '', 'default', 'card.php?action=setcredited&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); @@ -444,13 +462,12 @@ if ($id > 0 || $ref) { } } - if (getDolGlobalString('BANK_CAN_REOPEN_DIRECT_DEBIT_OR_CREDIT_TRANSFER')) { - if ($object->status == BonPrelevement::STATUS_DEBITED || $object->status == BonPrelevement::STATUS_CREDITED) { - if ($object->type == 'bank-transfer') { - print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); - } else { - print dolGetButtonAction($langs->trans("ReOpen"), '', 'default', 'card.php?action=reopen&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit')); - } + // Cancel + if ($object->status == BonPrelevement::STATUS_TRANSFERED) { + if ($object->type == 'bank-transfer') { + print dolGetButtonAction($langs->trans("Cancel"), '', 'cancel', 'card.php?action=setcancel&token='.newToken().'&id='.$object->id, '', $user->hasRight('paymentbybanktransfer', 'debit')); + } else { + print dolGetButtonAction($langs->trans("Cancel"), '', 'cancel', 'card.php?action=setcancel&token='.newToken().'&id='.$object->id, '', $user->hasRight('prelevement', 'bons', 'credit')); } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index fcfcc94a971..6b14ea8cf85 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -163,6 +163,7 @@ class BonPrelevement extends CommonObject const STATUS_TRANSFERED = 1; const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type + const STATUS_CANCELED = -1; /** @@ -2909,6 +2910,8 @@ class BonPrelevement extends CommonObject $this->labelStatus[self::STATUS_CREDITED] = $langs->transnoentitiesnoconv('StatusCredited'); $this->labelStatusShort[self::STATUS_CREDITED] = $langs->transnoentitiesnoconv('StatusCredited'); } + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); } $statusType = 'status1'; @@ -2918,6 +2921,9 @@ class BonPrelevement extends CommonObject if ($status == self::STATUS_CREDITED || $status == self::STATUS_DEBITED) { $statusType = 'status6'; } + if ($status == self::STATUS_CANCELED) { + $statusType = 'status9'; + } return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3e943935acd..6787fd8cc41 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -14374,6 +14374,8 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = $class = 'butAction butActionEmail'; } elseif ($actionType == 'clone') { $class = 'butAction butActionClone'; + } elseif ($actionType == 'cancel') { + $class = 'butAction butActionDelete'; } elseif ($actionType == 'danger' || $actionType == 'delete') { $class = 'butAction butActionDelete'; if (!empty($url) && strpos($url, 'token=') === false) {