Bugzilla – Attachment 83118 Details for
Bug 21727
Add Koha::Account::Line->adjust
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21727: Unit tests for the refund case
Bug-21727-Unit-tests-for-the-refund-case.patch (text/plain), 3.06 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-12-12 13:51:43 UTC
(
hide
)
Description:
Bug 21727: Unit tests for the refund case
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-12-12 13:51:43 UTC
Size:
3.06 KB
patch
obsolete
>From 7c8175cf6dbaf03f2b767772e0464ff5102db9c5 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 12 Dec 2018 10:49:18 -0300 >Subject: [PATCH] Bug 21727: Unit tests for the refund case > >This patch introduces tests for the behaviour when the negative adjust >exceedes the amount that was already paid. In this case, the line amount >is expected to be set to 0, and a credit with the payed amount created. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Account/Lines.t >=> SUCCESS: tests pass! > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Account/Lines.t | 31 ++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index 7a9f080fc0..d3851d134a 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -272,7 +272,7 @@ subtest 'apply() tests' => sub { > > subtest 'adjust() tests' => sub { > >- plan tests => 19; >+ plan tests => 33; > > $schema->storage->txn_begin; > >@@ -352,6 +352,35 @@ subtest 'adjust() tests' => sub { > > is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); > >+ # Decrement the partially paid fine, less than what was paid >+ $debit_2->adjust( { amount => 50, type => 'fine_increment' } )->discard_changes; >+ >+ is( $debit_2->amount * 1, 50, 'Fine amount was updated in full' ); >+ is( $debit_2->amountoutstanding * 1, 10, 'Fine amountoutstanding was updated by difference' ); >+ is( $debit_2->lastincrement * 1, -110, 'lastincrement is the to the right value' ); >+ >+ $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); >+ is( $offsets->count, 4, 'An offset is generated for the decrement' ); >+ $THIS_offset = $offsets->last; >+ is( $THIS_offset->amount * 1, -110, 'Amount was calculated correctly (decrement by 110)' ); >+ is( $THIS_offset->type, 'Fine Update', 'Adjust type stored correctly' ); >+ >+ # Decrement the partially paid fine, more than what was paid >+ $debit_2->adjust( { amount => 30, type => 'fine_increment' } )->discard_changes; >+ is( $debit_2->amount * 1, 30, 'Fine amount was updated in full' ); >+ is( $debit_2->amountoutstanding * 1, 0, 'Fine amountoutstanding was zeroed (payment was 40)' ); >+ is( $debit_2->lastincrement * 1, -20, 'lastincrement is the to the right value' ); >+ >+ $offsets = Koha::Account::Offsets->search( { debit_id => $debit_2->id } ); >+ is( $offsets->count, 5, 'An offset is generated for the decrement' ); >+ $THIS_offset = $offsets->last; >+ is( $THIS_offset->amount * 1, -20, 'Amount was calculated correctly (decrement by 20)' ); >+ is( $THIS_offset->type, 'Fine Update', 'Adjust type stored correctly' ); >+ >+ my $overpayment_refund = $account->lines->last; >+ is( $overpayment_refund->amount * 1, -10, 'A new credit has been added' ); >+ is( $overpayment_refund->description, 'Overpayment refund', 'Credit generated with the expected description' ); >+ > $schema->storage->txn_rollback; > }; > >-- >2.20.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 21727
:
81879
|
82777
|
82778
|
83054
|
83055
|
83056
|
83058
|
83088
|
83089
|
83090
|
83091
|
83095
|
83096
|
83097
|
83098
|
83101
|
83117
|
83118
|
83121
|
83122
|
83818