Bugzilla – Attachment 83038 Details for
Bug 21759
Avoid manually setting amountoutstanding in _FixAccountForLostAndReturned
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21759: Regression tests
Bug-21759-Regression-tests.patch (text/plain), 4.93 KB, created by
Kyle M Hall (khall)
on 2018-12-11 14:17:04 UTC
(
hide
)
Description:
Bug 21759: Regression tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2018-12-11 14:17:04 UTC
Size:
4.93 KB
patch
obsolete
>From 42abd72ed98957b93587470fb66ee8d5c5294c23 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 10 Dec 2018 16:38:05 -0300 >Subject: [PATCH] Bug 21759: Regression tests > >This patch tests for a new behaviour in the _FixAccountForLostAndFound >method. > >The method will now add the amountoutstanding value for the lost item >fee to the CR credit to be generated. This means that: >- If there's some remaining debt, the same amount will be added to the > CR credit and used to cancel that debt. The final amountoutstanding > will be the same as before, but an offset will be generated as > required. >- If the line was written off, the behaviour remains unchanged, so no > offset. >- If the line was payed and/or written off in full only the payments are > refund, preserving the current behaviour. > >Only changes to the 'remaining debt' use cases on this tests are >expected. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Circulation.t >=> FAIL: Tests fail because the behaviour is not correct. > >Note: some tests order changes are introduced to avoid calling >discard_changes twice > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 28 ++++++++++++++++++---------- > 1 file changed, 18 insertions(+), 10 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 93f62571c6..4b8cd75d38 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -2053,7 +2053,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > my $lost_fee_line = $lost_fee_lines->next; > is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); > is( $lost_fee_line->amountoutstanding + 0, >- $replacement_amount, 'The right L amountountstanding is generated' ); >+ $replacement_amount, 'The right L amountoutstanding is generated' ); > > my $account = $patron->account; > my $debts = $account->outstanding_debits; >@@ -2148,7 +2148,7 @@ subtest '_FixAccountForLostAndReturned' => sub { > > subtest 'Test without payment or write off' => sub { > >- plan tests => 10; >+ plan tests => 12; > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $barcode = 'KD123456791'; >@@ -2187,7 +2187,11 @@ subtest '_FixAccountForLostAndReturned' => sub { > $replacement_amount, 'The right L amountountstanding is generated' ); > > my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id ); >- is( $credit_return_id, undef, 'No CR account line added' ); >+ my $credit_return = Koha::Account::Lines->find($credit_return_id); >+ >+ is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); >+ is( $credit_return->amount + 0, -99.00, 'The account line of type CR has an amount of -99' ); >+ is( $credit_return->amountoutstanding + 0, 0, 'The account line of type CR has an amountoutstanding of 0' ); > > $lost_fee_line->discard_changes; > is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); >@@ -2263,26 +2267,30 @@ subtest '_FixAccountForLostAndReturned' => sub { > 'Payment and write off applied' > ); > >+ # Store the amountoutstanding value >+ $lost_fee_line->discard_changes; >+ my $outstanding = $lost_fee_line->amountoutstanding; >+ > my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id ); > my $credit_return = Koha::Account::Lines->find($credit_return_id); > > is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' ); > >+ $lost_fee_line->discard_changes; >+ is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); >+ is( $lost_fee_line->accounttype, >+ 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); >+ > is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); > is( $credit_return->amount + 0, >- $payment_amount * -1, >- 'The account line of type CR has an amount equal to the payment' >+ ($payment_amount + $outstanding ) * -1, >+ 'The account line of type CR has an amount equal to the payment + outstanding' > ); > is( $credit_return->amountoutstanding + 0, > $payment_amount * -1, > 'The account line of type CR has an amountoutstanding equal to the payment' > ); > >- $lost_fee_line->discard_changes; >- is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); >- is( $lost_fee_line->accounttype, >- 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); >- > is( $account->balance, > $processfee_amount - $payment_amount, > 'The patron balance is the difference between the PF and the credit' >-- >2.17.2 (Apple Git-113)
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 21759
:
83029
|
83030
|
83038
|
83039
|
83040
|
83041
|
83042
|
83043