Bugzilla – Attachment 123442 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: (follow-up) Set CREATE offset for credits to positive
Bug-22435-follow-up-Set-CREATE-offset-for-credits-.patch (text/plain), 6.51 KB, created by
Martin Renvoize (ashimema)
on 2021-08-03 14:34:51 UTC
(
hide
)
Description:
Bug 22435: (follow-up) Set CREATE offset for credits to positive
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-08-03 14:34:51 UTC
Size:
6.51 KB
patch
obsolete
>From bd1eeba989d4fc2950dcb45b9cc6facc9f15eae8 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 5 Jul 2021 14:16:30 +0100 >Subject: [PATCH] Bug 22435: (follow-up) Set CREATE offset for credits to > positive > >The history view of an accountline shows increases and decreases in the >amount outstanding from the perspective of the credit/debit line you are >inspecting. > >Apply creates a negative offset amount which acts to 'reduce' both the >outstanding 'debt' for the debit line and the outstanding 'credit' for >the credit line. Starting with a negative offset for the credit thus >makes this nonsenical. > >Void creates positive offset amounts which act to 'restore' both the >outstanding 'debt' for the debit line and the outstanding 'credit' for >the credit line. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Account.pm | 2 +- > t/db_dependent/Accounts.t | 4 ++-- > t/db_dependent/Koha/Account.t | 16 +++++++++++----- > 3 files changed, 14 insertions(+), 8 deletions(-) > >diff --git a/Koha/Account.pm b/Koha/Account.pm >index 962f6e14fa..fe2465cae1 100644 >--- a/Koha/Account.pm >+++ b/Koha/Account.pm >@@ -242,7 +242,7 @@ sub add_credit { > { > credit_id => $line->id, > type => 'CREATE', >- amount => $amount >+ amount => $amount * -1 > } > )->store(); > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index c1ad715168..f468cd98e0 100755 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -376,7 +376,7 @@ subtest "More Koha::Account::pay tests" => sub { > 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' ); >+ 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' ); >@@ -449,7 +449,7 @@ subtest "Even more Koha::Account::pay tests" => sub { > 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' ); >+ 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' ); >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index a66af97723..fa36c4b835 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -201,7 +201,7 @@ subtest 'outstanding_credits() tests' => sub { > > subtest 'add_credit() tests' => sub { > >- plan tests => 17; >+ plan tests => 21; > > $schema->storage->txn_begin; > >@@ -219,7 +219,8 @@ subtest 'add_credit() tests' => sub { > > throws_ok { > $account->add_credit( >- { amount => 25, >+ { >+ amount => 25, > description => 'Payment of 25', > library_id => $patron->branchcode, > note => 'not really important', >@@ -231,7 +232,8 @@ subtest 'add_credit() tests' => sub { > 'Koha::Exceptions::MissingParameter', 'Exception thrown if interface parameter missing'; > > my $line_1 = $account->add_credit( >- { amount => 25, >+ { >+ amount => 25, > description => 'Payment of 25', > library_id => $patron->branchcode, > note => 'not really important', >@@ -245,6 +247,7 @@ subtest 'add_credit() tests' => sub { > is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' ); > is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' ); > is( $line_1->credit_type_code, 'PAYMENT', 'Account type is correctly set' ); >+ ok( $line_1->amount < 0, 'Credit amount is stored as a negative' ); > > # Enable logs > t::lib::Mocks::mock_preference( 'FinesLog', 1 ); >@@ -263,6 +266,7 @@ subtest 'add_credit() tests' => sub { > is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); > is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' ); > is( $line_2->credit_type_code, 'PAYMENT', 'Account type is correctly set' ); >+ ok( $line_1->amount < 0, 'Credit amount is stored as a negative' ); > > # offsets have the credit_id set to accountlines_id, and debit_id is undef > my $offset_1 = Koha::Account::Offsets->search({ credit_id => $line_1->id })->next; >@@ -270,8 +274,10 @@ subtest 'add_credit() tests' => sub { > > is( $offset_1->credit_id, $line_1->id, 'No debit_id is set for credits' ); > is( $offset_1->debit_id, undef, 'No debit_id is set for credits' ); >+ ok( $offset_1->amount > 0, 'Credit creation offset is a positive' ); > is( $offset_2->credit_id, $line_2->id, 'No debit_id is set for credits' ); > is( $offset_2->debit_id, undef, 'No debit_id is set for credits' ); >+ ok( $offset_2->amount > 0, 'Credit creation offset is a positive' ); > > my $line_3 = $account->add_credit( > { >@@ -1392,7 +1398,7 @@ subtest 'Koha::Account::payin_amount() tests' => sub { > is( $offsets->count, 4, 'Four offsets generated' ); > my $offset = $offsets->next; > is( $offset->type, 'CREATE', 'CREATE offset added for payin line' ); >- is( $offset->amount * 1, -10, 'Correct offset amount recorded' ); >+ is( $offset->amount * 1, 10, 'Correct offset amount recorded' ); > $offset = $offsets->next; > is( $offset->debit_id, $debit_1->id, "Offset added against debit_1"); > is( $offset->type, 'APPLY', "APPLY used for offset_type" ); >@@ -1425,7 +1431,7 @@ subtest 'Koha::Account::payin_amount() tests' => sub { > is( $offsets->count, 2, 'Two offsets generated' ); > $offset = $offsets->next; > is( $offset->type, 'CREATE', 'CREATE offset added for payin line' ); >- is( $offset->amount * 1, -2.50, 'Correct offset amount recorded' ); >+ is( $offset->amount * 1, 2.50, 'Correct offset amount recorded' ); > $offset = $offsets->next; > is( $offset->debit_id, $debit_5->id, "Offset added against debit_5"); > is( $offset->type, 'APPLY', "APPLY used for offset_type" ); >-- >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