From 98324dab2644c80d2a4bca1f4f49c4f825ce4700 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 27 Jun 2016 16:12:29 +0000 Subject: [PATCH] Bug 15561 - Add ability to charge cancelation fee from "Holds over" tab The fee set in ExpireReservesMaxPickUpDelayCharge can only be charged by the automatic expiration cron script. Some libraries would prefer to manually cancel holds via the "Holds over" tab of the "Holds awaiting pickup" page but still be able to charge the cancellation fee. Test Plan: 1) Apply this patch 2) Set ExpireReservesMaxPickUpDelayCharge to some number 3) Go to the Holds awaiting pickup page 4) Go to the Holds over tab 5) Note the new checkbox for charging the fee 6) Test canceling a single hold with the checkbox checked 7) Note a fee is charged 8) Test canceling a single hold with the checkbox unchecked 9) Note a fee is not charged 10) Test canceling all holds with the checkbox checked 11) Note the patrons are charged fees 12) Test canceling all holds without the checkbox checked 13) Note the patrons are not charged fees Signed-off-by: Jason Burds --- C4/Reserves.pm | 4 ++-- circ/waitingreserves.pl | 23 +++++++++++----------- .../prog/en/modules/circ/waitingreserves.tt | 11 ++++++++++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index b83f8e1..87e3f1c 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -1368,10 +1368,10 @@ function to cancel reserv,check other reserves, and transfer document if it's ne sub ModReserveCancelAll { my $messages; my $nextreservinfo; - my ( $itemnumber, $borrowernumber ) = @_; + my ( $itemnumber, $borrowernumber, $charge_cancel_fee ) = @_; #step 1 : cancel the reservation - my $CancelReserve = CancelReserve({ itemnumber => $itemnumber, borrowernumber => $borrowernumber }); + my $CancelReserve = CancelReserve({ itemnumber => $itemnumber, borrowernumber => $borrowernumber, charge_cancel_fee => $charge_cancel_fee }); #step 2 launch the subroutine of the others reserves ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber); diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index 0050ce3..306f6b1 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -40,13 +40,14 @@ use C4::Koha; my $input = new CGI; -my $item = $input->param('itemnumber'); -my $borrowernumber = $input->param('borrowernumber'); -my $fbr = $input->param('fbr') || ''; -my $tbr = $input->param('tbr') || ''; -my $all_branches = $input->param('allbranches') || ''; -my $cancelall = $input->param('cancelall'); -my $tab = $input->param('tab'); +my $item = $input->param('itemnumber'); +my $borrowernumber = $input->param('borrowernumber'); +my $fbr = $input->param('fbr') || ''; +my $tbr = $input->param('tbr') || ''; +my $all_branches = $input->param('allbranches') || ''; +my $cancelall = $input->param('cancelall'); +my $tab = $input->param('tab'); +my $charge_cancel_fee = $input->param('charge_cancel_fee'); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -67,7 +68,7 @@ $template->param( TransferWhenCancelAllWaitingHolds => 1 ) if $transfer_when_can my @cancel_result; # if we have a return from the form we launch the subroutine CancelReserve if ($item) { - my $res = cancel( $item, $borrowernumber, $fbr, $tbr ); + my $res = cancel( $item, $borrowernumber, $fbr, $tbr, undef, $charge_cancel_fee ); push @cancel_result, $res if $res; } @@ -140,7 +141,7 @@ foreach my $num (@getreserves) { if ($today > $calcDate) { if ($cancelall) { - my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all ); + my $res = cancel( $itemnumber, $borrowernum, $holdingbranch, $homebranch, !$transfer_when_cancel_all, $charge_cancel_fee ); push @cancel_result, $res if $res; next; } else { @@ -175,13 +176,13 @@ if ($item && $tab eq 'holdsover') { exit; sub cancel { - my ($item, $borrowernumber, $fbr, $tbr, $skip_transfers ) = @_; + my ($item, $borrowernumber, $fbr, $tbr, $skip_transfers, $charge_cancel_fee ) = @_; my $transfer = $fbr ne $tbr; # XXX && !$nextreservinfo; return if $transfer && $skip_transfers; - my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber ); + my ( $messages, $nextreservinfo ) = ModReserveCancelAll( $item, $borrowernumber, $charge_cancel_fee ); # if the document is not in his homebranch location and there is not reservation after, we transfer it if ($transfer && !$nextreservinfo) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt index 3183442..ed6a583 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% USE KohaDates %] [% USE Branches %] [% INCLUDE 'doc-head-open.inc' %] @@ -113,7 +114,7 @@ - + [% IF ( reserveloo.dotransfer ) %] [% ELSE %] @@ -137,6 +138,9 @@ + [% IF Koha.Preference('ExpireReservesMaxPickUpDelayCharge') %] +

Charge cancelation fee

+ [% END %] [% UNLESS TransferWhenCancelAllWaitingHolds %] Only items that need not be transferred will be cancelled (TransferWhenCancelAllWaitingHolds sypref) @@ -174,6 +178,11 @@ + + [% IF Koha.Preference('ExpireReservesMaxPickUpDelayCharge') %] +

Charge cancelation fee

+ [% END %] + [% IF ( overloo.dotransfer ) %] [% ELSE %] -- 2.1.4