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

(-)a/C4/Budgets.pm (-21 / +7 lines)
Lines 442-468 sub GetBudgetPeriods { Link Here
442
sub GetBudgetPeriod {
442
sub GetBudgetPeriod {
443
	my ($budget_period_id) = @_;
443
	my ($budget_period_id) = @_;
444
	my $dbh = C4::Context->dbh;
444
	my $dbh = C4::Context->dbh;
445
	## $total = number of records linked to the record that must be deleted
445
	my $sth = $dbh->prepare( qq|
446
	my $total = 0;
446
        SELECT      *
447
	## get information about the record that will be deleted
447
        FROM aqbudgetperiods
448
	my $sth;
448
        WHERE budget_period_id=? |
449
	if ($budget_period_id) {
449
	);
450
		$sth = $dbh->prepare( qq|
450
	$sth->execute($budget_period_id);
451
              SELECT      *
451
	return $sth->fetchrow_hashref;
452
                FROM aqbudgetperiods
453
                WHERE budget_period_id=? |
454
		);
455
		$sth->execute($budget_period_id);
456
	} else {         # ACTIVE BUDGET
457
		$sth = $dbh->prepare(qq|
458
			  SELECT      *
459
                FROM aqbudgetperiods
460
                WHERE budget_period_active=1 |
461
		);
462
		$sth->execute();
463
	}
464
	my $data = $sth->fetchrow_hashref;
465
	return $data;
466
}
452
}
467
453
468
sub DelBudgetPeriod{
454
sub DelBudgetPeriod{
(-)a/t/db_dependent/Budgets.t (-8 / +1 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 => 147;
3
use Test::More tests => 144;
4
4
5
BEGIN {
5
BEGIN {
6
    use_ok('C4::Budgets')
6
    use_ok('C4::Budgets')
Lines 58-64 $bpid = AddBudgetPeriod({ Link Here
58
    budget_period_enddate => '2008-12-31',
58
    budget_period_enddate => '2008-12-31',
59
});
59
});
60
is( $bpid, undef, 'AddBugetPeriod without start date returns undef' );
60
is( $bpid, undef, 'AddBugetPeriod without start date returns undef' );
61
is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
62
my $budgetperiods = GetBudgetPeriods();
61
my $budgetperiods = GetBudgetPeriods();
63
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
62
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
64
63
Lines 76-83 is( $budgetperiod->{budget_period_startdate}, $my_budgetperiod->{budget_period_s Link Here
76
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'AddBudgetPeriod stores the end date correctly' );
75
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'AddBudgetPeriod stores the end date correctly' );
77
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'AddBudgetPeriod stores the description correctly' );
76
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'AddBudgetPeriod stores the description correctly' );
78
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'AddBudgetPeriod stores active correctly' );
77
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'AddBudgetPeriod stores active correctly' );
79
is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
80
81
78
82
$my_budgetperiod = {
79
$my_budgetperiod = {
83
    budget_period_startdate   => '2009-01-01',
80
    budget_period_startdate   => '2009-01-01',
Lines 96-103 is( $budgetperiod->{budget_period_startdate}, $my_budgetperiod->{budget_period_s Link Here
96
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'ModBudgetPeriod updates the end date correctly' );
93
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'ModBudgetPeriod updates the end date correctly' );
97
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'ModBudgetPeriod updates the description correctly' );
94
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'ModBudgetPeriod updates the description correctly' );
98
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'ModBudgetPeriod upates active correctly' );
95
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'ModBudgetPeriod upates active correctly' );
99
isnt( GetBudgetPeriod(0), undef, 'GetBugetPeriods functions correctly' );
100
101
96
102
$budgetperiods = GetBudgetPeriods();
97
$budgetperiods = GetBudgetPeriods();
103
is( @$budgetperiods, 1, 'GetBudgetPeriods returns the correct number of budget periods' );
98
is( @$budgetperiods, 1, 'GetBudgetPeriods returns the correct number of budget periods' );
Lines 111-117 is( DelBudgetPeriod($bpid), 1, 'DelBudgetPeriod returns true' ); Link Here
111
$budgetperiods = GetBudgetPeriods();
106
$budgetperiods = GetBudgetPeriods();
112
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
107
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
113
108
114
115
#
109
#
116
# Budget  :
110
# Budget  :
117
#
111
#
118
- 

Return to bug 10577