Bugzilla – Attachment 76640 Details for
Bug 20990
Add Koha::Account::outstanding_credits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20990: (QA follow-up) make outstanding_credits return the account lines only
Bug-20990-QA-follow-up-make-outstandingcredits-ret.patch (text/plain), 3.21 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-07-02 19:12:09 UTC
(
hide
)
Description:
Bug 20990: (QA follow-up) make outstanding_credits return the account lines only
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-07-02 19:12:09 UTC
Size:
3.21 KB
patch
obsolete
>From b9cc5942247e50328c3aded1755886fceaf46e19 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 2 Jul 2018 15:59:54 -0300 >Subject: [PATCH] Bug 20990: (QA follow-up) make outstanding_credits return the > account lines only > >This patch was discussed with Jonathan on a QA conversation. It is >better to keep this simpler and more reusable. And is the right approach >in this case. > >This patch makes Koha::Account::outstanding_credits return the account >lines, code that used the $total value, will just use > > $lines->total_outstanding; > >Tests are adjusted accordingly. > >To test: >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Account.t >=> SUCCESS: Test pass. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Account.pm | 7 ++----- > t/db_dependent/Koha/Account.t | 11 ++++++----- > 2 files changed, 8 insertions(+), 10 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 82535159b6..036b34e429 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -424,7 +424,7 @@ sub outstanding_debits { > > =head3 outstanding_credits > >-my ( $total, $lines ) = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits; >+my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits; > > =cut > >@@ -438,10 +438,7 @@ sub outstanding_credits { > } > ); > >- # sum returns undef if list is empty >- my $total = sum0( $lines->get_column('amountoutstanding') ); >- >- return ( $total, $lines ); >+ return $lines; > } > > =head3 non_issues_charges >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 6c2785d943..cfc14addf7 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -90,7 +90,7 @@ subtest 'outstanding_credits() tests' => sub { > $schema->storage->txn_begin; > > my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >- my $account = Koha::Account->new({ patron_id => $patron->id }); >+ my $account = $patron->account; > > my @generated_lines; > push @generated_lines, $account->add_credit({ amount => 1 }); >@@ -98,9 +98,9 @@ subtest 'outstanding_credits() tests' => sub { > push @generated_lines, $account->add_credit({ amount => 3 }); > push @generated_lines, $account->add_credit({ amount => 4 }); > >- my ( $total, $lines ) = $account->outstanding_credits(); >+ my $lines = $account->outstanding_credits(); > >- is( $total, -10, 'Outstandig credits total is correctly calculated' ); >+ is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' ); > > my $i = 0; > foreach my $line ( @{ $lines->as_list } ) { >@@ -109,8 +109,9 @@ subtest 'outstanding_credits() tests' => sub { > $i++; > } > >- ( $total, $lines ) = Koha::Account->new({ patron_id => 'InvalidBorrowernumber' })->outstanding_credits(); >- is( $total, 0, "Total if no outstanding credits is 0" ); >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ $lines = $patron_2->account->outstanding_credits(); >+ is( $lines->total_outstanding, 0, "Total if no outstanding credits is 0" ); > is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" ); > > $schema->storage->txn_rollback; >-- >2.18.0
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 20990
:
76380
|
76381
|
76405
|
76406
|
76407
|
76446
|
76447
|
76448
|
76449
|
76525
|
76640
|
76739
|
76740
|
76741
|
76742
|
76743