Bugzilla – Attachment 105546 Details for
Bug 23091
Add options to charge new or restore forgiven overdues when a lost item is returned
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23091: Add handling for new lostreturn rules
Bug-23091-Add-handling-for-new-lostreturn-rules.patch (text/plain), 15.84 KB, created by
Martin Renvoize (ashimema)
on 2020-06-04 09:54:46 UTC
(
hide
)
Description:
Bug 23091: Add handling for new lostreturn rules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-06-04 09:54:46 UTC
Size:
15.84 KB
patch
obsolete
>From adf06464f85729e45a6730d9fd037b2def600d25 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 23 Oct 2019 11:32:28 +0100 >Subject: [PATCH] Bug 23091: Add handling for new lostreturn rules > >This patch adds circulation handling for two new lost item return rules. >These new rules allow for the new options of refund lost item charge >plus charge a freshly calculated overdue fine and refind of lost item >charge plus charge a new fine matching the amount from the original >overdue fine. >--- > C4/Circulation.pm | 68 +++++++++++---- > Koha/CirculationRules.pm | 19 +++- > admin/smart-rules.pl | 16 ++-- > .../prog/en/modules/admin/smart-rules.tt | 87 ++++++++++++------- > 4 files changed, 128 insertions(+), 62 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index a0fde11397..aadebf9adf 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1446,19 +1446,34 @@ sub AddIssue { > UpdateTotalIssues( $item_object->biblionumber, 1 ); > } > >- ## If item was lost, it has now been found, reverse any list item charges if necessary. >+ ## If item was lost, it has now been found, reverse any lost item charges if necessary. > if ( $item_object->itemlost ) { >- if ( >- Koha::CirculationRules->get_lostreturn_policy( >- { >- return_branch => C4::Context->userenv->{branch}, >- item => $item_object >- } >- ) >- ) >- { >+ my $lostreturn_policy = >+ Koha::CirculationRules->get_lostreturn_policy( >+ { >+ return_branch => C4::Context->userenv->{branch}, >+ item => $item_object >+ } >+ ); >+ >+ if ($lostreturn_policy) { > _FixAccountForLostAndFound( $item_object->itemnumber, undef, > $item_object->barcode ); >+ >+ if ( $lostreturn_policy eq 'charge' ) { >+ _CalculateAndUpdateFine( >+ { >+ issue => $issue, >+ item => $item_unblessed, >+ borrower => $borrower >+ } >+ ); >+ _FixOverduesOnReturn( $borrower->{borrowernumber}, >+ $item_object->itemnumber, undef, 'RENEWED' ); >+ } >+ elsif ( $lostreturn_policy eq 'restore' ) { >+ >+ } > } > } > >@@ -2031,18 +2046,33 @@ sub AddReturn { > if ( $item->itemlost ) { > $messages->{'WasLost'} = 1; > unless ( C4::Context->preference("BlockReturnOfLostItems") ) { >- if ( >- Koha::CirculationRules->get_lostreturn_policy( >- { >- return_branch => C4::Context->userenv->{branch}, >- item => $item, >- } >- ) >- ) >- { >+ my $lostreturn_policy = >+ Koha::CirculationRules->get_lostreturn_policy( >+ { >+ return_branch => C4::Context->userenv->{branch}, >+ item => $item >+ } >+ ); >+ >+ if ($lostreturn_policy) { > _FixAccountForLostAndFound( $item->itemnumber, > $borrowernumber, $barcode ); > $messages->{'LostItemFeeRefunded'} = 1; >+ >+ if ( $lostreturn_policy eq 'charge' ) { >+ _CalculateAndUpdateFine( >+ { >+ issue => $issue, >+ item => $item, >+ borrower => $patron_unblessed, >+ return_date => $return_date >+ } >+ ); >+ $messages->{'LostItemFeeCharged'} = 1; >+ } >+ elsif ( $lostreturn_policy eq 'restore' ) { >+ $messages->{'LostItemFeeRestored'} = 1; >+ } > } > } > } >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 0b989daffa..38aee10ccc 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -46,7 +46,7 @@ Any attempt to set a rule with a nonsensical scope (for instance, setting the C< > =cut > > our $RULE_KINDS = { >- refund => { >+ lostreturn => { > scope => [ 'branchcode' ], > }, > >@@ -425,7 +425,18 @@ sub get_onshelfholds_policy { > > =head3 get_lostreturn_policy > >- my $refund = Koha::CirculationRules->get_lostreturn_policy( { return_branch => $return_branch, item => $item } ); >+ my $lostrefund_policy = Koha::CirculationRules->get_lostreturn_policy( { return_branch => $return_branch, item => $item } ); >+ >+Return values are: >+ >+=over 2 >+ >+=item 0 - Do not refund >+=item refund - Refund the lost item charge >+=item restore - Refund the lost item charge and restore the original overdue fine >+=item charge - Refund the lost item charge and charge a new overdue fine >+ >+=back > > =cut > >@@ -446,11 +457,11 @@ sub get_lostreturn_policy { > my $rule = Koha::CirculationRules->get_effective_rule( > { > branchcode => $branch, >- rule_name => 'refund', >+ rule_name => 'lostreturn', > } > ); > >- return $rule ? $rule->rule_value : 1; >+ return $rule ? $rule->rule_value : 'refund'; > } > > =head3 article_requestable_rules >diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl >index d72599faae..22add21fec 100755 >--- a/admin/smart-rules.pl >+++ b/admin/smart-rules.pl >@@ -522,16 +522,16 @@ elsif ($op eq "add-branch-item") { > } > elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { > >- my $refund = $input->param('refund'); >+ my $lostreturn = $input->param('lostreturn'); > >- if ( $refund eq '*' ) { >+ if ( $lostreturn eq '*' ) { > if ( $branch ne '*' ) { >- # only do something for $refund eq '*' if branch-specific >+ # only do something for $lostreturn eq '*' if branch-specific > Koha::CirculationRules->set_rules( > { > branchcode => $branch, > rules => { >- refund => undef >+ lostreturn => undef > } > } > ); >@@ -541,18 +541,18 @@ elsif ( $op eq 'mod-refund-lost-item-fee-rule' ) { > { > branchcode => $branch, > rules => { >- refund => $refund >+ lostreturn => $lostreturn > } > } > ); > } > } > >-my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'refund' }); >-my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'refund' }); >+my $refundLostItemFeeRule = Koha::CirculationRules->find({ branchcode => ($branch eq '*') ? undef : $branch, rule_name => 'lostreturn' }); >+my $defaultLostItemFeeRule = Koha::CirculationRules->find({ branchcode => undef, rule_name => 'lostreturn' }); > $template->param( > refundLostItemFeeRule => $refundLostItemFeeRule, >- defaultRefundRule => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 1 >+ defaultRefundRule => $defaultLostItemFeeRule ? $defaultLostItemFeeRule->rule_value : 'refund' > ); > > my $patron_categories = Koha::Patron::Categories->search({}, { order_by => ['description'] }); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index 5ae3bb94e1..0a2d7f74b0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -718,23 +718,35 @@ > </tr> > <tr> > <td> >- <select name="refund"> >+ <select name="lostreturn"> > [%# Default branch %] > [% IF ( current_branch == '*' ) %] >- [% IF ( defaultRefundRule ) %] >- <option value="1" selected="selected"> >+ [% IF ( defaultRefundRule == 'refund' ) %] >+ <option value="refund" selected="selected">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( defaultRefundRule == 'charge' ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( defaultRefundRule == 'restore' ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( defaultRefundRule == 0 ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0" selected="selected">Leave lost item charge</option> > [% ELSE %] >- <option value="1"> >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> > [% END %] >- Yes >- </option> >- [% IF ( not defaultRefundRule ) %] >- <option value="0" selected="selected"> >- [% ELSE %] >- <option value="0"> >- [% END %] >- No >- </option> > [% ELSE %] > [%# Branch-specific %] > [% IF ( not refundLostItemFeeRule ) %] >@@ -742,30 +754,43 @@ > [% ELSE %] > <option value="*"> > [% END %] >- [% IF defaultRefundRule %] >- Use default (Yes) >+ [% IF defaultRefundRule == 'refund' %] >+ Use default (Refund lost item charge) >+ [% ELSIF defaultRefundRule == 'charge' %] >+ Use default (Refund lost item charge and restore overdue fine) >+ [% ELSIF defaultRefundRule == 'restore' %] >+ Use default (Refund lost item charge and charge new overdue fine) > [% ELSE %] >- Use default (No) >+ Use default (Leave lost item charge) > [% END %] > </option> > [% IF ( not refundLostItemFeeRule ) %] >- <option value="1">Yes</option> >- <option value="0">No</option> >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> > [% ELSE %] >- [% IF ( refundLostItemFeeRule.rule_value ) %] >- <option value="1" selected="selected"> >- [% ELSE %] >- <option value="1"> >+ [% IF ( refundLostItemFeeRule.rule_value == 'refund' ) %] >+ <option value="refund" selected="selected">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( refundLostItemFeeRule.rule_value == 'charge' ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge" selected="selected">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( refundLostItemFeeRule.rule_value == 'restore' ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore" selected="selected">Refund lost item charge and restore overdue fine</option> >+ <option value="0">Leave lost item charge</option> >+ [% ELSIF ( refundLostItemFeeRule.rule_value == 0 ) %] >+ <option value="refund">Refund lost item charge</option> >+ <option value="charge">Refund lost item charge and charge new overdue fine</option> >+ <option value="restore">Refund lost item charge and restore overdue fine</option> >+ <option value="0" selected="selected">Leave lost item charge</option> > [% END %] >- Yes >- </option> >- [% IF ( not refundLostItemFeeRule.rule_value ) %] >- <option value="0" selected="selected"> >- [% ELSE %] >- <option value="0"> >- [% END %] >- No >- </option> > [% END %] > [% END %] > </select> >-- >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 23091
:
96217
|
105529
|
105530
|
105531
|
105544
|
105545
|
105546
|
105547
|
105567
|
105649
|
106871
|
106872
|
106873
|
106874
|
106875
|
106876
|
106906
|
106907
|
106908
|
106909
|
106910
|
106911
|
106912
|
106961
|
107026
|
107027
|
107028
|
107029
|
107030
|
107031
|
107032
|
107033
|
107034
|
107100
|
107101
|
107102
|
107103
|
107104
|
107105
|
107106
|
107107
|
107108
|
107335
|
107336
|
107337
|
107338
|
107339
|
107340
|
107341
|
107342
|
107343
|
108718
|
108719
|
108720
|
108721
|
108722
|
108723
|
108724
|
109571
|
109572
|
109573
|
109574
|
109575
|
109576
|
109577
|
110660
|
110661
|
110662
|
110663
|
110664
|
110665
|
110666
|
110667
|
110720
|
110721
|
110722
|
110723
|
110724
|
110725
|
110726
|
110727
|
111501
|
111502
|
111503
|
111504
|
111505
|
111506
|
111507
|
111508
|
111935
|
111936
|
111965
|
111979
|
111980
|
111981
|
111982
|
111983
|
111984
|
111985
|
111986
|
111987
|
111988
|
111989
|
113081
|
113082
|
113083
|
113084
|
113085
|
113086
|
113087
|
113088
|
113089
|
113090
|
113091