Lines 1-6
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
use Modern::Perl; |
2 |
use Modern::Perl; |
3 |
use Test::More tests => 146; |
3 |
use Test::More tests => 147; |
4 |
|
4 |
|
5 |
BEGIN { |
5 |
BEGIN { |
6 |
use_ok('C4::Budgets') |
6 |
use_ok('C4::Budgets') |
Lines 939-945
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
939 |
|
939 |
|
940 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
940 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
941 |
|
941 |
|
942 |
plan tests => 16; |
942 |
plan tests => 24; |
943 |
|
943 |
|
944 |
#Let's build an order, we need a couple things though |
944 |
#Let's build an order, we need a couple things though |
945 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
945 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
Lines 957-964
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
957 |
authorised_value => 'PICKLE', |
957 |
authorised_value => 'PICKLE', |
958 |
} |
958 |
} |
959 |
}); |
959 |
}); |
|
|
960 |
my $spent_budget_period = $builder->build({ source => 'Aqbudgetperiod', value => { |
961 |
} |
962 |
}); |
960 |
my $spent_budget = $builder->build({ source => 'Aqbudget', value => { |
963 |
my $spent_budget = $builder->build({ source => 'Aqbudget', value => { |
961 |
sort1_authcat => $budget_authcat->{category_name}, |
964 |
sort1_authcat => $budget_authcat->{category_name}, |
|
|
965 |
budget_period_id => $spent_budget_period->{budget_period_id}, |
966 |
budget_parent_id => undef, |
962 |
} |
967 |
} |
963 |
}); |
968 |
}); |
964 |
my $spent_orderinfo = { |
969 |
my $spent_orderinfo = { |
Lines 1003-1008
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
1003 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
1008 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
1004 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
1009 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
1005 |
|
1010 |
|
|
|
1011 |
#Test GetBudgetHierarchy for rounding |
1012 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1013 |
my $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1014 |
is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an exact order cost * quantity"); |
1015 |
is ( @$gbh[0]->{budget_ordered}+0, 78.8336, "We expect this to be an exact order cost * quantity"); |
1016 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1017 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1018 |
is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an rounded order cost * quantity"); |
1019 |
is ( @$gbh[0]->{budget_ordered}+0, 78.8, "We expect this to be an exact order cost * quantity"); |
1020 |
|
1006 |
#Let's test some budget planning |
1021 |
#Let's test some budget planning |
1007 |
#Regression tests for bug 18736 |
1022 |
#Regression tests for bug 18736 |
1008 |
#We need an item to test by BRANCHES |
1023 |
#We need an item to test by BRANCHES |
Lines 1067-1073
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
1067 |
}); |
1082 |
}); |
1068 |
my $received_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); |
1083 |
my $received_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); |
1069 |
|
1084 |
|
1070 |
#And receive |
1085 |
#And receive a copy of the order so we have both spent and ordered values |
1071 |
|
1086 |
|
1072 |
ModReceiveOrder({ |
1087 |
ModReceiveOrder({ |
1073 |
biblionumber => $spent_order->{biblionumber}, |
1088 |
biblionumber => $spent_order->{biblionumber}, |
Lines 1088-1093
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
1088 |
$spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); |
1103 |
$spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); |
1089 |
is($spent_spent,'78.8',"We expect the spent amount to be equal to the estimated price rounded times quantity"); |
1104 |
is($spent_spent,'78.8',"We expect the spent amount to be equal to the estimated price rounded times quantity"); |
1090 |
|
1105 |
|
|
|
1106 |
#Test GetBudgetHierarchy for rounding |
1107 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1108 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1109 |
is ( @$gbh[0]->{budget_spent}, 78.8336, "We expect this to be an exact order cost * quantity"); |
1110 |
is ( @$gbh[0]->{budget_ordered}, 78.8336, "We expect this to be an exact order cost * quantity"); |
1111 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1112 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1113 |
is ( @$gbh[0]->{budget_spent}+0, 78.8, "We expect this to be a rounded order cost * quantity"); |
1114 |
is ( @$gbh[0]->{budget_ordered}, 78.8, "We expect this to be a rounded order cost * quantity"); |
1115 |
|
1091 |
}; |
1116 |
}; |
1092 |
|
1117 |
|
1093 |
sub _get_dependencies { |
1118 |
sub _get_dependencies { |
1094 |
- |
|
|