Bugzilla – Attachment 88707 Details for
Bug 22511
Koha::Account::Line->void loses the original type of the credit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22511: Update tests
Bug-22511-Update-tests.patch (text/plain), 7.06 KB, created by
Josef Moravec
on 2019-04-25 08:37:19 UTC
(
hide
)
Description:
Bug 22511: Update tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-04-25 08:37:19 UTC
Size:
7.06 KB
patch
obsolete
>From 772044576f9d8584628efcc0faf9bb18be1b0fa4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 15 Mar 2019 14:18:12 +0000 >Subject: [PATCH] Bug 22511: Update tests > >Updated tests to check for 'status' change and fixed 'accounttype' and >moved from t/db_dependent/Accounts.t to the more appropriate >t/db_dependent/Koha/Account/Lines.t > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/db_dependent/Accounts.t | 66 ----------------------------------- > t/db_dependent/Koha/Account/Lines.t | 68 +++++++++++++++++++++++++++++++++++++ > 2 files changed, 68 insertions(+), 66 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 791af7875b..e1ba90d124 100644 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -958,72 +958,6 @@ subtest "Koha::Account::non_issues_charges tests" => sub { > is( Koha::Account::Lines->count({ borrowernumber => $patron->id }), 2 + 2, "The 2 + 2 account lines still exists, the last 2 have been deleted ok" ); > }; > >-subtest "Koha::Account::Line::void tests" => sub { >- >- plan tests => 15; >- >- # Create a borrower >- my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; >- my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; >- >- my $borrower = Koha::Patron->new( { >- cardnumber => 'dariahall', >- surname => 'Hall', >- firstname => 'Daria', >- } ); >- $borrower->categorycode( $categorycode ); >- $borrower->branchcode( $branchcode ); >- $borrower->store; >- >- my $account = Koha::Account->new({ patron_id => $borrower->id }); >- >- my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10, interface => 'commandline' })->store(); >- my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20, interface => 'commandline' })->store(); >- >- is( $account->balance(), 30, "Account balance is 30" ); >- is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' ); >- is( $line2->amountoutstanding, 20, 'Second fee has amount outstanding of 20' ); >- >- my $id = $account->pay( >- { >- lines => [$line1, $line2], >- amount => 30, >- } >- ); >- >- my $account_payment = Koha::Account::Lines->find( $id ); >- >- is( $account->balance(), 0, "Account balance is 0" ); >- >- $line1->_result->discard_changes(); >- $line2->_result->discard_changes(); >- is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' ); >- is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' ); >- >- my $ret = $account_payment->void(); >- >- is( ref($ret), 'Koha::Account::Line', 'Void returns the account line' ); >- is( $account->balance(), 30, "Account balance is again 30" ); >- >- $account_payment->_result->discard_changes(); >- $line1->_result->discard_changes(); >- $line2->_result->discard_changes(); >- >- is( $account_payment->accounttype, 'VOID', 'Voided payment accounttype is VOID' ); >- is( $account_payment->amount+0, 0, 'Voided payment amount is 0' ); >- is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' ); >- >- is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' ); >- is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' ); >- >- # Accountlines that are not credits should be un-voidable >- my $line1_pre = $line1->unblessed(); >- $ret = $line1->void(); >- $line1->_result->discard_changes(); >- my $line1_post = $line1->unblessed(); >- is( $ret, undef, 'Attempted void on non-credit returns undef' ); >- is_deeply( $line1_pre, $line1_post, 'Non-credit account line cannot be voided' ) >-}; > > subtest "Koha::Account::Offset credit & debit tests" => sub { > >diff --git a/t/db_dependent/Koha/Account/Lines.t b/t/db_dependent/Koha/Account/Lines.t >index 610a342b3a..f0087a9935 100755 >--- a/t/db_dependent/Koha/Account/Lines.t >+++ b/t/db_dependent/Koha/Account/Lines.t >@@ -489,4 +489,72 @@ subtest 'checkout() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest "void() tests" => sub { >+ >+ plan tests => 15; >+ >+ # Create a borrower >+ my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; >+ my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; >+ >+ my $borrower = Koha::Patron->new( { >+ cardnumber => 'dariahall', >+ surname => 'Hall', >+ firstname => 'Daria', >+ } ); >+ $borrower->categorycode( $categorycode ); >+ $borrower->branchcode( $branchcode ); >+ $borrower->store; >+ >+ my $account = Koha::Account->new({ patron_id => $borrower->id }); >+ >+ my $line1 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 10, amountoutstanding => 10, interface => 'commandline' })->store(); >+ my $line2 = Koha::Account::Line->new({ borrowernumber => $borrower->borrowernumber, amount => 20, amountoutstanding => 20, interface => 'commandline' })->store(); >+ >+ is( $account->balance(), 30, "Account balance is 30" ); >+ is( $line1->amountoutstanding, 10, 'First fee has amount outstanding of 10' ); >+ is( $line2->amountoutstanding, 20, 'Second fee has amount outstanding of 20' ); >+ >+ my $id = $account->pay( >+ { >+ lines => [$line1, $line2], >+ amount => 30, >+ } >+ ); >+ >+ my $account_payment = Koha::Account::Lines->find( $id ); >+ >+ is( $account->balance(), 0, "Account balance is 0" ); >+ >+ $line1->_result->discard_changes(); >+ $line2->_result->discard_changes(); >+ is( $line1->amountoutstanding+0, 0, 'First fee has amount outstanding of 0' ); >+ is( $line2->amountoutstanding+0, 0, 'Second fee has amount outstanding of 0' ); >+ >+ my $ret = $account_payment->void(); >+ >+ is( ref($ret), 'Koha::Account::Line', 'Void returns the account line' ); >+ is( $account->balance(), 30, "Account balance is again 30" ); >+ >+ $account_payment->_result->discard_changes(); >+ $line1->_result->discard_changes(); >+ $line2->_result->discard_changes(); >+ >+ is( $account_payment->accounttype, 'Pay', 'Voided payment accounttype is still Pay' ); >+ is( $account_payment->status, 'VOID', 'Voided payment status is VOID' ); >+ is( $account_payment->amount+0, 0, 'Voided payment amount is 0' ); >+ is( $account_payment->amountoutstanding+0, 0, 'Voided payment amount outstanding is 0' ); >+ >+ is( $line1->amountoutstanding+0, 10, 'First fee again has amount outstanding of 10' ); >+ is( $line2->amountoutstanding+0, 20, 'Second fee again has amount outstanding of 20' ); >+ >+ # Accountlines that are not credits should be un-voidable >+ my $line1_pre = $line1->unblessed(); >+ $ret = $line1->void(); >+ $line1->_result->discard_changes(); >+ my $line1_post = $line1->unblessed(); >+ is( $ret, undef, 'Attempted void on non-credit returns undef' ); >+ is_deeply( $line1_pre, $line1_post, 'Non-credit account line cannot be voided' ) >+}; >+ > 1; >-- >2.11.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 22511
:
86674
|
86675
|
86903
|
86904
|
86905
|
86915
|
86916
|
86917
|
87088
|
87089
|
87090
|
87091
|
87221
|
87222
|
87223
|
87224
|
87632
|
87633
|
87634
|
87635
|
87650
|
87651
|
87652
|
87653
|
87654
|
87704
|
87706
|
87796
|
87797
|
87798
|
87799
|
87800
|
87869
|
87870
|
87871
|
87872
|
87873
| 88707 |
88708
|
88709
|
88710
|
88711
|
88712
|
88713
|
88714
|
88715
|
88748