Bugzilla – Attachment 81744 Details for
Bug 21673
Koha::Account::Lines->total_outstanding must be used when needed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21673: Use Koha::Account::Lines->total_amountoutstanding when needed
Bug-21673-Use-KohaAccountLines-totalamountoutstand.patch (text/plain), 4.12 KB, created by
Martin Renvoize (ashimema)
on 2018-10-31 15:07:46 UTC
(
hide
)
Description:
Bug 21673: Use Koha::Account::Lines->total_amountoutstanding when needed
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2018-10-31 15:07:46 UTC
Size:
4.12 KB
patch
obsolete
>From 8e570236bfd73873853d737578d7bf1a7bfedcbd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 25 Oct 2018 16:55:32 -0300 >Subject: [PATCH] Bug 21673: Use Koha::Account::Lines->total_amountoutstanding > when needed > >There are several times the same pattern to retrieve the sum of >amountoutstanding columns for Koha::Account::Line set. >We should use Koha::Account::Lines->total_outstanding instead. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Account.pm | 23 ++++------------------- > Koha/Account/Lines.pm | 14 +++++++++++--- > opac/opac-user.pl | 9 ++------- > 3 files changed, 17 insertions(+), 29 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index e6863979fd..ef5cd478ec 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -421,19 +421,11 @@ Return the balance (sum of amountoutstanding columns) > > sub balance { > my ($self) = @_; >- my $fines = Koha::Account::Lines->search( >+ return Koha::Account::Lines->search( > { > borrowernumber => $self->{patron_id}, >- }, >- { >- select => [ { sum => 'amountoutstanding' } ], >- as => ['total_amountoutstanding'], > } >- ); >- >- return ( $fines->count ) >- ? $fines->next->get_column('total_amountoutstanding') + 0 >- : 0; >+ )->total_outstanding; > } > > =head3 outstanding_debits >@@ -509,19 +501,12 @@ sub non_issues_charges { > } > @not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines); > >- my $non_issues_charges = Koha::Account::Lines->search( >+ return Koha::Account::Lines->search( > { > borrowernumber => $self->{patron_id}, > accounttype => { -not_in => \@not_fines } > }, >- { >- select => [ { sum => 'amountoutstanding' } ], >- as => ['non_issues_charges'], >- } >- ); >- return $non_issues_charges->count >- ? $non_issues_charges->next->get_column('non_issues_charges') + 0 >- : 0; >+ )->total_outstanding; > } > > 1; >diff --git a/Koha/Account/Lines.pm b/Koha/Account/Lines.pm >index fde90cd99c..66a91c9959 100644 >--- a/Koha/Account/Lines.pm >+++ b/Koha/Account/Lines.pm >@@ -46,9 +46,17 @@ empty it returns 0. > sub total_outstanding { > my ( $self ) = @_; > >- my $total = sum0( $self->get_column('amountoutstanding') ); >- >- return $total; >+ my $lines = $self->search( >+ {}, >+ { >+ select => [ { sum => 'amountoutstanding' } ], >+ as => ['total_amountoutstanding'], >+ } >+ ); >+ >+ return $lines->count >+ ? $lines->next->get_column('total_amountoutstanding') + 0 >+ : 0; > } > > =head2 Internal methods >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 500042dea4..c83f6d78f1 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -197,9 +197,8 @@ if ( $pending_checkouts->count ) { # Useless test > accounttype => [ 'F', 'FU', 'L' ], > itemnumber => $issue->{itemnumber} > }, >- { select => [ { sum => 'amountoutstanding' } ], as => ['charges'] } > ); >- $issue->{charges} = $charges->count ? $charges->next->get_column('charges') : 0; >+ $issue->{charges} = $charges->total_outstanding; > > my $rental_fines = Koha::Account::Lines->search( > { >@@ -207,13 +206,9 @@ if ( $pending_checkouts->count ) { # Useless test > amountoutstanding => { '>' => 0 }, > accounttype => 'Rent', > itemnumber => $issue->{itemnumber} >- }, >- { >- select => [ { sum => 'amountoutstanding' } ], >- as => ['rental_fines'] > } > ); >- $issue->{rentalfines} = $rental_fines->count ? $rental_fines->next->get_column('rental_fines') : 0; >+ $issue->{rentalfines} = $rental_fines->total_outstanding > > my $marcrecord = GetMarcBiblio({ biblionumber => $issue->{'biblionumber'} }); > $issue->{'subtitle'} = GetRecordValue('subtitle', $marcrecord, GetFrameworkCode($issue->{'biblionumber'})); >-- >2.19.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 21673
:
81196
|
81355
|
81356
| 81744 |
81745