Bugzilla – Attachment 107343 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: (follow-up) Remove borrower requirement for restore
Bug-23091-follow-up-Remove-borrower-requirement-fo.patch (text/plain), 7.11 KB, created by
Martin Renvoize (ashimema)
on 2020-07-24 12:28:15 UTC
(
hide
)
Description:
Bug 23091: (follow-up) Remove borrower requirement for restore
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-07-24 12:28:15 UTC
Size:
7.11 KB
patch
obsolete
>From b6cc4ab2a58aac9d0c962f6213e8517ad63588c2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 17 Jul 2020 16:16:15 +0100 >Subject: [PATCH] Bug 23091: (follow-up) Remove borrower requirement for > restore > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > C4/Circulation.pm | 33 ++++++++++++++------------------- > t/db_dependent/Circulation.t | 19 +++++-------------- > 2 files changed, 19 insertions(+), 33 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 0ec0707175..32a50ad9a3 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1476,8 +1476,7 @@ sub AddIssue { > ); > > if ($refund && $lostreturn_policy) { >- _FixAccountForLostAndFound( $item_object->itemnumber, undef, >- $item_object->barcode ); >+ _FixAccountForLostAndFound( $item_object->itemnumber ); > > if ( $lostreturn_policy eq 'charge' ) { > $actualissue //= Koha::Old::Checkouts->search( >@@ -1487,6 +1486,10 @@ sub AddIssue { > rows => 1 > } > )->single; >+ unless (exists($borrower->{branchcode})) { >+ my $patron = $issue->patron; >+ $borrower = $patron->unblessed; >+ } > _CalculateAndUpdateFine( > { > issue => $actualissue, >@@ -1498,10 +1501,7 @@ sub AddIssue { > $item_object->itemnumber, undef, 'RENEWED' ); > } > elsif ( $lostreturn_policy eq 'restore' ) { >- _RestoreOverdueForLostAndFound( >- $borrower->{'borrowernumber'}, >- $item_object->itemnumber >- ); >+ _RestoreOverdueForLostAndFound( $item_object->itemnumber ); > } > } > } >@@ -2096,8 +2096,7 @@ sub AddReturn { > ); > > if ($refund && $lostreturn_policy) { >- _FixAccountForLostAndFound( $item->itemnumber, >- $borrowernumber, $barcode ); >+ _FixAccountForLostAndFound( $item->itemnumber ); > $messages->{'LostItemFeeRefunded'} = 1; > > if ( $lostreturn_policy eq 'charge' ) { >@@ -2105,6 +2104,10 @@ sub AddReturn { > { itemnumber => $item->itemnumber }, > { order_by => { '-desc' => 'returndate' }, rows => 1 } > )->single; >+ unless (exists($patron_unblessed->{branchcode})) { >+ my $patron = $issue->patron; >+ $patron_unblessed = $patron->unblessed; >+ } > _CalculateAndUpdateFine( > { > issue => $issue, >@@ -2118,8 +2121,7 @@ sub AddReturn { > $messages->{'LostItemFeeCharged'} = 1; > } > elsif ( $lostreturn_policy eq 'restore' ) { >- _RestoreOverdueForLostAndFound( $borrowernumber, >- $item->itemnumber ); >+ _RestoreOverdueForLostAndFound( $item->itemnumber ); > $messages->{'LostItemFeeRestored'} = 1; > } > } >@@ -2634,9 +2636,7 @@ sub _FixAccountForLostAndFound { > > =head2 _RestoreOverdueForLostAndFound > >- &_RestoreOverdueForLostAndFound($borrowernumber, $itemnumber ); >- >-C<$borrowernumber> borrowernumber >+ &_RestoreOverdueForLostAndFound( $itemnumber ); > > C<$itemnumber> itemnumber > >@@ -2645,12 +2645,8 @@ Internal function > =cut > > sub _RestoreOverdueForLostAndFound { >- my ( $borrowernumber, $item ) = @_; >+ my ( $item ) = @_; > >- unless( $borrowernumber ) { >- warn "_RestoreOverdueForLostAndFound() not supplied valid borrowernumber"; >- return; >- } > unless( $item ) { > warn "_RestoreOverdueForLostAndFound() not supplied valid itemnumber"; > return; >@@ -2663,7 +2659,6 @@ sub _RestoreOverdueForLostAndFound { > # check for lost overdue fine > my $accountlines = Koha::Account::Lines->search( > { >- borrowernumber => $borrowernumber, > itemnumber => $item, > debit_type_code => 'OVERDUE', > status => 'LOST' >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index be4a237b9a..e3a4bb339f 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -3093,7 +3093,7 @@ subtest '_FixAccountForLostAndFound' => sub { > > subtest '_RestoreOverdueForLostAndFound' => sub { > >- plan tests => 8; >+ plan tests => 7; > > my $manager = $builder->build_object( { class => "Koha::Patrons" } ); > t::lib::Mocks::mock_userenv( >@@ -3103,7 +3103,7 @@ subtest '_RestoreOverdueForLostAndFound' => sub { > my $item = $builder->build_sample_item(); > > # No fine found >- my $result = C4::Circulation::_RestoreOverdueForLostAndFound($patron->borrowernumber, $item->itemnumber); >+ my $result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); > is($result, 0, "0 returned when no overdue found"); > > # Fine not forgiven >@@ -3120,7 +3120,7 @@ subtest '_RestoreOverdueForLostAndFound' => sub { > )->store(); > $overdue->status('LOST')->store(); > >- $result = C4::Circulation::_RestoreOverdueForLostAndFound($patron->borrowernumber, $item->itemnumber); >+ $result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); > is($result, 0, "0 returned when overdue found without forgival"); > $overdue->discard_changes; > is($overdue->status, 'RETURNED', 'Overdue status updated to RETURNED'); >@@ -3141,7 +3141,7 @@ subtest '_RestoreOverdueForLostAndFound' => sub { > ); > $credit->apply( { debits => [$overdue], offset_type => 'Forgiven' } ); > >- $result = C4::Circulation::_RestoreOverdueForLostAndFound($patron->borrowernumber, $item->itemnumber); >+ $result = C4::Circulation::_RestoreOverdueForLostAndFound( $item->itemnumber); > > is( ref($result), 'Koha::Account::Line', 'Return a Koha::Account::Line object on sucess'); > $overdue->discard_changes; >@@ -3150,19 +3150,10 @@ subtest '_RestoreOverdueForLostAndFound' => sub { > > # Missing parameters > warning_like { >- C4::Circulation::_RestoreOverdueForLostAndFound( undef, >- $item->itemnumber ) >- } >- qr/_RestoreOverdueForLostAndFound\(\) not supplied valid borrowernumber/, >- "parameter warning received for missing borrowernumber"; >- >- warning_like { >- C4::Circulation::_RestoreOverdueForLostAndFound( >- $patron->borrowernumber, undef ) >+ C4::Circulation::_RestoreOverdueForLostAndFound( undef ) > } > qr/_RestoreOverdueForLostAndFound\(\) not supplied valid itemnumber/, > "parameter warning received for missing itemnumbernumber"; >- > }; > > subtest '_FixOverduesOnReturn' => sub { >-- >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