Bugzilla – Attachment 76519 Details for
Bug 20946
Cannot pay fines for patrons with credits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20946: (RM follow-up) Additional tests and fix addition to undef
Bug-20946-RM-follow-up-Additional-tests-and-fix-ad.patch (text/plain), 3.01 KB, created by
Nick Clemens (kidclamp)
on 2018-06-27 14:22:47 UTC
(
hide
)
Description:
Bug 20946: (RM follow-up) Additional tests and fix addition to undef
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-06-27 14:22:47 UTC
Size:
3.01 KB
patch
obsolete
>From 0a34fb17666f737f7eaa2d49b3dcaebee3a7e2fc Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 27 Jun 2018 03:53:27 +0000 >Subject: [PATCH] Bug 20946: (RM follow-up) Additional tests and fix addition > to undef > >Added a few tests with credit lines and found we got warnings, adjusted >the routine to avoid this >--- > Koha/Account.pm | 2 +- > t/db_dependent/Koha/Account.t | 19 ++++++++++++++++++- > 2 files changed, 19 insertions(+), 2 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index bffc98b..518e3c3 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -306,7 +306,7 @@ sub outstanding_debits { > ); > > # sum returns undef it list is empty >- my $total = sum( $lines->get_column('amountoutstanding') ) + 0; >+ my $total = sum( $lines->get_column('amountoutstanding') ) ? sum( $lines->get_column('amountoutstanding') ) + 0 : 0; > > return ( $total, $lines ); > } >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 5d15f4a..c0cce13 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -31,7 +31,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'outstanding_debits() tests' => sub { > >- plan tests => 7; >+ plan tests => 12; > > $schema->storage->txn_begin; > >@@ -59,6 +59,23 @@ subtest 'outstanding_debits() tests' => sub { > is( $total, 0, "Total if no outstanding debits is 0" ); > is( $lines->count, 0, "With no outstanding debits, we get back a Lines object with 0 lines" ); > >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2 })->store; >+ my $just_one = Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => 3 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -6 })->store; >+ ( $total, $lines ) = Koha::Account->new({ patron_id => $patron_2->id })->outstanding_debits(); >+ is( $total, 3, "Total if some outstanding debits and some credits is only debits" ); >+ is( $lines->count, 1, "With 1 outstanding debits, we get back a Lines object with 1 lines" ); >+ my $the_line = Koha::Account::Lines->find( $just_one->id ); >+ is_deeply( $the_line->unblessed, $lines->next->unblessed, "We get back the one correct line"); >+ >+ my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' }); >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -2 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -20 })->store; >+ Koha::Account::Line->new({ borrowernumber => $patron_2->id, amountoutstanding => -200 })->store; >+ ( $total, $lines ) = Koha::Account->new({ patron_id => $patron_3->id })->outstanding_debits(); >+ is( $total, 0, "Total if no outstanding debits total is 0" ); >+ is( $lines->count, 0, "With 0 outstanding debits, we get back a Lines object with 0 lines" ); > > $schema->storage->txn_rollback; > }; >-- >2.1.4
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 20946
:
76116
|
76317
|
76318
|
76394
|
76395
|
76432
|
76433
|
76434
|
76435
|
76437
|
76519
|
76521
|
76522
|
76632