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 228-249 my $budget_id2 = AddBudget( Link Here
228
        budget_amount    => $budget_2_total,
228
        budget_amount    => $budget_2_total,
229
    }
229
    }
230
);
230
);
231
my $budget_id11 = AddBudget(
231
my $budget_id12 = AddBudget(
232
    {
232
    {
233
        budget_code      => 'budget_11',
233
        budget_code      => 'budget_12',
234
        budget_name      => 'budget_11',
234
        budget_name      => 'budget_12',
235
        budget_period_id => $budget_period_id,
235
        budget_period_id => $budget_period_id,
236
        budget_parent_id => $budget_id1,
236
        budget_parent_id => $budget_id1,
237
        budget_amount    => $budget_11_total,
237
        budget_amount    => $budget_12_total,
238
    }
238
    }
239
);
239
);
240
my $budget_id12 = AddBudget(
240
my $budget_id11 = AddBudget(
241
    {
241
    {
242
        budget_code      => 'budget_12',
242
        budget_code      => 'budget_11',
243
        budget_name      => 'budget_12',
243
        budget_name      => 'budget_11',
244
        budget_period_id => $budget_period_id,
244
        budget_period_id => $budget_period_id,
245
        budget_parent_id => $budget_id1,
245
        budget_parent_id => $budget_id1,
246
        budget_amount    => $budget_12_total,
246
        budget_amount    => $budget_11_total,
247
    }
247
    }
248
);
248
);
249
my $budget_id111 = AddBudget(
249
my $budget_id111 = AddBudget(
Lines 427-432 $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod( Link Here
427
);
427
);
428
428
429
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
429
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
430
is( $budget_hierarchy->[0]->{children}->[0]->{budget_name}, 'budget_11', 'GetBudgetHierarchy should return budgets ordered by name, first child is budget_11' );
431
is( $budget_hierarchy->[0]->{children}->[1]->{budget_name}, 'budget_12', 'GetBudgetHierarchy should return budgets ordered by name, second child is budget_12' );
432
433
$budget_hierarchy        = GetBudgetHierarchy($budget_period_id);
430
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
434
$budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
431
435
432
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
436
is( scalar(@$budget_hierarchy_cloned), scalar(@$budget_hierarchy),
433
- 

Return to bug 14388