Bugzilla – Attachment 122017 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.10 KB, created by
Victor Grousset/tuxayo
on 2021-06-16 00:02:10 UTC
(
hide
)
Description:
Bug 28421: Unit Tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2021-06-16 00:02:10 UTC
Size:
5.10 KB
patch
obsolete
>From 17dce0371d67ad4d62753f02e915258656c7869c 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 >0/ Don't apply >1/ Run t/db_dependent/Koha/Items.t >2/ Prior to this commit the test should pass >3/ Apply this commit but not the dependency(bug 22435) >3/ The test should fail >4/ Bug 22435 should make the test pass again. > >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > 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 b8767ad861..245f687e3e 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -557,10 +557,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( >@@ -615,11 +617,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, >@@ -630,8 +632,8 @@ subtest 'store' => sub { > > $payment->apply( { debits => [$lost_fee_line] } ); > >- # 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, >@@ -641,18 +643,64 @@ subtest 'store' => sub { > ); > $write_off->apply( { debits => [$lost_fee_line] } ); > >+ >+ 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] } ); >+ >+ # 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] } ); >+ >+ 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; >@@ -685,7 +733,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.32.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 28421
:
121316
|
121317
|
122017
|
122162