Bugzilla – Attachment 82814 Details for
Bug 21896
Add Koha::Account::reconcile_balance
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[18.05.x] Bug 21896: (QA follow-up) Add tests for FIFO behaviour
1805x-Bug-21896-QA-follow-up-Add-tests-for-FIFO-be.patch (text/plain), 2.64 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-11-30 20:11:51 UTC
(
hide
)
Description:
[18.05.x] Bug 21896: (QA follow-up) Add tests for FIFO behaviour
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-11-30 20:11:51 UTC
Size:
2.64 KB
patch
obsolete
>From 9be4f81dbb9f63db46540236f3a26a4439b7c8a7 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 29 Nov 2018 10:55:51 -0300 >Subject: [PATCH] [18.05.x] Bug 21896: (QA follow-up) Add tests for FIFO > behaviour > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Account.t | 40 ++++++++++++++++++++++++++++++++++- > 1 file changed, 39 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index 572d86f9d0..d4121c6cc2 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -194,7 +194,7 @@ subtest 'add_credit() tests' => sub { > > subtest 'reconcile_balance' => sub { > >- plan tests => 3; >+ plan tests => 4; > > subtest 'more credit than debit' => sub { > >@@ -311,4 +311,42 @@ subtest 'reconcile_balance' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'credits are applied to older debits first' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $account = $patron->account; >+ >+ # Add Credits >+ $account->add_credit({ amount => 1 }); >+ $account->add_credit({ amount => 3 }); >+ >+ # Add Debits TODO: replace for calls to add_debit when time comes >+ my $debit_1 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 1, amountoutstanding => 1 })->store; >+ my $debit_2 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 2, amountoutstanding => 2 })->store; >+ my $debit_3 = Koha::Account::Line->new({ borrowernumber => $patron->id, amount => 3, amountoutstanding => 3 })->store; >+ >+ is( $account->balance(), 2, "Account balance is 2" ); >+ is( $account->outstanding_debits->total_outstanding, 6, 'Outstanding debits sum 6' ); >+ is( $account->outstanding_credits->total_outstanding, -4, 'Outstanding credits sum -4' ); >+ >+ $account->reconcile_balance(); >+ >+ is( $account->balance(), 2, "Account balance is 2" ); >+ is( $account->outstanding_debits->total_outstanding, 2, 'Outstanding debits sum 2' ); >+ is( $account->outstanding_credits->total_outstanding, 0, 'Outstanding credits sum 0' ); >+ >+ $debit_1->discard_changes; >+ is( $debit_1->amountoutstanding + 0, 0, 'Old debit payed' ); >+ $debit_2->discard_changes; >+ is( $debit_2->amountoutstanding + 0, 0, 'Old debit payed' ); >+ $debit_3->discard_changes; >+ is( $debit_3->amountoutstanding + 0, 2, 'Newest debit only partially payed' ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; >-- >2.19.2
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 21896
:
82684
|
82685
|
82688
|
82689
|
82690
|
82691
|
82692
|
82701
|
82702
|
82703
|
82720
|
82721
|
82722
|
82735
|
82736
|
82737
|
82738
|
82739
|
82740
|
82742
|
82811
|
82812
|
82813
| 82814 |
82815
|
82820