sub GetBudgetPeriod {
my ($budget_period_id) = @_;
my $dbh = C4::Context->dbh;
- ## $total = number of records linked to the record that must be deleted
- my $total = 0;
- ## get information about the record that will be deleted
- my $sth;
- if ($budget_period_id) {
- $sth = $dbh->prepare( qq|
- SELECT *
- FROM aqbudgetperiods
- WHERE budget_period_id=? |
- );
- $sth->execute($budget_period_id);
- } else { # ACTIVE BUDGET
- $sth = $dbh->prepare(qq|
- SELECT *
- FROM aqbudgetperiods
- WHERE budget_period_active=1 |
- );
- $sth->execute();
- }
- my $data = $sth->fetchrow_hashref;
- return $data;
+ my $sth = $dbh->prepare( qq|
+ SELECT *
+ FROM aqbudgetperiods
+ WHERE budget_period_id=? |
+ );
+ $sth->execute($budget_period_id);
+ return $sth->fetchrow_hashref;
}
sub DelBudgetPeriod{
#!/usr/bin/perl
use Modern::Perl;
-use Test::More tests => 147;
+use Test::More tests => 144;
BEGIN {
use_ok('C4::Budgets')
budget_period_enddate => '2008-12-31',
});
is( $bpid, undef, 'AddBugetPeriod without start date returns undef' );
-is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
my $budgetperiods = GetBudgetPeriods();
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'AddBudgetPeriod stores the end date correctly' );
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'AddBudgetPeriod stores the description correctly' );
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'AddBudgetPeriod stores active correctly' );
-is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
-
$my_budgetperiod = {
budget_period_startdate => '2009-01-01',
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'ModBudgetPeriod updates the end date correctly' );
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'ModBudgetPeriod updates the description correctly' );
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'ModBudgetPeriod upates active correctly' );
-isnt( GetBudgetPeriod(0), undef, 'GetBugetPeriods functions correctly' );
-
$budgetperiods = GetBudgetPeriods();
is( @$budgetperiods, 1, 'GetBudgetPeriods returns the correct number of budget periods' );
$budgetperiods = GetBudgetPeriods();
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
-
#
# Budget :
#