Bugzilla – Attachment 118512 Details for
Bug 27995
Koha::Account::Line->apply should return the update Koha::Account::Line object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27995: Update return for Koha::Account::Line->apply
Bug-27995-Update-return-for-KohaAccountLine-apply.patch (text/plain), 3.21 KB, created by
Martin Renvoize (ashimema)
on 2021-03-19 11:28:45 UTC
(
hide
)
Description:
Bug 27995: Update return for Koha::Account::Line->apply
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-19 11:28:45 UTC
Size:
3.21 KB
patch
obsolete
>From aa099c08925e85266fa3d961f92d27be3e356077 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 19 Mar 2021 10:52:54 +0000 >Subject: [PATCH] Bug 27995: Update return for Koha::Account::Line->apply > >This patch updates the return value of Koha::Account::Line->apply to return the >updated Koha::Account::Line object with Koha::Object::Messages embedded >for the results of any triggered renewals. > >Available credit, the former return value, is still availabe via the >object directly as `amountoutstanding`. > >Koha::REST::V1::Patrons::Account->add_credit has been updated to reflect >the change. No other area's of Koha relied upon the return value. > >This patch also fixes a bug whereby if you passed a list of debits with >an outstanding debit larger than the outstanding credit then you could >end up with superflous offest lines with zero amounts that was >highlighted by the improved unit tests in >t/db_dependent/Koha/Account/Line.t > >Test plan >1/ Run t/db_dependent/Koha/Account/Line.t >2/ Run t/db_dependent/api/v1/patrons_accounts.t >3/ If both tests pass then signoff >--- > Koha/Account/Line.pm | 13 +++++++++++-- > Koha/REST/V1/Patrons/Account.pm | 5 ++--- > 2 files changed, 13 insertions(+), 5 deletions(-) > >diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm >index 476e0e49b9..62f73d50a0 100644 >--- a/Koha/Account/Line.pm >+++ b/Koha/Account/Line.pm >@@ -657,7 +657,14 @@ sub apply { > # Attempt to renew the item associated with this debit if > # appropriate > if ($debit->renewable) { >- $debit->renew_item($params->{interface}); >+ my $outcome = $debit->renew_item($params->{interface}); >+ $self->add_message( >+ { >+ type => 'info', >+ message => 'renewal', >+ payload => $outcome >+ } >+ ); > } > > # Same logic exists in Koha::Account::pay >@@ -677,10 +684,12 @@ sub apply { > C4::Circulation::ReturnLostItem( $self->borrowernumber, > $debit->itemnumber ); > } >+ >+ last if $available_credit == 0; > } > }); > >- return $available_credit; >+ return $self; > } > > =head3 payout >diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm >index aee36497ce..c75f91a1f7 100644 >--- a/Koha/REST/V1/Patrons/Account.pm >+++ b/Koha/REST/V1/Patrons/Account.pm >@@ -132,13 +132,12 @@ sub add_credit { > $debits = Koha::Account::Lines->search({ accountlines_id => { -in => $debits_ids } }) > if $debits_ids; > >- my $outstanding_credit = $credit->amountoutstanding; > if ($debits) { > # pay them! >- $outstanding_credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' }); >+ $credit = $credit->apply({ debits => [ $debits->as_list ], offset_type => 'payment' }); > } > >- if ($outstanding_credit) { >+ if ($credit->amountoutstanding != 0) { > my $outstanding_debits = $account->outstanding_debits; > $credit->apply({ debits => [ $outstanding_debits->as_list ], offset_type => 'payment' }); > } >-- >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 27995
:
118511
|
118512
|
118615
|
118616
|
119182
|
119183
|
119203
|
119204
|
120010
|
120011
|
120078
|
120079
|
120080
|
120083
|
120085
|
120086
|
120087