Lines 1-6
Link Here
|
1 |
use strict; |
1 |
use strict; |
2 |
use warnings; |
2 |
use warnings; |
3 |
use Test::More tests=>18; |
3 |
use Test::More tests=>29; |
4 |
|
4 |
|
5 |
BEGIN {use_ok('C4::Budgets') } |
5 |
BEGIN {use_ok('C4::Budgets') } |
6 |
use C4::Dates; |
6 |
use C4::Dates; |
Lines 16-28
my $active_period;
Link Here
|
16 |
my $mod_status; |
16 |
my $mod_status; |
17 |
my $del_status; |
17 |
my $del_status; |
18 |
ok($bpid=AddBudgetPeriod( |
18 |
ok($bpid=AddBudgetPeriod( |
19 |
{ budget_period_startdate => '2008-01-01' |
19 |
{ budget_period_startdate => '2008-01-01' |
20 |
, budget_period_enddate => '2008-12-31' |
20 |
, budget_period_enddate => '2008-12-31' |
21 |
, budget_description => "MAPERI"}), |
21 |
, budget_period_description => "MAPERI"}), |
22 |
"AddBudgetPeriod with iso dates OK"); |
22 |
"AddBudgetPeriod with iso dates OK"); |
23 |
|
23 |
|
24 |
ok($budgetperiod=GetBudgetPeriod($bpid), |
24 |
ok($budgetperiod=GetBudgetPeriod($bpid), |
25 |
"GetBudgetPeriod($bpid) returned ".Dump($budgetperiod)); |
25 |
"GetBudgetPeriod($bpid) returned ".Dump($budgetperiod)); |
26 |
ok(!GetBudgetPeriod(0) ,"GetBudgetPeriod(0) returned undef : noactive BudgetPeriod"); |
26 |
ok(!GetBudgetPeriod(0) ,"GetBudgetPeriod(0) returned undef : noactive BudgetPeriod"); |
27 |
$$budgetperiod{budget_period_active}=1; |
27 |
$$budgetperiod{budget_period_active}=1; |
28 |
ok($mod_status=ModBudgetPeriod($budgetperiod),"ModBudgetPeriod OK"); |
28 |
ok($mod_status=ModBudgetPeriod($budgetperiod),"ModBudgetPeriod OK"); |
Lines 39-58
if (C4::Context->preference('dateformat') eq "metric"){
Link Here
|
39 |
ok($bpid=AddBudgetPeriod( |
39 |
ok($bpid=AddBudgetPeriod( |
40 |
{ budget_period_startdate =>'01-01-2008' |
40 |
{ budget_period_startdate =>'01-01-2008' |
41 |
, budget_period_enddate =>'31-12-2008' |
41 |
, budget_period_enddate =>'31-12-2008' |
42 |
, budget_description =>"MAPERI"}), |
42 |
, budget_period_description =>"MAPERI"}), |
43 |
"AddBudgetPeriod returned $bpid"); |
43 |
"AddBudgetPeriod returned $bpid"); |
44 |
} elsif (C4::Context->preference('dateformat') eq "us"){ |
44 |
} elsif (C4::Context->preference('dateformat') eq "us"){ |
45 |
ok($bpid=AddBudgetPeriod( |
45 |
ok($bpid=AddBudgetPeriod( |
46 |
{ budget_period_startdate =>'01-01-2008' |
46 |
{ budget_period_startdate =>'01-01-2008' |
47 |
, budget_period_enddate =>'12-31-2008' |
47 |
, budget_period_enddate =>'12-31-2008' |
48 |
, budget_description =>"MAPERI"}), |
48 |
, budget_period_description =>"MAPERI"}), |
49 |
"AddBudgetPeriod returned $bpid"); |
49 |
"AddBudgetPeriod returned $bpid"); |
50 |
} |
50 |
} |
51 |
else{ |
51 |
else{ |
52 |
ok($bpid=AddBudgetPeriod( |
52 |
ok($bpid=AddBudgetPeriod( |
53 |
{budget_period_startdate=>'2008-01-01' |
53 |
{budget_period_startdate=>'2008-01-01' |
54 |
,budget_period_enddate =>'2008-12-31' |
54 |
,budget_period_enddate =>'2008-12-31' |
55 |
,budget_description =>"MAPERI" |
55 |
,budget_period_description =>"MAPERI" |
56 |
}), |
56 |
}), |
57 |
"AddBudgetPeriod returned $bpid"); |
57 |
"AddBudgetPeriod returned $bpid"); |
58 |
|
58 |
|
Lines 102-106
ok(GetBudgets({budget_period_id=>GetBudgetPeriod($bpid)->{budget_period_id}},[{"
Link Here
|
102 |
my $budget_name = GetBudgetName( $budget_id ); |
102 |
my $budget_name = GetBudgetName( $budget_id ); |
103 |
is($budget_name, $budget->{budget_name}, "Test the GetBudgetName routine"); |
103 |
is($budget_name, $budget->{budget_name}, "Test the GetBudgetName routine"); |
104 |
|
104 |
|
|
|
105 |
my $new_bpid; |
106 |
ok($new_bpid = C4::Budgets::DuplicateBudget($bpid, '2012-01-01', '2012-08-01', 'MAPERI COPY'), |
107 |
"Duplicate budget returned $new_bpid"); |
108 |
|
109 |
my $budgetcpyp; |
110 |
ok($budgetcpyp = GetBudgetPeriod($new_bpid) ,"GetBudgetPeriod OK"); |
111 |
|
112 |
#Verify data of the copy |
113 |
is ($budgetcpyp->{'budget_period_startdate'}, '2012-01-01'); |
114 |
is ($budgetcpyp->{'budget_period_enddate'}, '2012-08-01'); |
115 |
is ($budgetcpyp->{'budget_period_description'}, 'MAPERI COPY'); |
116 |
|
117 |
my $budgetscpy; |
118 |
ok($budgetscpy = GetBudgetHierarchy( $new_bpid )); |
119 |
is (scalar(@$budgetscpy), 2, '2 budgets for that budget period : the original and his child'); |
120 |
is (@$budgetscpy[0]->{'budget_code'}, 'ABCD'); |
121 |
is (@$budgetscpy[0]->{'budget_amount'}, '123.132000'); |
122 |
is (@$budgetscpy[0]->{'budget_notes'}, 'This is a note'); |
123 |
is (@$budgetscpy[0]->{'budget_name'}, 'Serials'); |
124 |
|
105 |
ok($del_status=DelBudget($budget_id), |
125 |
ok($del_status=DelBudget($budget_id), |
106 |
"DelBudget returned $del_status"); |
126 |
"DelBudget returned $del_status"); |
107 |
- |
|
|