Bugzilla – Attachment 143158 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: Unit tests
Bug-31631-Unit-tests.patch (text/plain), 5.54 KB, created by
David Nind
on 2022-11-03 23:22:55 UTC
(
hide
)
Description:
Bug 31631: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-11-03 23:22:55 UTC
Size:
5.54 KB
patch
obsolete
>From e2d87fb86dd8827c8bcc2365814a57b38bdcb662 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Tue, 27 Sep 2022 17:01:51 +1300 >Subject: [PATCH] Bug 31631: Unit tests > >Test plan: >1. Run tests in koha-shell >sudo koha-shell <instance> >prove t/db_dependent/Budgets.t > >Sponsored-by: Waikato Institute of Technology, New Zealand > >Signed-off-by: David Nind <david@davidnind.com> >--- > t/db_dependent/Budgets.t | 83 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 81 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 094583f3f0..1ee95a4e72 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1038,9 +1038,9 @@ subtest 'GetBudgetSpent and GetBudgetOrdered and GetBudgetHierarchy shipping and > > }; > >-subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { >+subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell FieldsForCalculatingFundValues tests' => sub { > >- plan tests => 24; >+ plan tests => 34; > > #Let's build an order, we need a couple things though > t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); >@@ -1208,6 +1208,85 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > is ( @$gbh[0]->{budget_spent}+0, 78.8, "We expect this to be a rounded order cost * quantity"); > is ( @$gbh[0]->{budget_ordered}, 78.8, "We expect this to be a rounded order cost * quantity"); > >+ # Test GetBudgetSpent(), GetBudgetOrdered() and GetBudgetHierarchy() with the >+ # CalculateFundValuesIncludingTax system preference >+ my $spent_orderinfo_2 = { >+ basketno => $spent_basket->{basketno}, >+ booksellerid => $spent_vendor->{id}, >+ rrp => 16.99, >+ discount => .42, >+ ecost => 16.91, >+ biblionumber => $item_1->biblionumber, >+ currency => $spent_currency->{currency}, >+ tax_rate_on_ordering => 0.15, >+ tax_value_on_ordering => 0, >+ tax_rate_on_receiving => 0.15, >+ tax_value_on_receiving => 0, >+ quantity => 8, >+ quantityreceived => 0, >+ datecancellationprinted => undef, >+ datereceived => undef, >+ budget_id => $spent_budget->{budget_id}, >+ sort1 => $spent_sort1->{authorised_value}, >+ }; >+ >+ # Do some maths >+ my $spent_order_obj_2 = Koha::Acquisition::Order->new($spent_orderinfo_2); >+ $spent_order_obj_2->populate_with_prices_for_ordering(); >+ $spent_orderinfo_2 = $spent_order_obj_2->unblessed(); >+ >+ #Place the order >+ my $spent_order_2 = $builder->build({ source => 'Aqorder', value => $spent_orderinfo_2 }); >+ >+ t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); >+ $spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); >+ is ( $spent_ordered, 147.36, "We expect this to be the tax exclusive value" ); >+ >+ t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); >+ $spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); >+ is ( $spent_ordered, 157.6, "We expect this to be the tax exclusive value" ); >+ >+ # Receive the order >+ $spent_orderinfo_2->{unitprice} = 9.85; #we are paying what we expected >+ >+ #Do our maths >+ $spent_order_obj_2 = Koha::Acquisition::Order->new($spent_orderinfo_2); >+ $spent_order_obj_2->populate_with_prices_for_receiving(); >+ $spent_orderinfo_2 = $spent_order_obj_2->unblessed(); >+ my $received_order_2 = $builder->build({ source => 'Aqorder', value => $spent_orderinfo_2 }); >+ >+ #Receive a copy of the order >+ ModReceiveOrder({ >+ biblionumber => $spent_order_2->{biblionumber}, >+ order => $received_order_2, >+ invoice => $spent_invoice, >+ quantityreceived => $spent_order_2->{quantity}, >+ budget_id => $spent_order_2->{budget_id}, >+ received_items => [], >+ }); >+ >+ t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '0'); >+ $spent_spent = GetBudgetSpent( $spent_order_2->{budget_id} ); >+ is ( $spent_spent, 147.36, "We expect this to be the tax exclusive value" ); >+ $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ is ( @$gbh[0]->{budget_spent}, 147.36, "We expect this value to be the tax exclusive value"); >+ >+ t::lib::Mocks::mock_preference('CalculateFundValuesIncludingTax', '1'); >+ $spent_spent = GetBudgetSpent( $spent_order_2->{budget_id} ); >+ is ( $spent_spent, 157.6 , "We expect this to be the tax exclusive value" ); >+ $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ is ( @$gbh[0]->{budget_spent}, 157.6, "We expect this value to be the tax exclusive value"); >+ >+ # Test FieldsForCalculatingFundValues() >+ 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'); >+ ( $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" ); >+ > }; > > sub _get_dependencies { >-- >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