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

(-)a/C4/Budgets.pm (-2 / +2 lines)
Lines 528-535 sub GetBudgetHierarchy { Link Here
528
528
529
    # link child to parent
529
    # link child to parent
530
    my @first_parents;
530
    my @first_parents;
531
    foreach ( sort keys %links ) {
531
    foreach my $budget ( sort { $a->{budget_code} cmp $b->{budget_code} } values %links ) {
532
        my $child = $links{$_};
532
        my $child = $links{$budget->{budget_id}};
533
        if ( $child->{'budget_parent_id'} ) {
533
        if ( $child->{'budget_parent_id'} ) {
534
            my $parent = $links{ $child->{'budget_parent_id'} };
534
            my $parent = $links{ $child->{'budget_parent_id'} };
535
            if ($parent) {
535
            if ($parent) {
(-)a/t/db_dependent/Budgets.t (-10 / +13 lines)
Lines 1-5 Link Here
1
use Modern::Perl;
1
use Modern::Perl;
2
use Test::More tests => 120;
2
use Test::More tests => 122;
3
3
4
BEGIN {
4
BEGIN {
5
    use_ok('C4::Budgets')
5
    use_ok('C4::Budgets')
Lines 232-253 my $budget_id2 = AddBudget( Link Here
232
        budget_amount    => $budget_2_total,
232
        budget_amount    => $budget_2_total,
233
    }
233
    }
234
);
234
);
235
my $budget_id11 = AddBudget(
235
my $budget_id12 = AddBudget(
236
    {
236
    {
237
        budget_code      => 'budget_11',
237
        budget_code      => 'budget_12',
238
        budget_name      => 'budget_11',
238
        budget_name      => 'budget_12',
239
        budget_period_id => $budget_period_id,
239
        budget_period_id => $budget_period_id,
240
        budget_parent_id => $budget_id1,
240
        budget_parent_id => $budget_id1,
241
        budget_amount    => $budget_11_total,
241
        budget_amount    => $budget_12_total,
242
    }
242
    }
243
);
243
);
244
my $budget_id12 = AddBudget(
244
my $budget_id11 = AddBudget(
245
    {
245
    {
246
        budget_code      => 'budget_12',
246
        budget_code      => 'budget_11',
247
        budget_name      => 'budget_12',
247
        budget_name      => 'budget_11',
248
        budget_period_id => $budget_period_id,
248
        budget_period_id => $budget_period_id,
249
        budget_parent_id => $budget_id1,
249
        budget_parent_id => $budget_id1,
250
        budget_amount    => $budget_12_total,
250
        budget_amount    => $budget_11_total,
251
    }
251
    }
252
);
252
);
253
my $budget_id111 = AddBudget(
253
my $budget_id111 = AddBudget(
Lines 431-436 $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( Link Here
431
);
431
);
432
432
433
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
433
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
434
is( $budget_hierarchy->[0]->{children}->[0]->{budget_name}, 'budget_11', 'GetBudgetHierarchy should return budgets ordered by name, first child is budget_11' );
435
is( $budget_hierarchy->[0]->{children}->[1]->{budget_name}, 'budget_12', 'GetBudgetHierarchy should return budgets ordered by name, second child is budget_12' );
436
437
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
434
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
438
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
435
439
436
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
440
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
437
- 

Return to bug 14388