Lines 819-830
is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting cat
Link Here
|
819 |
# /Test GetBudgetAuthCats |
819 |
# /Test GetBudgetAuthCats |
820 |
|
820 |
|
821 |
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub { |
821 |
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub { |
822 |
plan tests => 10; |
822 |
plan tests => 20; |
823 |
|
823 |
|
|
|
824 |
my $budget_period = $builder->build({ |
825 |
source => 'Aqbudgetperiod', |
826 |
value => { |
827 |
budget_period_active => 1, |
828 |
budget_total => 10000, |
829 |
} |
830 |
}); |
824 |
my $budget = $builder->build({ |
831 |
my $budget = $builder->build({ |
825 |
source => 'Aqbudget', |
832 |
source => 'Aqbudget', |
826 |
value => { |
833 |
value => { |
827 |
budget_amount => 1000, |
834 |
budget_amount => 1000, |
|
|
835 |
budget_encumb => undef, |
836 |
budget_expend => undef, |
837 |
budget_period_id => $budget_period->{budget_period_id}, |
838 |
budget_parent_id => undef, |
828 |
} |
839 |
} |
829 |
}); |
840 |
}); |
830 |
my $invoice = $builder->build({ |
841 |
my $invoice = $builder->build({ |
Lines 834-844
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
834 |
} |
845 |
} |
835 |
}); |
846 |
}); |
836 |
|
847 |
|
837 |
my $spent = GetBudgetSpent( $budget->{budget_id} ); |
848 |
my $spent = GetBudgetSpent( $budget->{budget_id} ); |
838 |
my $ordered = GetBudgetOrdered( $budget->{budget_id} ); |
849 |
my $ordered = GetBudgetOrdered( $budget->{budget_id} ); |
|
|
850 |
my $hierarchy = GetBudgetHierarchy($budget_period->{budget_period_id} ); |
839 |
|
851 |
|
840 |
is( $spent, 0, "New budget, no orders/invoices, should be nothing spent"); |
852 |
is( $spent, 0, "New budget, no orders/invoices, should be nothing spent"); |
841 |
is( $ordered, 0, "New budget, no orders/invoices, should be nothing ordered"); |
853 |
is( $ordered, 0, "New budget, no orders/invoices, should be nothing ordered"); |
|
|
854 |
is( @$hierarchy[0]->{total_spent},0,"New budgets, no orders/invoices, budget hierarchy shows 0 spent"); |
855 |
is( @$hierarchy[0]->{total_ordered},0,"New budgets, no orders/invoices, budget hierarchy shows 0 ordered"); |
842 |
|
856 |
|
843 |
my $inv_adj_1 = $builder->build({ |
857 |
my $inv_adj_1 = $builder->build({ |
844 |
source => 'AqinvoiceAdjustment', |
858 |
source => 'AqinvoiceAdjustment', |
Lines 852-859
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
852 |
|
866 |
|
853 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
867 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
854 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
868 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
|
|
869 |
$hierarchy = GetBudgetHierarchy($budget_period->{budget_period_id} ); |
855 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
870 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
856 |
is( $ordered, 0, "After adding invoice adjustment on open invoice not encumbered, should be nothing ordered"); |
871 |
is( $ordered, 0, "After adding invoice adjustment on open invoice not encumbered, should be nothing ordered"); |
|
|
872 |
is( @$hierarchy[0]->{total_spent},0,"After adding invoice adjustment on open invoice, budget hierarchy shows 0 spent"); |
873 |
is( @$hierarchy[0]->{total_ordered},0,"After adding invoice adjustment on open invoice, budget hierarchy shows 0 ordered"); |
857 |
|
874 |
|
858 |
my $inv_adj_2 = $builder->build({ |
875 |
my $inv_adj_2 = $builder->build({ |
859 |
source => 'AqinvoiceAdjustment', |
876 |
source => 'AqinvoiceAdjustment', |
Lines 867-874
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
867 |
|
884 |
|
868 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
885 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
869 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
886 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
|
|
887 |
$hierarchy = GetBudgetHierarchy($budget_period->{budget_period_id} ); |
870 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
888 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
871 |
is( $ordered, 3, "After adding invoice adjustment on open invoice encumbered, should be 3 ordered"); |
889 |
is( $ordered, 3, "After adding invoice adjustment on open invoice encumbered, should be 3 ordered"); |
|
|
890 |
is( @$hierarchy[0]->{total_spent},0,"After adding invoice adjustment on open invoice encumbered, budget hierarchy shows 0 spent"); |
891 |
is( @$hierarchy[0]->{total_ordered},3,"After adding invoice adjustment on open invoice encumbered, budget hierarchy shows 3 ordered"); |
872 |
|
892 |
|
873 |
my $invoice_2 = $builder->build({ |
893 |
my $invoice_2 = $builder->build({ |
874 |
source => 'Aqinvoice', |
894 |
source => 'Aqinvoice', |
Lines 897-909
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
897 |
|
917 |
|
898 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
918 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
899 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
919 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
|
|
920 |
$hierarchy = GetBudgetHierarchy($budget_period->{budget_period_id} ); |
900 |
is( $spent, 6, "After adding invoice adjustment on closed invoice, should be 6 spent, encumber has no affect once closed"); |
921 |
is( $spent, 6, "After adding invoice adjustment on closed invoice, should be 6 spent, encumber has no affect once closed"); |
901 |
is( $ordered, 3, "After adding invoice adjustment on closed invoice, should still be 3 ordered"); |
922 |
is( $ordered, 3, "After adding invoice adjustment on closed invoice, should still be 3 ordered"); |
|
|
923 |
is( @$hierarchy[0]->{total_spent},6,"After adding invoice adjustment on closed invoice, budget hierarchy shows 6 spent"); |
924 |
is( @$hierarchy[0]->{total_ordered},3,"After adding invoice adjustment on closed invoice, budget hierarchy still shows 3 ordered"); |
902 |
|
925 |
|
903 |
my $budget_2 = $builder->build({ |
926 |
my $budget0 = $builder->build({ |
904 |
source => 'Aqbudget', |
927 |
source => 'Aqbudget', |
905 |
value => { |
928 |
value => { |
906 |
budget_amount => 1000, |
929 |
budget_amount => 1000, |
|
|
930 |
budget_encumb => undef, |
931 |
budget_expend => undef, |
932 |
budget_period_id => $budget_period->{budget_period_id}, |
933 |
budget_parent_id => $budget->{budget_id}, |
907 |
} |
934 |
} |
908 |
}); |
935 |
}); |
909 |
my $inv_adj_5 = $builder->build({ |
936 |
my $inv_adj_5 = $builder->build({ |
Lines 912-918
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
912 |
invoiceid => $invoice->{invoiceid}, |
939 |
invoiceid => $invoice->{invoiceid}, |
913 |
adjustment => 3, |
940 |
adjustment => 3, |
914 |
encumber_open => 1, |
941 |
encumber_open => 1, |
915 |
budget_id => $budget_2->{budget_id}, |
942 |
budget_id => $budget0->{budget_id}, |
916 |
} |
943 |
} |
917 |
}); |
944 |
}); |
918 |
my $inv_adj_6 = $builder->build({ |
945 |
my $inv_adj_6 = $builder->build({ |
Lines 921-934
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub {
Link Here
|
921 |
invoiceid => $invoice_2->{invoiceid}, |
948 |
invoiceid => $invoice_2->{invoiceid}, |
922 |
adjustment => 3, |
949 |
adjustment => 3, |
923 |
encumber_open => 1, |
950 |
encumber_open => 1, |
924 |
budget_id => $budget_2->{budget_id}, |
951 |
budget_id => $budget0->{budget_id}, |
925 |
} |
952 |
} |
926 |
}); |
953 |
}); |
927 |
|
954 |
|
928 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
955 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
929 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
956 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
930 |
is( $spent, 6, "After adding invoice adjustment on a different budget should be 6 spent/budget unaffected"); |
957 |
$hierarchy = GetBudgetHierarchy($budget_period->{budget_period_id} ); |
931 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
958 |
is( $spent, 6, "After adding invoice adjustment on a child budget should be 6 spent/budget unaffected"); |
|
|
959 |
is( $ordered, 3, "After adding invoice adjustment on a child budget, should still be 3 ordered/budget unaffected"); |
960 |
is( @$hierarchy[0]->{total_spent},9,"After adding invoice adjustment on child budget, budget hierarchy shows 9 spent"); |
961 |
is( @$hierarchy[0]->{total_ordered},6,"After adding invoice adjustment on child budget, budget hierarchy shows 6 ordered"); |
932 |
|
962 |
|
933 |
}; |
963 |
}; |
934 |
|
964 |
|
935 |
- |
|
|