Bugzilla – Attachment 122565 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) Update POS for reduced offset types
Bug-22435-follow-up-Update-POS-for-reduced-offset-.patch (text/plain), 4.74 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-07-02 15:33:18 UTC
(
hide
)
Description:
Bug 22435: (follow-up) Update POS for reduced offset types
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-07-02 15:33:18 UTC
Size:
4.74 KB
patch
obsolete
>From 73f623c4977b6bc9fce461567b37876f18c14973 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 21 Jun 2021 15:43:04 +0100 >Subject: [PATCH] Bug 22435: (follow-up) Update POS for reduced offset types > >This patch updates the Koha::Charges::Sales class to use the 'CREATE' >and 'APPLY' offset types. > >Test plan >1/ Run t/db_dependent/Koha/Charges/Sales.t > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Charges/Sales.pm | 34 +++++++++++------------------ > t/db_dependent/Koha/Charges/Sales.t | 4 ++-- > 2 files changed, 15 insertions(+), 23 deletions(-) > >diff --git a/Koha/Charges/Sales.pm b/Koha/Charges/Sales.pm >index 5d99474868..20ea3fcb3d 100644 >--- a/Koha/Charges/Sales.pm >+++ b/Koha/Charges/Sales.pm >@@ -196,7 +196,7 @@ sub purchase { > my $schema = Koha::Database->new->schema; > my $dt = dt_from_string(); > my $total_owed = 0; >- my $credit; >+ my $payment; > > $schema->txn_do( > sub { >@@ -213,7 +213,7 @@ sub purchase { > { > amount => $amount, > debit_type_code => $item->{code}, >- amountoutstanding => 0, >+ amountoutstanding => $amount, > note => $item->{quantity}, > manager_id => $self->{staff_id}, > interface => 'intranet', >@@ -227,19 +227,19 @@ sub purchase { > my $account_offset = Koha::Account::Offset->new( > { > debit_id => $debit->id, >- type => 'Purchase', >+ type => 'CREATE', > amount => $amount > } > )->store(); > } > > # Add accountline for payment >- $credit = Koha::Account::Line->new( >+ $payment = Koha::Account::Line->new( > { > amount => 0 - $total_owed, > credit_type_code => 'PURCHASE', > payment_type => $self->{payment_type}, >- amountoutstanding => 0, >+ amountoutstanding => 0 - $total_owed, > manager_id => $self->{staff_id}, > interface => 'intranet', > branchcode => $self->{cash_register}->branch, >@@ -250,29 +250,21 @@ sub purchase { > )->store(); > > # Record the account offset >- my $credit_offset = Koha::Account::Offset->new( >+ my $payment_offset = Koha::Account::Offset->new( > { >- credit_id => $credit->id, >- type => 'Purchase', >- amount => $credit->amount >+ credit_id => $payment->id, >+ type => 'CREATE', >+ amount => $payment->amount > } > )->store(); > >- # Link payment to debits >- for my $debit ( @{$debits} ) { >- Koha::Account::Offset->new( >- { >- credit_id => $credit->accountlines_id, >- debit_id => $debit->id, >- amount => $debit->amount * -1, >- type => 'Payment', >- } >- )->store(); >- } >+ # Link payment to charges >+ $payment->apply( { debits => $debits } ); >+ $payment->discard_changes; > } > ); > >- return $credit; >+ return $payment; > } > > =head1 AUTHOR >diff --git a/t/db_dependent/Koha/Charges/Sales.t b/t/db_dependent/Koha/Charges/Sales.t >index c3064fbba0..85676ef840 100755 >--- a/t/db_dependent/Koha/Charges/Sales.t >+++ b/t/db_dependent/Koha/Charges/Sales.t >@@ -236,8 +236,8 @@ subtest 'purchase tests' => sub { > is(ref($credit), 'Koha::Account::Line', "Koha::Account::Line returned"); > ok($credit->is_credit, "return is a credit for payment"); > is($credit->credit_type_code, 'PURCHASE', "credit_type_code set correctly to 'PURCHASE' for payment"); >- is($credit->amount, -5.00, "amount is calculated correctly for payment"); >- is($credit->amountoutstanding, 0.00, "amountoutstanding is set to zero for payment"); >+ is($credit->amount * 1, -5, "amount is calculated correctly for payment"); >+ is($credit->amountoutstanding * 1, 0, "amountoutstanding is set to zero for payment"); > is($credit->manager_id, $staff->borrowernumber, "manager_id set correctionly for payment"); > is($credit->register_id, $cash_register->id, "register_id set correctly for payment"); > is($credit->payment_type, 'CASH', "payment_type set correctly for payment"); >-- >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 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