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

(-)a/C4/Budgets.pm (-2 / +2 lines)
Lines 529-536 sub GetBudgetHierarchy { Link Here
529
529
530
    # link child to parent
530
    # link child to parent
531
    my @first_parents;
531
    my @first_parents;
532
    foreach ( sort keys %links ) {
532
    foreach my $budget ( sort { $a->{budget_code} cmp $b->{budget_code} } values %links ) {
533
        my $child = $links{$_};
533
        my $child = $links{$budget->{budget_id}};
534
        if ( $child->{'budget_parent_id'} ) {
534
        if ( $child->{'budget_parent_id'} ) {
535
            my $parent = $links{ $child->{'budget_parent_id'} };
535
            my $parent = $links{ $child->{'budget_parent_id'} };
536
            if ($parent) {
536
            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 229-250 my $budget_id2 = AddBudget( Link Here
229
        budget_amount    => $budget_2_total,
229
        budget_amount    => $budget_2_total,
230
    }
230
    }
231
);
231
);
232
my $budget_id11 = AddBudget(
232
my $budget_id12 = AddBudget(
233
    {
233
    {
234
        budget_code      => 'budget_11',
234
        budget_code      => 'budget_12',
235
        budget_name      => 'budget_11',
235
        budget_name      => 'budget_12',
236
        budget_period_id => $budget_period_id,
236
        budget_period_id => $budget_period_id,
237
        budget_parent_id => $budget_id1,
237
        budget_parent_id => $budget_id1,
238
        budget_amount    => $budget_11_total,
238
        budget_amount    => $budget_12_total,
239
    }
239
    }
240
);
240
);
241
my $budget_id12 = AddBudget(
241
my $budget_id11 = AddBudget(
242
    {
242
    {
243
        budget_code      => 'budget_12',
243
        budget_code      => 'budget_11',
244
        budget_name      => 'budget_12',
244
        budget_name      => 'budget_11',
245
        budget_period_id => $budget_period_id,
245
        budget_period_id => $budget_period_id,
246
        budget_parent_id => $budget_id1,
246
        budget_parent_id => $budget_id1,
247
        budget_amount    => $budget_12_total,
247
        budget_amount    => $budget_11_total,
248
    }
248
    }
249
);
249
);
250
my $budget_id111 = AddBudget(
250
my $budget_id111 = AddBudget(
Lines 428-433 $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( Link Here
428
);
428
);
429
429
430
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
430
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
431
is( $budget_hierarchy->[0]->{children}->[0]->{budget_name}, 'budget_11', 'GetBudgetHierarchy should return budgets ordered by name, first child is budget_11' );
432
is( $budget_hierarchy->[0]->{children}->[1]->{budget_name}, 'budget_12', 'GetBudgetHierarchy should return budgets ordered by name, second child is budget_12' );
433
434
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
431
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
435
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
432
436
433
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
437
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
434
- 

Return to bug 14388