Bugzilla – Attachment 57991 Details for
Bug 17586
Add the Koha::Account->balance method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17586: Move ->get_balance to Koha::Account->balance
Bug-17586-Move--getbalance-to-KohaAccount-balance.patch (text/plain), 2.93 KB, created by
Jonathan Druart
on 2016-12-06 08:14:19 UTC
(
hide
)
Description:
Bug 17586: Move ->get_balance to Koha::Account->balance
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-06 08:14:19 UTC
Size:
2.93 KB
patch
obsolete
>From ef0c80f8a4b1ea591a1bb9e095d5d782ba62a5c9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 6 Dec 2016 09:12:57 +0100 >Subject: [PATCH] Bug 17586: Move ->get_balance to Koha::Account->balance > >--- > Koha/Account.pm | 24 ++++++++++++++++++++++++ > Koha/Account/Lines.pm | 20 -------------------- > t/db_dependent/Accounts.t | 10 +++++----- > 3 files changed, 29 insertions(+), 25 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index b7341b1..380bb57 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -162,6 +162,30 @@ sub pay { > } > } > >+=head3 balance >+ >+my $balance = $self->balance >+ >+Return the balance (sum of amountoutstanding columns) >+ >+=cut >+ >+sub balance { >+ my ($self) = @_; >+ my $fines = Koha::Account::Lines->search( >+ { >+ borrowernumber => $self->{patron_id}, >+ }, >+ { >+ select => [ { sum => 'amountoutstanding' } ], >+ as => ['total_amountoutstanding'], >+ } >+ ); >+ return $fines->count >+ ? $fines->next->get_column('total_amountoutstanding') >+ : 0; >+} >+ > 1; > > =head1 AUTHOR >diff --git a/Koha/Account/Lines.pm b/Koha/Account/Lines.pm >index aa54e0c..0e0677c 100644 >--- a/Koha/Account/Lines.pm >+++ b/Koha/Account/Lines.pm >@@ -36,26 +36,6 @@ Koha::Account::Lines - Koha Account Line Object set class > > =cut > >-=head3 get_balance >- >-my $balance = $self->get_balance >- >-Return the balance (sum of amountoutstanding columns) >- >-=cut >- >-sub get_balance { >- my ($self) = @_; >- my $fines = $self->search( >- {}, >- { >- select => [ { sum => 'amountoutstanding' } ], >- as => ['total_amountoutstanding'] >- } >- ); >- return $fines->count ? $fines->next->get_column('total_amountoutstanding') : 0; >-} >- > =head3 type > > =cut >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 864f4f4..bb92232 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -356,13 +356,13 @@ subtest "makepartialpayment() tests" => sub { > } > }; > >-subtest 'get_balance' => sub { >+subtest 'balance' => sub { > plan tests => 2; > > my $patron = $builder->build({source => 'Borrower'}); > $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >- my $account_lines = $patron->get_account_lines; >- is( $account_lines->get_balance, 0, 'get_balance should return 0 if the patron does not have fines' ); >+ my $account = $patron->account; >+ is( $account->balance, 0, 'balance should return 0 if the patron does not have fines' ); > > my $accountline_1 = $builder->build( > { >@@ -385,8 +385,8 @@ subtest 'get_balance' => sub { > } > ); > >- my $balance = $patron->get_account_lines->get_balance; >- is( int($balance), 29, 'get_balance should return the correct value'); >+ my $balance = $patron->account->balance; >+ is( int($balance), 29, 'balance should return the correct value'); > > $patron->delete; > }; >-- >2.9.3
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 17586
:
57337
|
57338
|
57906
|
57929
|
57990
| 57991