View | Details | Raw Unified | Return to bug 18736
Collapse All | Expand All

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

Return to bug 18736