Bugzilla – Attachment 119909 Details for
Bug 3492
Move hold fee setting into circulation rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3492: Begginings of moving holds_fee rule to circulation rules
Bug-3492-Begginings-of-moving-holdsfee-rule-to-cir.patch (text/plain), 5.01 KB, created by
Martin Renvoize (ashimema)
on 2021-04-20 13:59:26 UTC
(
hide
)
Description:
Bug 3492: Begginings of moving holds_fee rule to circulation rules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-04-20 13:59:26 UTC
Size:
5.01 KB
patch
obsolete
>From 91c8635f091dbbef6066dc9f2ad4648d49348118 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 20 Apr 2021 14:58:36 +0100 >Subject: [PATCH] Bug 3492: Begginings of moving holds_fee rule to circulation > rules > >--- > C4/Reserves.pm | 32 +++++++++++++++++++++++++------- > Koha/CirculationRules.pm | 3 +++ > admin/smart-rules.pl | 3 +++ > 3 files changed, 31 insertions(+), 7 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index dc99bc1cbb..6239d881e2 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -264,7 +264,7 @@ sub AddReserve { > > # add a reserve fee if needed > if ( C4::Context->preference('HoldFeeMode') ne 'any_time_is_collected' ) { >- my $reserve_fee = GetReserveFee( $borrowernumber, $biblionumber ); >+ my $reserve_fee = GetReserveFee( $hold, $borrowernumber, $biblionumber ); > ChargeReserveFee( $borrowernumber, $reserve_fee, $title ); > } > >@@ -684,10 +684,29 @@ sub ChargeReserveFee { > =cut > > sub GetReserveFee { >- my ( $borrowernumber, $biblionumber ) = @_; >- my $borquery = qq{ >-SELECT reservefee FROM borrowers LEFT JOIN categories ON borrowers.categorycode = categories.categorycode WHERE borrowernumber = ? >- }; >+ my ( $hold, $borrowernumber, $biblionumber ) = @_; >+ >+ my $itemtype = >+ $hold->itemtype ? $hold->itemtype >+ : $hold->item ? $hold->item->effective_itemtype >+ : $hold->biblio->itemtype; >+ >+ # FIXME: item may not have been attached to hold yet.. so we can't know 'homebranch' >+ my $item = $hold->item ? $hold->item->unblessed() : { homebranch => "?" }; >+ >+ my $reserves_control_branch = >+ GetReservesControlBranch( $item, $hold->borrower->unblessed ); >+ >+ my $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ categorycode => $hold->borrower->categorycode, >+ itemtype => $itemtype, >+ branchcode => $reserves_control_branch, >+ rule_name => 'holds_fee' >+ } >+ ); >+ my $fee = defined($rule) ? $rule->rule_value : 0; >+ > my $issue_qry = qq{ > SELECT COUNT(*) FROM items > LEFT JOIN issues USING (itemnumber) >@@ -698,7 +717,6 @@ SELECT COUNT(*) FROM reserves WHERE biblionumber=? AND borrowernumber<>? > }; > > my $dbh = C4::Context->dbh; >- my ( $fee ) = $dbh->selectrow_array( $borquery, undef, ($borrowernumber) ); > my $hold_fee_mode = C4::Context->preference('HoldFeeMode') || 'not_always'; > if( $fee and $fee > 0 and $hold_fee_mode eq 'not_always' ) { > # This is a reconstruction of the old code: >@@ -1109,7 +1127,7 @@ sub ModReserveFill { > $hold->delete(); > > if ( C4::Context->preference('HoldFeeMode') eq 'any_time_is_collected' ) { >- my $reserve_fee = GetReserveFee( $hold->borrowernumber, $hold->biblionumber ); >+ my $reserve_fee = GetReserveFee( $hold, $hold->borrowernumber, $hold->biblionumber ); > ChargeReserveFee( $hold->borrowernumber, $reserve_fee, $hold->biblio->title ); > } > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index df1314613e..1c9c6799e9 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -109,6 +109,9 @@ our $RULE_KINDS = { > holds_per_record => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >+ holds_fee => { >+ scope => [ 'categorycode', 'itemtype' ], >+ }, > issuelength => { > scope => [ 'branchcode', 'categorycode', 'itemtype' ], > }, >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index b1fa57b4da..5a0d947693 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -106,6 +106,7 @@ if ($op eq 'delete') { > reservesallowed => undef, > holds_per_record => undef, > holds_per_day => undef, >+ holds_fee => undef, > onshelfholds => undef, > opacitemholds => undef, > overduefinescap => undef, >@@ -274,6 +275,7 @@ elsif ($op eq 'add') { > my $reservesallowed = strip_non_numeric( scalar $input->param('reservesallowed') ); > my $holds_per_record = strip_non_numeric( scalar $input->param('holds_per_record') ); > my $holds_per_day = strip_non_numeric( scalar $input->param('holds_per_day') ); >+ my $holds_fee = $input->param('holds_fee') || 0; > my $onshelfholds = $input->param('onshelfholds') || 0; > my $issuelength = $input->param('issuelength'); > $issuelength = $issuelength eq q{} ? undef : $issuelength; >@@ -318,6 +320,7 @@ elsif ($op eq 'add') { > reservesallowed => $reservesallowed, > holds_per_record => $holds_per_record, > holds_per_day => $holds_per_day, >+ holds_fee => $holds_fee, > onshelfholds => $onshelfholds, > opacitemholds => $opacitemholds, > overduefinescap => $overduefinescap, >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3492
:
1356
|
1357
| 119909