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 => 144; |
3 |
use Test::More tests => 145; |
4 |
|
4 |
|
5 |
BEGIN { |
5 |
BEGIN { |
6 |
use_ok('C4::Budgets') |
6 |
use_ok('C4::Budgets') |
Lines 472-478
ModReceiveOrder({
Link Here
|
472 |
} ); |
472 |
} ); |
473 |
|
473 |
|
474 |
is ( GetBudgetSpent( $fund ), 6, "total shipping cost is 6"); |
474 |
is ( GetBudgetSpent( $fund ), 6, "total shipping cost is 6"); |
475 |
is ( GetBudgetOrdered( $fund ), '20.000000', "total ordered price is 20"); |
475 |
is ( GetBudgetOrdered( $fund ), '26', "total ordered price is 20"); |
476 |
|
476 |
|
477 |
|
477 |
|
478 |
# CloneBudgetPeriod |
478 |
# CloneBudgetPeriod |
Lines 798-803
is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting cat
Link Here
|
798 |
|
798 |
|
799 |
# /Test GetBudgetAuthCats |
799 |
# /Test GetBudgetAuthCats |
800 |
|
800 |
|
|
|
801 |
subtest 'GetBudgetSpent and GetBudgetOrdered' => sub { |
802 |
plan tests => 10; |
803 |
|
804 |
my $budget = $builder->build({ |
805 |
source => 'Aqbudget', |
806 |
value => { |
807 |
budget_amount => 1000, |
808 |
} |
809 |
}); |
810 |
my $invoice = $builder->build({ |
811 |
source => 'Aqinvoice', |
812 |
value => { |
813 |
closedate => undef, |
814 |
} |
815 |
}); |
816 |
|
817 |
my $spent = GetBudgetSpent( $budget->{budget_id} ); |
818 |
my $ordered = GetBudgetOrdered( $budget->{budget_id} ); |
819 |
|
820 |
is( $spent, 0, "New budget, no orders/invoices, should be nothing spent"); |
821 |
is( $ordered, 0, "New budget, no orders/invoices, should be nothing ordered"); |
822 |
|
823 |
my $inv_adj_1 = $builder->build({ |
824 |
source => 'InvoiceAdjustment', |
825 |
value => { |
826 |
invoiceid => $invoice->{invoiceid}, |
827 |
adjustment => 3, |
828 |
encumber_open => 0, |
829 |
budget_id => $budget->{budget_id}, |
830 |
} |
831 |
}); |
832 |
|
833 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
834 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
835 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
836 |
is( $ordered, 0, "After adding invoice adjustment on open invoice not encumbered, should be nothing ordered"); |
837 |
|
838 |
my $inv_adj_2 = $builder->build({ |
839 |
source => 'InvoiceAdjustment', |
840 |
value => { |
841 |
invoiceid => $invoice->{invoiceid}, |
842 |
adjustment => 3, |
843 |
encumber_open => 1, |
844 |
budget_id => $budget->{budget_id}, |
845 |
} |
846 |
}); |
847 |
|
848 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
849 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
850 |
is( $spent, 0, "After adding invoice adjustment on open invoice, should be nothing spent"); |
851 |
is( $ordered, 3, "After adding invoice adjustment on open invoice encumbered, should be 3 ordered"); |
852 |
|
853 |
my $invoice_2 = $builder->build({ |
854 |
source => 'Aqinvoice', |
855 |
value => { |
856 |
closedate => '2017-07-01', |
857 |
} |
858 |
}); |
859 |
my $inv_adj_3 = $builder->build({ |
860 |
source => 'InvoiceAdjustment', |
861 |
value => { |
862 |
invoiceid => $invoice_2->{invoiceid}, |
863 |
adjustment => 3, |
864 |
encumber_open => 0, |
865 |
budget_id => $budget->{budget_id}, |
866 |
} |
867 |
}); |
868 |
my $inv_adj_4 = $builder->build({ |
869 |
source => 'InvoiceAdjustment', |
870 |
value => { |
871 |
invoiceid => $invoice_2->{invoiceid}, |
872 |
adjustment => 3, |
873 |
encumber_open => 1, |
874 |
budget_id => $budget->{budget_id}, |
875 |
} |
876 |
}); |
877 |
|
878 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
879 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
880 |
is( $spent, 6, "After adding invoice adjustment on closed invoice, should be 6 spent, encumber has no affect once closed"); |
881 |
is( $ordered, 3, "After adding invoice adjustment on closed invoice, should still be 3 ordered"); |
882 |
|
883 |
my $budget_2 = $builder->build({ |
884 |
source => 'Aqbudget', |
885 |
value => { |
886 |
budget_amount => 1000, |
887 |
} |
888 |
}); |
889 |
my $inv_adj_5 = $builder->build({ |
890 |
source => 'InvoiceAdjustment', |
891 |
value => { |
892 |
invoiceid => $invoice->{invoiceid}, |
893 |
adjustment => 3, |
894 |
encumber_open => 1, |
895 |
budget_id => $budget_2->{budget_id}, |
896 |
} |
897 |
}); |
898 |
my $inv_adj_6 = $builder->build({ |
899 |
source => 'InvoiceAdjustment', |
900 |
value => { |
901 |
invoiceid => $invoice_2->{invoiceid}, |
902 |
adjustment => 3, |
903 |
encumber_open => 1, |
904 |
budget_id => $budget_2->{budget_id}, |
905 |
} |
906 |
}); |
907 |
|
908 |
$spent = GetBudgetSpent( $budget->{budget_id} ); |
909 |
$ordered = GetBudgetOrdered( $budget->{budget_id} ); |
910 |
is( $spent, 6, "After adding invoice adjustment on a different budget should be 6 spent/budget unaffected"); |
911 |
is( $ordered, 3, "After adding invoice adjustment on a different budget, should still be 3 ordered/budget unaffected"); |
912 |
|
913 |
}; |
914 |
|
801 |
sub _get_dependencies { |
915 |
sub _get_dependencies { |
802 |
my ($budget_hierarchy) = @_; |
916 |
my ($budget_hierarchy) = @_; |
803 |
my $graph; |
917 |
my $graph; |
804 |
- |
|
|