Bugzilla – Attachment 79104 Details for
Bug 18736
Problems in order calculations (rounding errors)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18736: Unit tests for GetBudgetHierarchy
Bug-18736-Unit-tests-for-GetBudgetHierarchy.patch (text/plain), 4.09 KB, created by
Julian Maurice
on 2018-09-19 12:52:39 UTC
(
hide
)
Description:
Bug 18736: Unit tests for GetBudgetHierarchy
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2018-09-19 12:52:39 UTC
Size:
4.09 KB
patch
obsolete
>From 354dd1131a321486bccbb741a5837ddfd469d81c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 24 Aug 2018 11:11:19 +0000 >Subject: [PATCH] Bug 18736: Unit tests for GetBudgetHierarchy > >prove -v t/db_dependent/Budgets.t > >Signed-off-by: Julian Maurice <julian.maurice@biblibre.com> >--- > t/db_dependent/Budgets.t | 31 ++++++++++++++++++++++++++++--- > 1 file changed, 28 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Budgets.t b/t/db_dependent/Budgets.t >index 0b35e5f6d6..336c7c91e2 100755 >--- a/t/db_dependent/Budgets.t >+++ b/t/db_dependent/Budgets.t >@@ -1,6 +1,6 @@ > #!/usr/bin/perl > use Modern::Perl; >-use Test::More tests => 146; >+use Test::More tests => 147; > > BEGIN { > use_ok('C4::Budgets') >@@ -934,7 +934,7 @@ subtest 'GetBudgetSpent and GetBudgetOrdered' => sub { > > subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > >- plan tests => 16; >+ plan tests => 24; > > #Let's build an order, we need a couple things though > t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); >@@ -952,8 +952,13 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > authorised_value => 'PICKLE', > } > }); >+ my $spent_budget_period = $builder->build({ source => 'Aqbudgetperiod', value => { >+ } >+ }); > my $spent_budget = $builder->build({ source => 'Aqbudget', value => { > sort1_authcat => $budget_authcat->{category_name}, >+ budget_period_id => $spent_budget_period->{budget_period_id}, >+ budget_parent_id => undef, > } > }); > my $spent_orderinfo = { >@@ -998,6 +1003,16 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > $spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); > is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); > >+ #Test GetBudgetHierarchy for rounding >+ t::lib::Mocks::mock_preference('OrderPriceRounding',''); >+ my $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an exact order cost * quantity"); >+ is ( @$gbh[0]->{budget_ordered}+0, 78.8336, "We expect this to be an exact order cost * quantity"); >+ t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); >+ $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an rounded order cost * quantity"); >+ is ( @$gbh[0]->{budget_ordered}+0, 78.8, "We expect this to be an exact order cost * quantity"); >+ > #Let's test some budget planning > #Regression tests for bug 18736 > #We need an item to test by BRANCHES >@@ -1062,7 +1077,7 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > }); > my $received_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); > >-#And receive >+#And receive a copy of the order so we have both spent and ordered values > > ModReceiveOrder({ > biblionumber => $spent_order->{biblionumber}, >@@ -1083,6 +1098,16 @@ subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { > $spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); > is($spent_spent,'78.8',"We expect the spent amount to be equal to the estimated price rounded times quantity"); > >+ #Test GetBudgetHierarchy for rounding >+ t::lib::Mocks::mock_preference('OrderPriceRounding',''); >+ $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ is ( @$gbh[0]->{budget_spent}, 78.8336, "We expect this to be an exact order cost * quantity"); >+ is ( @$gbh[0]->{budget_ordered}, 78.8336, "We expect this to be an exact order cost * quantity"); >+ t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); >+ $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); >+ 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"); >+ > }; > > sub _get_dependencies { >-- >2.17.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 18736
:
64061
|
64065
|
70187
|
70188
|
70189
|
70768
|
71062
|
71063
|
71627
|
71628
|
71629
|
71630
|
71631
|
71632
|
74335
|
74336
|
74337
|
74338
|
74339
|
74340
|
74341
|
74342
|
74370
|
74371
|
74374
|
74397
|
74398
|
74422
|
74427
|
74438
|
76979
|
76980
|
76981
|
76982
|
76983
|
76984
|
76985
|
76986
|
76987
|
76988
|
76989
|
76990
|
76991
|
77614
|
77615
|
77616
|
77617
|
77618
|
78101
|
78120
|
78981
|
78982
|
78983
|
78984
|
78985
|
78986
|
78987
|
78988
|
79087
|
79088
|
79089
|
79090
|
79091
|
79092
|
79093
|
79094
|
79098
|
79099
|
79100
|
79101
|
79102
|
79103
|
79104
|
79105
|
79187
|
79223
|
79562
|
79563
|
82967
|
82968
|
82969
|
82970
|
82971
|
82972
|
82973
|
82974
|
82975
|
82976
|
82977
|
83212
|
83213
|
83214
|
83973
|
83974
|
83975
|
83976
|
83977
|
83978
|
83979
|
83980
|
83981
|
83982
|
83983
|
83984
|
83985
|
86646
|
86647
|
86648
|
86649
|
86650
|
86651
|
86652
|
86653
|
86654
|
86655
|
86656
|
86657
|
86658