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 934-940
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
934 |
|
934 |
|
935 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
935 |
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub { |
936 |
|
936 |
|
937 |
plan tests => 16; |
937 |
plan tests => 24; |
938 |
|
938 |
|
939 |
#Let's build an order, we need a couple things though |
939 |
#Let's build an order, we need a couple things though |
940 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
940 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
Lines 952-959
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
952 |
authorised_value => 'PICKLE', |
952 |
authorised_value => 'PICKLE', |
953 |
} |
953 |
} |
954 |
}); |
954 |
}); |
|
|
955 |
my $spent_budget_period = $builder->build({ source => 'Aqbudgetperiod', value => { |
956 |
} |
957 |
}); |
955 |
my $spent_budget = $builder->build({ source => 'Aqbudget', value => { |
958 |
my $spent_budget = $builder->build({ source => 'Aqbudget', value => { |
956 |
sort1_authcat => $budget_authcat->{category_name}, |
959 |
sort1_authcat => $budget_authcat->{category_name}, |
|
|
960 |
budget_period_id => $spent_budget_period->{budget_period_id}, |
961 |
budget_parent_id => undef, |
957 |
} |
962 |
} |
958 |
}); |
963 |
}); |
959 |
my $spent_orderinfo = { |
964 |
my $spent_orderinfo = { |
Lines 998-1003
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
998 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
1003 |
$spent_ordered = GetBudgetOrdered( $spent_order->{budget_id} ); |
999 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
1004 |
is($spent_ordered,'78.8',"We expect the ordered amount to be equal to the estimated price rounded times quantity"); |
1000 |
|
1005 |
|
|
|
1006 |
#Test GetBudgetHierarchy for rounding |
1007 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1008 |
my $gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1009 |
is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an exact order cost * quantity"); |
1010 |
is ( @$gbh[0]->{budget_ordered}+0, 78.8336, "We expect this to be an exact order cost * quantity"); |
1011 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1012 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1013 |
is ( @$gbh[0]->{budget_spent}+0, 0, "We expect this to be an rounded order cost * quantity"); |
1014 |
is ( @$gbh[0]->{budget_ordered}+0, 78.8, "We expect this to be an exact order cost * quantity"); |
1015 |
|
1001 |
#Let's test some budget planning |
1016 |
#Let's test some budget planning |
1002 |
#Regression tests for bug 18736 |
1017 |
#Regression tests for bug 18736 |
1003 |
#We need an item to test by BRANCHES |
1018 |
#We need an item to test by BRANCHES |
Lines 1062-1068
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
1062 |
}); |
1077 |
}); |
1063 |
my $received_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); |
1078 |
my $received_order = $builder->build({ source => 'Aqorder', value => $spent_orderinfo }); |
1064 |
|
1079 |
|
1065 |
#And receive |
1080 |
#And receive a copy of the order so we have both spent and ordered values |
1066 |
|
1081 |
|
1067 |
ModReceiveOrder({ |
1082 |
ModReceiveOrder({ |
1068 |
biblionumber => $spent_order->{biblionumber}, |
1083 |
biblionumber => $spent_order->{biblionumber}, |
Lines 1083-1088
subtest 'GetBudgetSpent GetBudgetOrdered GetBudgetsPlanCell tests' => sub {
Link Here
|
1083 |
$spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); |
1098 |
$spent_spent = GetBudgetSpent( $spent_order->{budget_id} ); |
1084 |
is($spent_spent,'78.8',"We expect the spent amount to be equal to the estimated price rounded times quantity"); |
1099 |
is($spent_spent,'78.8',"We expect the spent amount to be equal to the estimated price rounded times quantity"); |
1085 |
|
1100 |
|
|
|
1101 |
#Test GetBudgetHierarchy for rounding |
1102 |
t::lib::Mocks::mock_preference('OrderPriceRounding',''); |
1103 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1104 |
is ( @$gbh[0]->{budget_spent}, 78.8336, "We expect this to be an exact order cost * quantity"); |
1105 |
is ( @$gbh[0]->{budget_ordered}, 78.8336, "We expect this to be an exact order cost * quantity"); |
1106 |
t::lib::Mocks::mock_preference('OrderPriceRounding','nearest_cent'); |
1107 |
$gbh = GetBudgetHierarchy($spent_budget->{budget_period_id}); |
1108 |
is ( @$gbh[0]->{budget_spent}+0, 78.8, "We expect this to be a rounded order cost * quantity"); |
1109 |
is ( @$gbh[0]->{budget_ordered}, 78.8, "We expect this to be a rounded order cost * quantity"); |
1110 |
|
1086 |
}; |
1111 |
}; |
1087 |
|
1112 |
|
1088 |
sub _get_dependencies { |
1113 |
sub _get_dependencies { |
1089 |
- |
|
|