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

(-)a/C4/Budgets.pm (-21 / +7 lines)
Lines 438-464 sub GetBudgetPeriods { Link Here
438
sub GetBudgetPeriod {
438
sub GetBudgetPeriod {
439
	my ($budget_period_id) = @_;
439
	my ($budget_period_id) = @_;
440
	my $dbh = C4::Context->dbh;
440
	my $dbh = C4::Context->dbh;
441
	## $total = number of records linked to the record that must be deleted
441
	my $sth = $dbh->prepare( qq|
442
	my $total = 0;
442
        SELECT      *
443
	## get information about the record that will be deleted
443
        FROM aqbudgetperiods
444
	my $sth;
444
        WHERE budget_period_id=? |
445
	if ($budget_period_id) {
445
	);
446
		$sth = $dbh->prepare( qq|
446
	$sth->execute($budget_period_id);
447
              SELECT      *
447
	return $sth->fetchrow_hashref;
448
                FROM aqbudgetperiods
449
                WHERE budget_period_id=? |
450
		);
451
		$sth->execute($budget_period_id);
452
	} else {         # ACTIVE BUDGET
453
		$sth = $dbh->prepare(qq|
454
			  SELECT      *
455
                FROM aqbudgetperiods
456
                WHERE budget_period_active=1 |
457
		);
458
		$sth->execute();
459
	}
460
	my $data = $sth->fetchrow_hashref;
461
	return $data;
462
}
448
}
463
449
464
sub DelBudgetPeriod{
450
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 => 146;
3
use Test::More tests => 143;
4
4
5
BEGIN {
5
BEGIN {
6
    use_ok('C4::Budgets')
6
    use_ok('C4::Budgets')
Lines 53-59 $bpid = AddBudgetPeriod({ Link Here
53
    budget_period_enddate => '2008-12-31',
53
    budget_period_enddate => '2008-12-31',
54
});
54
});
55
is( $bpid, undef, 'AddBugetPeriod without start date returns undef' );
55
is( $bpid, undef, 'AddBugetPeriod without start date returns undef' );
56
is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
57
my $budgetperiods = GetBudgetPeriods();
56
my $budgetperiods = GetBudgetPeriods();
58
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
57
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
59
58
Lines 71-78 is( $budgetperiod->{budget_period_startdate}, $my_budgetperiod->{budget_period_s Link Here
71
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'AddBudgetPeriod stores the end date correctly' );
70
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'AddBudgetPeriod stores the end date correctly' );
72
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'AddBudgetPeriod stores the description correctly' );
71
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'AddBudgetPeriod stores the description correctly' );
73
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'AddBudgetPeriod stores active correctly' );
72
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'AddBudgetPeriod stores active correctly' );
74
is( GetBudgetPeriod(0), undef ,'GetBudgetPeriod(0) returned undef : noactive BudgetPeriod' );
75
76
73
77
$my_budgetperiod = {
74
$my_budgetperiod = {
78
    budget_period_startdate   => '2009-01-01',
75
    budget_period_startdate   => '2009-01-01',
Lines 91-98 is( $budgetperiod->{budget_period_startdate}, $my_budgetperiod->{budget_period_s Link Here
91
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'ModBudgetPeriod updates the end date correctly' );
88
is( $budgetperiod->{budget_period_enddate}, $my_budgetperiod->{budget_period_enddate}, 'ModBudgetPeriod updates the end date correctly' );
92
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'ModBudgetPeriod updates the description correctly' );
89
is( $budgetperiod->{budget_period_description}, $my_budgetperiod->{budget_period_description}, 'ModBudgetPeriod updates the description correctly' );
93
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'ModBudgetPeriod upates active correctly' );
90
is( $budgetperiod->{budget_period_active}, $my_budgetperiod->{budget_period_active}, 'ModBudgetPeriod upates active correctly' );
94
isnt( GetBudgetPeriod(0), undef, 'GetBugetPeriods functions correctly' );
95
96
91
97
$budgetperiods = GetBudgetPeriods();
92
$budgetperiods = GetBudgetPeriods();
98
is( @$budgetperiods, 1, 'GetBudgetPeriods returns the correct number of budget periods' );
93
is( @$budgetperiods, 1, 'GetBudgetPeriods returns the correct number of budget periods' );
Lines 106-112 is( DelBudgetPeriod($bpid), 1, 'DelBudgetPeriod returns true' ); Link Here
106
$budgetperiods = GetBudgetPeriods();
101
$budgetperiods = GetBudgetPeriods();
107
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
102
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget periods' );
108
103
109
110
#
104
#
111
# Budget  :
105
# Budget  :
112
#
106
#
113
- 

Return to bug 10577