Bugzilla – Attachment 121316 Details for
Bug 28421
Add tests for Voided Payment and Voided Writeoff.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28421: Unit Tests
Bug-28421-Unit-Tests.patch (text/plain), 5.20 KB, created by
Martin Renvoize (ashimema)
on 2021-05-24 09:59:43 UTC
(
hide
)
Description:
Bug 28421: Unit Tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-05-24 09:59:43 UTC
Size:
5.20 KB
patch
obsolete
>From 9e449f323ffb9e26a6bd2284a02aec67ce9e3283 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 24 May 2021 10:57:24 +0100 >Subject: [PATCH] Bug 28421: Unit Tests > >This patch adds test test cases for both a Voided Payment and Voided >Writeoff. These cases need special handling in the refund process. > >Test plan >1/ Run t/db_dependent/Koha/Items.t >2/ Prior to this commit the test should pass >3/ After this commit the test should fail >4/ The subsequent commit should make the test pass again. >--- > t/db_dependent/Koha/Items.t | 66 ++++++++++++++++++++++++++++++++----- > 1 file changed, 57 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 900004d912..633e1957b2 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -559,10 +559,12 @@ subtest 'store' => sub { > }; > > subtest >- 'Test with partial payement and write off, and remaining debt' => >+ 'Test with partial payment and write off, and remaining debt' => > sub { > >- plan tests => 17; >+ plan tests => 19; >+ >+ t::lib::Mocks::mock_preference( 'AccountAutoReconcile', 0 ); > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $item = $builder->build_sample_item( >@@ -617,11 +619,11 @@ subtest 'store' => sub { > is( > $account->balance, > $processfee_amount + $replacement_amount, >- 'Balance is PROCESSING + L' >+ 'Balance is PROCESSING + LOST' > ); > >- # Partially pay fee >- my $payment_amount = 27; >+ # Partially pay fee (99 - 27 = 72) >+ my $payment_amount = 24; > my $payment = $account->add_credit( > { > amount => $payment_amount, >@@ -633,8 +635,8 @@ subtest 'store' => sub { > $payment->apply( > { debits => [$lost_fee_line], offset_type => 'Payment' } ); > >- # Partially write off fee >- my $write_off_amount = 25; >+ # Partially write off fee (72 - 20 = 52) >+ my $write_off_amount = 20; > my $write_off = $account->add_credit( > { > amount => $write_off_amount, >@@ -642,21 +644,67 @@ subtest 'store' => sub { > interface => 'test', > } > ); >+ > $write_off->apply( > { debits => [$lost_fee_line], offset_type => 'Writeoff' } ); > >+ my $payment_amount_2 = 3; >+ my $payment_2 = $account->add_credit( >+ { >+ amount => $payment_amount_2, >+ type => 'PAYMENT', >+ interface => 'test', >+ } >+ ); >+ >+ $payment_2->apply( >+ { debits => [$lost_fee_line], offset_type => 'Payment' } ); >+ >+ # Partially write off fee (52 - 5 = 47) >+ my $write_off_amount_2 = 5; >+ my $write_off_2 = $account->add_credit( >+ { >+ amount => $write_off_amount_2, >+ type => 'WRITEOFF', >+ interface => 'test', >+ } >+ ); >+ >+ $write_off_2->apply( >+ { debits => [$lost_fee_line], offset_type => 'Writeoff' } ); >+ >+ is( >+ $account->balance, >+ $processfee_amount + >+ $replacement_amount - >+ $payment_amount - >+ $write_off_amount - >+ $payment_amount_2 - >+ $write_off_amount_2, >+ 'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF - PAYMENT 2 - WRITEOFF 2' >+ ); >+ >+ # VOID payment_2 and writeoff_2 >+ $payment_2->void({ interface => 'test' }); >+ $write_off_2->void({ interface => 'test' }); >+ > is( > $account->balance, > $processfee_amount + > $replacement_amount - > $payment_amount - > $write_off_amount, >- 'Payment and write off applied' >+ 'Balance is PROCESSING + LOST - PAYMENT 1 - WRITEOFF (PAYMENT 2 and WRITEOFF 2 VOIDED)' > ); > > # Store the amountoutstanding value > $lost_fee_line->discard_changes; > my $outstanding = $lost_fee_line->amountoutstanding; >+ is( >+ $outstanding + 0, >+ $replacement_amount - $payment_amount - $write_off_amount, >+ "Lost Fee Outstanding is LOST - PAYMENT 1 - WRITEOFF" >+ ); > > # Simulate item marked as found > $item->itemlost(0)->store; >@@ -689,7 +737,7 @@ subtest 'store' => sub { > is( > $credit_return->amount + 0, > ( $payment_amount + $outstanding ) * -1, >-'The account line of type LOST_FOUND has an amount equal to the payment + outstanding' >+'The account line of type LOST_FOUND has an amount equal to the payment 1 + outstanding' > ); > is( > $credit_return->amountoutstanding + 0, >-- >2.20.1
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 28421
:
121316
|
121317
|
122017
|
122162