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