Bugzilla – Attachment 118546 Details for
Bug 22435
Clarify account_offset types by converting them to clear codes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22435: Update unit tests
Bug-22435-Update-unit-tests.patch (text/plain), 10.31 KB, created by
Martin Renvoize (ashimema)
on 2021-03-19 14:14:14 UTC
(
hide
)
Description:
Bug 22435: Update unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-03-19 14:14:14 UTC
Size:
10.31 KB
patch
obsolete
>From 89f0ae666a4b4c3796115d1ddbf0b2d7ffb19254 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 17 Mar 2021 17:48:23 +0000 >Subject: [PATCH] Bug 22435: Update unit tests > >--- > t/db_dependent/Accounts.t | 46 +++++++++++++++---- > t/db_dependent/Circulation.t | 4 +- > .../Circulation/NoIssuesChargeGuarantees.t | 2 +- > t/db_dependent/Koha/Account/Line.t | 38 +++++++++------ > 4 files changed, 63 insertions(+), 27 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index 489ae7de36..3d253e6f0f 100755 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -358,7 +358,7 @@ subtest "Koha::Account::pay writeoff tests" => sub { > > subtest "More Koha::Account::pay tests" => sub { > >- plan tests => 8; >+ plan tests => 12; > > # Create a borrower > my $category = $builder->build({ source => 'Category' })->{ categorycode }; >@@ -392,11 +392,24 @@ subtest "More Koha::Account::pay tests" => sub { > my $account = Koha::Account->new( { patron_id => $borrowernumber } ); > my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } ); > # make the full payment >- $account->pay({ lines => [$line], amount => $amount, library_id => $branch, note => 'A payment note' }); >+ my $payment = $account->pay( >+ { >+ lines => [$line], >+ amount => $amount, >+ library_id => $branch, >+ note => 'A payment note' >+ } >+ ); > >- my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->{accountlines_id} })->next(); >- is( $offset->amount+0, -100, 'Offset amount is -100.00' ); >- is( $offset->type(), 'Payment', 'Offset type is Payment' ); >+ my $offsets = Koha::Account::Offsets->search({ credit_id => $payment->{payment_id} }); >+ is( $offsets->count, 2, 'Two offsets recorded'); >+ my $offset = $offsets->next; >+ is( $offset->type(), 'CREATE', 'First offset type is CREATE' ); >+ is( $offset->amount+0, -100, 'First offset amount is -100.00' ); >+ $offset = $offsets->next; >+ is( $offset->type(), 'APPLY', 'Second offset type is APPLY' ); >+ is( $offset->amount+0, -100, 'Second offset amount is -100.00' ); >+ is( $offset->debit_id, $accountline->{accountlines_id}, 'Second offset is against the right accountline'); > > my $stat = $schema->resultset('Statistic')->search({ > branch => $branch, >@@ -417,7 +430,7 @@ subtest "More Koha::Account::pay tests" => sub { > > subtest "Even more Koha::Account::pay tests" => sub { > >- plan tests => 8; >+ plan tests => 12; > > # Create a borrower > my $category = $builder->build({ source => 'Category' })->{ categorycode }; >@@ -452,11 +465,24 @@ subtest "Even more Koha::Account::pay tests" => sub { > my $account = Koha::Account->new( { patron_id => $borrowernumber } ); > my $line = Koha::Account::Lines->find( $accountline->{ accountlines_id } ); > # make the full payment >- $account->pay({ lines => [$line], amount => $partialamount, library_id => $branch, note => 'A payment note' }); >+ my $payment = $account->pay( >+ { >+ lines => [$line], >+ amount => $partialamount, >+ library_id => $branch, >+ note => 'A payment note' >+ } >+ ); > >- my $offset = Koha::Account::Offsets->search( { debit_id => $accountline->{ accountlines_id } } )->next(); >- is( $offset->amount+0, -60, 'Offset amount is -60.00' ); >- is( $offset->type, 'Payment', 'Offset type is payment' ); >+ my $offsets = Koha::Account::Offsets->search({ credit_id => $payment->{payment_id} }); >+ is( $offsets->count, 2, 'Two offsets recorded'); >+ my $offset = $offsets->next; >+ is( $offset->type(), 'CREATE', 'First offset type is CREATE' ); >+ is( $offset->amount+0, -60, 'First offset amount is -60.00' ); >+ $offset = $offsets->next; >+ is( $offset->type(), 'APPLY', 'Second offset type is APPLY' ); >+ is( $offset->amount+0, -60, 'Second offset amount is -60.00' ); >+ is( $offset->debit_id, $accountline->{accountlines_id}, 'Second offset is against the right accountline'); > > my $stat = $schema->resultset('Statistic')->search({ > branch => $branch, >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 27fc7cbbd3..7e207883d2 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -1285,7 +1285,7 @@ subtest "CanBookBeRenewed tests" => sub { > is( $line->issue_id, $issue->id, 'Account line issue id matches' ); > > my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next(); >- is( $offset->type, 'OVERDUE', 'Account offset type is Fine' ); >+ is( $offset->type, 'CREATE', 'Account offset type is CREATE' ); > is( $offset->amount+0, 15, 'Account offset amount is 15.00' ); > > t::lib::Mocks::mock_preference('WhenLostForgiveFine','0'); >@@ -3297,7 +3297,7 @@ subtest '_FixOverduesOnReturn' => sub { > C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' ); > > $accountline->_result()->discard_changes(); >- my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); >+ my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'APPLY' })->next(); > > is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); > isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); >diff --git a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >index 4746cb8ae1..84ad699d89 100755 >--- a/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >+++ b/t/db_dependent/Circulation/NoIssuesChargeGuarantees.t >@@ -81,7 +81,7 @@ is( $accountline->amountoutstanding+0, 10, "Found 10.00 amount outstanding" ); > is( $accountline->debit_type_code, "LOST", "Debit type is LOST" ); > > my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id })->next(); >-is( $offset->type, 'Lost Item', 'Got correct offset type' ); >+is( $offset->type, 'CREATE', 'Got CREATE offset type' ); > is( $offset->amount+0, 10, 'Got amount of $10.00' ); > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Koha/Account/Line.t b/t/db_dependent/Koha/Account/Line.t >index 0eaa469385..d96abb235e 100755 >--- a/t/db_dependent/Koha/Account/Line.t >+++ b/t/db_dependent/Koha/Account/Line.t >@@ -232,7 +232,7 @@ subtest 'apply() tests' => sub { > is( $offsets->count, 1, 'Only one offset is generated' ); > $THE_offset = $offsets->next; > is( $THE_offset->amount * 1, -90, 'Amount was calculated correctly (less than the available credit)' ); >- is( $THE_offset->type, 'Credit Applied', 'Defaults to \'Credit Applied\' offset type' ); >+ is( $THE_offset->type, 'APPLY', 'Defaults to \'APPLY\' offset type' ); > > $debits = Koha::Account::Lines->search({ accountlines_id => $debit_1->id }); > throws_ok >@@ -944,7 +944,7 @@ subtest "payout() tests" => sub { > > subtest "reduce() tests" => sub { > >- plan tests => 29; >+ plan tests => 34; > > $schema->storage->txn_begin; > >@@ -1067,12 +1067,16 @@ subtest "reduce() tests" => sub { > is( $reduction->status(), 'APPLIED', "Reduction status is 'APPLIED'" ); > > my $offsets = Koha::Account::Offsets->search( >- { credit_id => $reduction->id, debit_id => $debit1->id } ); >- is( $offsets->count, 1, 'Only one offset is generated' ); >+ { credit_id => $reduction->id } ); >+ is( $offsets->count, 2, 'Two offsets generated' ); > my $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'CREATE', 'CREATE offset added for discount line'); > is( $THE_offset->amount * 1, >- -5, 'Correct amount was applied against debit' ); >- is( $THE_offset->type, 'DISCOUNT', "Offset type set to 'DISCOUNT'" ); >+ -5, 'Correct offset amount recorded'); >+ $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'APPLY', "APPLY offset added for 'DISCOUNT'" ); >+ is( $THE_offset->amount * 1, -5, 'Correct amount offset against debt'); >+ is( $THE_offset->debit_id, $debit1->accountlines_id, 'APPLY offset recorded the correct debit_id'); > > # Zero offset created when zero outstanding > # (Refund another 5 on paid debt of 20) >@@ -1087,12 +1091,16 @@ subtest "reduce() tests" => sub { > is( $debit1->status(), 'REFUNDED', "Debit status updated to REFUNDED"); > > $offsets = Koha::Account::Offsets->search( >- { credit_id => $reduction->id, debit_id => $debit1->id } ); >- is( $offsets->count, 1, 'Only one new offset is generated' ); >+ { credit_id => $reduction->id } ); >+ is( $offsets->count, 2, 'Two offsets generated' ); >+ $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'CREATE', 'CREATE offset added for refund line'); >+ is( $THE_offset->amount * 1, >+ -5, 'Correct offset amount recorded'); > $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'APPLY', "APPLY offset added for 'REFUND'" ); > is( $THE_offset->amount * 1, > 0, 'Zero offset created for already paid off debit' ); >- is( $THE_offset->type, 'REFUND', "Offset type set to 'REFUND'" ); > > # Compound reduction should not allow more than original amount > # (Reduction of 5 + 5 + 20 > 20) >@@ -1123,7 +1131,7 @@ subtest "reduce() tests" => sub { > }; > > subtest "cancel() tests" => sub { >- plan tests => 16; >+ plan tests => 18; > > $schema->storage->txn_begin; > >@@ -1209,13 +1217,15 @@ subtest "cancel() tests" => sub { > is( $account->balance() * 1, 15, "Account balance is 15" ); > > my $offsets = Koha::Account::Offsets->search( >- { credit_id => $cancellation->id, debit_id => $debit1->id } ); >- is( $offsets->count, 1, 'Only one offset is generated' ); >+ { credit_id => $cancellation->id } ); >+ is( $offsets->count, 2, 'Two offsets are generated' ); > my $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'CREATE', 'CREATE offset added for cancel line'); >+ is( $THE_offset->amount * 1, -10, 'Correct offset amount recorded' ); >+ $THE_offset = $offsets->next; >+ is( $THE_offset->type, 'APPLY', "APPLY offset added" ); > is( $THE_offset->amount * 1, > -10, 'Correct amount was applied against debit' ); >- is( $THE_offset->type, 'CANCELLATION', >- "Offset type set to 'CANCELLATION'" ); > > $schema->storage->txn_rollback; > }; >-- >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 22435
:
118340
|
118341
|
118541
|
118542
|
118543
|
118544
|
118545
|
118546
|
118547
|
120040
|
120041
|
120042
|
120043
|
120044
|
120045
|
120046
|
120963
|
120964
|
120965
|
120966
|
120967
|
120968
|
120969
|
120970
|
120979
|
120980
|
120981
|
120982
|
120983
|
120984
|
120985
|
120986
|
120987
|
120988
|
120989
|
120990
|
120991
|
121004
|
121005
|
121006
|
121007
|
121008
|
121009
|
121010
|
121011
|
121012
|
121013
|
121014
|
121015
|
121016
|
121028
|
121757
|
121758
|
121759
|
121760
|
121761
|
121762
|
121763
|
121764
|
121765
|
121766
|
121767
|
121768
|
121769
|
121960
|
121961
|
121962
|
121963
|
121964
|
121965
|
121966
|
121967
|
121968
|
121969
|
121970
|
121971
|
121972
|
122148
|
122149
|
122150
|
122151
|
122152
|
122153
|
122154
|
122155
|
122156
|
122157
|
122158
|
122159
|
122160
|
122161
|
122235
|
122236
|
122237
|
122238
|
122239
|
122240
|
122241
|
122242
|
122243
|
122244
|
122245
|
122246
|
122247
|
122248
|
122249
|
122250
|
122251
|
122252
|
122253
|
122256
|
122257
|
122258
|
122259
|
122260
|
122261
|
122262
|
122263
|
122264
|
122265
|
122266
|
122267
|
122268
|
122269
|
122270
|
122271
|
122272
|
122273
|
122274
|
122553
|
122554
|
122555
|
122556
|
122557
|
122558
|
122559
|
122560
|
122561
|
122562
|
122563
|
122564
|
122565
|
122566
|
122567
|
122568
|
122569
|
122570
|
122571
|
122586
|
122899
|
122900
|
122901
|
122902
|
122903
|
122904
|
122905
|
122906
|
122907
|
122908
|
122909
|
122910
|
122911
|
122912
|
122913
|
122914
|
122915
|
122916
|
122917
|
122918
|
122937
|
123423
|
123424
|
123425
|
123426
|
123427
|
123428
|
123429
|
123430
|
123431
|
123432
|
123433
|
123434
|
123435
|
123436
|
123437
|
123438
|
123439
|
123440
|
123441
|
123442
|
123443