Bugzilla – Attachment 96217 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: Work In Progress
Bug-23091-Work-In-Progress.patch (text/plain), 5.61 KB, created by
Martin Renvoize (ashimema)
on 2019-12-12 12:56:08 UTC
(
hide
)
Description:
Bug 23091: Work In Progress
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-12-12 12:56:08 UTC
Size:
5.61 KB
patch
obsolete
>From f2cd6ffc434506a3a76fb0334e9b58bf008e33fb 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: Work In Progress > >--- > C4/Circulation.pm | 40 ++++++++++++++++++++++++- > Koha/RefundLostItemFeeRules.pm | 54 ++++++++++++++++++++++++++++++---- > 2 files changed, 87 insertions(+), 7 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 3568a32639..acbaa33e80 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1441,7 +1441,7 @@ 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::RefundLostItemFeeRules->should_refund( >@@ -1456,6 +1456,25 @@ sub AddIssue { > _FixAccountForLostAndReturned( $item_object->itemnumber, undef, > $item_object->barcode ); > } >+ if ( >+ Koha::RefundLostItemFeeRules->should_charge_fine( >+ { >+ current_branch => C4::Context->userenv->{branch}, >+ item_home_branch => $item_object->homebranch, >+ item_holding_branch => $item_object->holdingbranch >+ } >+ ) >+ ) >+ { >+ _CalculateAndUpdateFine( >+ { >+ issue => $issue, >+ item => $item_unblessed, >+ borrower => $borrower >+ } >+ ); >+ _FixOverduesOnReturn( $borrower->{borrowernumber}, $item_object->itemnumber, undef, 'RENEWED' ); >+ } > } > > ModItem( >@@ -2027,6 +2046,25 @@ sub AddReturn { > $borrowernumber, $barcode ); > $messages->{'LostItemFeeRefunded'} = 1; > } >+ if ( >+ Koha::RefundLostItemFeeRules->should_charge_fine( >+ { >+ current_branch => C4::Context->userenv->{branch}, >+ item_home_branch => $item->homebranch, >+ item_holding_branch => $item_holding_branch >+ } >+ ) >+ ) >+ { >+ _CalculateAndUpdateFine( >+ { >+ issue => $issue, >+ item => $item_unblessed, >+ borrower => $patron_unblessed, >+ return_date => $return_date >+ } >+ ); >+ } > } > } > >diff --git a/Koha/RefundLostItemFeeRules.pm b/Koha/RefundLostItemFeeRules.pm >index 86b01f0afd..d8e9d49ad7 100644 >--- a/Koha/RefundLostItemFeeRules.pm >+++ b/Koha/RefundLostItemFeeRules.pm >@@ -66,7 +66,49 @@ sub should_refund { > my $self = shift; > my $params = shift; > >- return $self->_effective_branch_rule( $self->_choose_branch( $params ) ); >+ # Options are: >+ # 'none' - Do not refund >+ # 'refund' - Refund only >+ # 'restore' - Refund and Restore original fine value >+ # 'charge' - Refund and Charge new fine value >+ my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); >+ return $rule eq 'none' ? 0 : 1; >+} >+ >+=head3 should_restore_fine >+ >+Koha::RefundLostItemFeeRules->should_restore() >+ >+Returns a boolean telling if the original overdue fee needs to be restored >+given the passed params, and the current rules/sysprefs configuration. >+ >+=cut >+ >+sub should_restore_fine { >+ >+ my $self = shift; >+ my $params = shift; >+ >+ my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); >+ return $rule eq 'restore' ? 1 : 0; >+} >+ >+=head3 should_charge_fine >+ >+Koha::RefundLostItemFeeRules->should_charge_fine() >+ >+Returns a boolean telling if a new overdue fee should be chargeed given the >+passed params, and the current rules/sysprefs configuration. >+ >+=cut >+ >+sub should_charge_fine { >+ >+ my $self = shift; >+ my $params = shift; >+ >+ my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); >+ return $rule eq 'charge' ? 1 : 0; > } > > >@@ -89,7 +131,7 @@ sub _effective_branch_rule { > branchcode => $branch, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >+ rule_name => 'lost_return', > } > )->next(); > >@@ -138,7 +180,7 @@ sub _choose_branch { > > =head3 Koha::RefundLostItemFeeRules->find(); > >-Inherit from Koha::Objects->find(), but forces rule_name => 'refund' >+Inherit from Koha::Objects->find(), but forces rule_name => 'lost_return' > > =cut > >@@ -146,7 +188,7 @@ sub find { > my ( $self, @pars ) = @_; > > if ( ref($pars[0]) eq 'HASH' ) { >- $pars[0]->{rule_name} = 'refund'; >+ $pars[0]->{rule_name} = 'lost_return'; > } > > return $self->SUPER::find(@pars); >@@ -167,13 +209,13 @@ sub _default_rule { > branchcode => undef, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >+ rule_name => 'lost_return', > } > )->next(); > > return (defined $default_rule) > ? $default_rule->rule_value >- : 1; >+ : 'refund'; > } > > 1; >-- >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