Bugzilla – Attachment 90878 Details for
Bug 23103
Cannot checkin items lost by deleted patrons with fines attached
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23103: Cannot checkin items lost by deleted patrons with fines attached
Bug-23103-Cannot-checkin-items-lost-by-deleted-pat.patch (text/plain), 3.56 KB, created by
Martin Renvoize (ashimema)
on 2019-06-21 08:36:45 UTC
(
hide
)
Description:
Bug 23103: Cannot checkin items lost by deleted patrons with fines attached
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-06-21 08:36:45 UTC
Size:
3.56 KB
patch
obsolete
>From 36298462aaaf9065f96726ac7d792dac6636ca1f Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 12 Jun 2019 15:08:08 -0400 >Subject: [PATCH] Bug 23103: Cannot checkin items lost by deleted patrons with > fines attached > >Test Plan: >1) Checkout an item to a patron >2) Ensure the item has a replacement cost (or itemtype has default) >3) Ensure patrons are charged when items lost >4) Mark the item lost >5) Confirm patron has a fine >6) Write off the fine >7) Delete the patron >8) Check in the item >9) Note the internal server error >10) Apply this patch >11) Repeat steps 1-8 >12) Note there is no internal server error! >13) prove t/db_dependent/Circulation.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Circulation.pm | 7 +++++- > t/db_dependent/Circulation.t | 44 +++++++++++++++++++++++++++++++++++- > 2 files changed, 49 insertions(+), 2 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 3061a8e61a..773f5701da 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2418,7 +2418,12 @@ sub _FixAccountForLostAndReturned { > return unless $accountlines->count > 0; > my $accountline = $accountlines->next; > my $total_to_refund = 0; >- my $account = Koha::Patrons->find( $accountline->borrowernumber )->account; >+ >+ return unless $accountline->borrowernumber; >+ my $patron = Koha::Patrons->find( $accountline->borrowernumber ); >+ return undef unless $patron; # Patron has been deleted, nobody to credit the return to >+ >+ my $account = $patron->account; > > # Use cases > if ( $accountline->amount > $accountline->amountoutstanding ) { >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index eb8be21a9a..52c240d6a8 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > use utf8; > >-use Test::More tests => 130; >+use Test::More tests => 131; > use Test::MockModule; > > use Data::Dumper; >@@ -2550,6 +2550,48 @@ subtest '_FixOverduesOnReturn' => sub { > is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); > }; > >+subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => sub { >+ plan tests => 1; >+ >+ my $manager = $builder->build_object({ class => "Koha::Patrons" }); >+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); >+ >+ my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' }); >+ >+ my $branchcode = $library2->{branchcode}; >+ >+ my $item = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branchcode, >+ replacementprice => 99.00, >+ itype => $itemtype, >+ } >+ ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ ## Start with basic call, should just close out the open fine >+ my $accountline = Koha::Account::Line->new( >+ { >+ borrowernumber => $patron->id, >+ accounttype => 'L', >+ status => undef, >+ itemnumber => $item->itemnumber, >+ amount => 99.00, >+ amountoutstanding => 99.00, >+ interface => 'test', >+ } >+ )->store(); >+ >+ $patron->delete(); >+ >+ my $return_value = C4::Circulation::_FixAccountForLostAndReturned( $patron->id, $item->itemnumber ); >+ >+ is( $return_value, undef, "_FixAccountForLostAndReturned returns undef if patron is deleted" ); >+ >+}; >+ > subtest 'Set waiting flag' => sub { > plan tests => 4; > >-- >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 23103
:
90538
|
90573
|
90775
|
90878
|
90879
|
90883
|
90884