From 2e0e9e45f776724da05faf3928ab5d4c11e8dd38 Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 8 Apr 2016 13:26:26 +0000 Subject: [PATCH] Bug 16223: Enable regex match for rules of debarment removals --- Koha/Patron/Debarments.pm | 36 +++++++++++++--------- .../prog/en/modules/admin/preferences/patrons.pref | 9 +++--- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm index 3394bcd..7413df5 100644 --- a/Koha/Patron/Debarments.pm +++ b/Koha/Patron/Debarments.pm @@ -311,22 +311,28 @@ sub DelDebarmentsAfterPayment { my ( $total_due, $accts, $numaccts ) = C4::Members::GetMemberAccountRecords($borrowernumber); foreach my $debarment (@{ $debarments }){ - if (exists $liftDebarmentRules->{$debarment->{'comment'}}) { - # Delete debarment IF: - # 1. there is no maximum outstanding fines defined for the liftDebarmentRule - # and there is no outstanding fines. - # 2. there is a maximum outstanding fines amount defined - # and total_due is smaller or equal than the defined maximum outstanding amount - # Otherwise, do not lift the debarment. - if (not defined $liftDebarmentRules->{$debarment->{'comment'}}->{'outstanding'}){ - if ($total_due <= 0) { - DelDebarment($debarment->{'borrower_debarment_id'}); - } + my $rule; + + foreach my $liftRule (keys $liftDebarmentRules){ + my $comment = $debarment->{'comment'}; + $rule = $liftRule if $comment =~ $liftRule; + } + next unless $rule; + + # Delete debarment IF: + # 1. there is no maximum outstanding fines defined for the liftDebarmentRule + # and there is no outstanding fines. + # 2. there is a maximum outstanding fines amount defined + # and total_due is smaller or equal than the defined maximum outstanding amount + # Otherwise, do not lift the debarment. + if (not defined $liftDebarmentRules->{$rule}->{'outstanding'}){ + if ($total_due <= 0) { + DelDebarment($debarment->{'borrower_debarment_id'}); } - else { - if ($total_due <= $liftDebarmentRules->{$debarment->{'comment'}}->{'outstanding'}) { - DelDebarment($debarment->{'borrower_debarment_id'}); - } + } + else { + if ($total_due <= $liftDebarmentRules->{$rule}->{'outstanding'}) { + DelDebarment($debarment->{'borrower_debarment_id'}); } } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index b1aac70..9c1937b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -53,13 +53,14 @@ Patrons: - pref: DebarmentsToLiftAfterPayment type: textarea class: code - - Lift these debarments after Borrower has paid his/her fees - - "

Example, debarment is lifted after all fees are paid:

" + - Lift these debarments after Borrower has paid his/her fees. Matches dynamic content in debarment comment. + - "

Example, debarments with comment (either exact match or dynamic content, e.g. 'Debarment message for Patron 123') that match 'Debarment message' are lifted after all fees are paid:

" - "
Debarment message:
  outstanding: 0
" - - "

Example, debarment is lifted after payment with outstanding fees less or equal than 5:

" - - "
Another debarment:
+ - "

Example, debarment with message of exactly 'Debarment message' is lifted after payment with outstanding fees less or equal than 5:

" + - "
^Debarment message$:
  outstanding: 5.00
" + - You can use regex in the definitions to match your needs. - - pref: EnhancedMessagingPreferences choices: -- 1.9.1