Bugzilla – Attachment 156069 Details for
Bug 31631
Optionally choose for tax-exclusive values to be used for calculating fund values (spent, ordered)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31631: (QA follow-up) Tidy code
Bug-31631-QA-follow-up-Tidy-code.patch (text/plain), 9.90 KB, created by
Kyle M Hall (khall)
on 2023-09-22 10:58:08 UTC
(
hide
)
Description:
Bug 31631: (QA follow-up) Tidy code
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-09-22 10:58:08 UTC
Size:
9.90 KB
patch
obsolete
>From e3aaebc114cede049825406029128063fc25b21b Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 22 Sep 2023 06:50:42 -0400 >Subject: [PATCH] Bug 31631: (QA follow-up) Tidy code > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > acqui/spent.pl | 2 +- > ...CalculateFundValuesIncludingTax_syspref.pl | 10 +- > t/db_dependent/Budgets.t | 98 +++++++++++-------- > 3 files changed, 66 insertions(+), 44 deletions(-) > >diff --git a/acqui/spent.pl b/acqui/spent.pl >index dfa3a041ae8..acd84676ee6 100755 >--- a/acqui/spent.pl >+++ b/acqui/spent.pl >@@ -52,7 +52,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > ); > > # Get correct unitprice field >-my ( $unitprice_field ) = C4::Budgets->FieldsForCalculatingFundValues(); >+my ($unitprice_field) = C4::Budgets->FieldsForCalculatingFundValues(); > > my $query = <<EOQ; > SELECT >diff --git a/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl b/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl >index fa21418f9fa..0226890cead 100755 >--- a/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl >+++ b/installer/data/mysql/atomicupdate/bug_31631-add_CalculateFundValuesIncludingTax_syspref.pl >@@ -1,12 +1,14 @@ > use Modern::Perl; > > return { >- bug_number => "31631", >+ bug_number => "31631", > description => "Add new system preference CalculateFundValuesIncludingTax", >- up => sub { >+ up => sub { > my ($args) = @_; >- my ($dbh, $out) = @$args{qw(dbh out)}; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; > >- $dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('CalculateFundValuesIncludingTax', '1', NULL, 'Include tax in the calculated fund values (spent, ordered) for all supplier configurations', 'YesNo')}); >+ $dbh->do( >+ q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('CalculateFundValuesIncludingTax', '1', NULL, 'Include tax in the calculated fund values (spent, ordered) for all supplier configurations', 'YesNo')} >+ ); > }, > }; >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index d3585e29639..418c66bc59e 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1219,31 +1219,49 @@ subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their > $schema->storage->txn_begin; > > # Test FieldsForCalculatingFundValues() >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); > my ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); >- is ( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" ); >- is ( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); >+ is( $unitprice_field, 'unitprice_tax_included', "We expect this to be unitprice_tax_included" ); >+ is( $ecost_field, 'ecost_tax_included', "We expect this to be ecost_tax_included" ); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); > ( $unitprice_field, $ecost_field ) = C4::Budgets->FieldsForCalculatingFundValues(); >- is ( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" ); >- is ( $ecost_field, 'ecost_tax_excluded', "We expect this to be ecost_tax_excluded" ); >+ is( $unitprice_field, 'unitprice_tax_excluded', "We expect this to be unitprice_tax_excluded" ); >+ is( $ecost_field, 'ecost_tax_excluded', "We expect this to be ecost_tax_excluded" ); > > # Test GetBudgetOrdered() > # ----------------------- > > # Build an order >- t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); >- my $item_1 = $builder->build_sample_item; >- my $invoice = $builder->build({ source => 'Aqinvoice'}); >- my $currency = $builder->build({ source => 'Currency', value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'BOO' } }); >- my $vendor = $builder->build({ source => 'Aqbookseller',value => { listincgst => 0, invoiceincgst => 0, listprice => $currency->{currency}, invoiceprice => $currency->{currency} } }); >- my $basket = $builder->build({ source => 'Aqbasket', value => { is_standing => 0, booksellerid => $vendor->{id} } }); >- my $budget_period = $builder->build({ source => 'Aqbudgetperiod' }); >- my $budget = $builder->build({ source => 'Aqbudget', value => { >- budget_period_id => $budget_period->{budget_period_id}, >- budget_parent_id => undef, >+ t::lib::Mocks::mock_preference( 'OrderPriceRounding', 'nearest_cent' ); >+ my $item_1 = $builder->build_sample_item; >+ my $invoice = $builder->build( { source => 'Aqinvoice' } ); >+ my $currency = $builder->build( >+ { >+ source => 'Currency', >+ value => { active => 1, archived => 0, symbol => 'F', rate => 2, isocode => undef, currency => 'BOO' } > } >- }); >+ ); >+ my $vendor = $builder->build( >+ { >+ source => 'Aqbookseller', >+ value => { >+ listincgst => 0, invoiceincgst => 0, listprice => $currency->{currency}, >+ invoiceprice => $currency->{currency} >+ } >+ } >+ ); >+ my $basket = >+ $builder->build( { source => 'Aqbasket', value => { is_standing => 0, booksellerid => $vendor->{id} } } ); >+ my $budget_period = $builder->build( { source => 'Aqbudgetperiod' } ); >+ my $budget = $builder->build( >+ { >+ source => 'Aqbudget', >+ value => { >+ budget_period_id => $budget_period->{budget_period_id}, >+ budget_parent_id => undef, >+ } >+ } >+ ); > my $orderdata = { > basketno => $basket->{basketno}, > booksellerid => $vendor->{id}, >@@ -1269,49 +1287,51 @@ subtest 'FieldsForCalculatingFundValues with a vendor NOT including tax in their > $orderdata = $order->unblessed(); > > # Place the order >- $order = $builder->build({ source => 'Aqorder', value => $orderdata }); >+ $order = $builder->build( { source => 'Aqorder', value => $orderdata } ); > > # Check order values with different CalculateFundValuesIncludingTax options >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); > my $budget_ordered = GetBudgetOrdered( $order->{budget_id} ); >- is ( $budget_ordered, 10, "We expect this to be the tax exclusive value" ); >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); >+ is( $budget_ordered, 10, "We expect this to be the tax exclusive value" ); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); > $budget_ordered = GetBudgetOrdered( $order->{budget_id} ); >- is ( $budget_ordered, 11.5, "We expect this to be the tax inclusive value" ); >+ is( $budget_ordered, 11.5, "We expect this to be the tax inclusive value" ); > > # Test GetBudgetSpent() and GetBudgetHierarchy() > # ----------------------------------------------- > > # Receive the order >- $orderdata->{unitprice} = 10; #we are paying what we expected >+ $orderdata->{unitprice} = 10; #we are paying what we expected > > # Do some maths > $order = Koha::Acquisition::Order->new($orderdata); > $order->populate_with_prices_for_receiving(); > $orderdata = $order->unblessed(); >- my $received_order = $builder->build({ source => 'Aqorder', value => $orderdata }); >+ my $received_order = $builder->build( { source => 'Aqorder', value => $orderdata } ); > > # Receive a copy of the order >- ModReceiveOrder({ >- biblionumber => $orderdata->{biblionumber}, >- order => $received_order, >- invoice => $invoice, >+ ModReceiveOrder( >+ { >+ biblionumber => $orderdata->{biblionumber}, >+ order => $received_order, >+ invoice => $invoice, > quantityreceived => 1, >- budget_id => $orderdata->{budget_id}, >- received_items => [], >- }); >+ budget_id => $orderdata->{budget_id}, >+ received_items => [], >+ } >+ ); > >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '0' ); > my $spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); >- is ( $spent_amount, 10, "We expect this to be the tax exclusive value" ); >- my $gbh = GetBudgetHierarchy($budget->{budget_period_id}); >- is ( @$gbh[0]->{budget_spent}, 10, "We expect this value to be the tax exclusive value"); >+ is( $spent_amount, 10, "We expect this to be the tax exclusive value" ); >+ my $gbh = GetBudgetHierarchy( $budget->{budget_period_id} ); >+ is( @$gbh[0]->{budget_spent}, 10, "We expect this value to be the tax exclusive value" ); > >- t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); >+ t::lib::Mocks::mock_preference( 'CalculateFundValuesIncludingTax', '1' ); > $spent_amount = GetBudgetSpent( $orderdata->{budget_id} ); >- is ( $spent_amount, 11.5, "We expect this to be the tax inclusive value" ); >- $gbh = GetBudgetHierarchy($budget->{budget_period_id}); >- is ( @$gbh[0]->{budget_spent}, 11.5, "We expect this value to be the tax inclusive value"); >+ is( $spent_amount, 11.5, "We expect this to be the tax inclusive value" ); >+ $gbh = GetBudgetHierarchy( $budget->{budget_period_id} ); >+ is( @$gbh[0]->{budget_spent}, 11.5, "We expect this value to be the tax inclusive value" ); > > $schema->storage->txn_rollback; > }; >-- >2.30.2
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 31631
:
141017
|
141018
|
141019
|
142597
|
142661
|
143156
|
143157
|
143158
|
143159
|
147011
|
147012
|
147013
|
147014
|
147015
|
147098
|
147099
|
147100
|
147101
|
147102
|
147103
|
147104
|
147105
|
150146
|
156062
|
156063
|
156064
|
156065
|
156066
|
156067
|
156068
| 156069