Lines 1-5
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
use Test::More tests => 37; |
2 |
use Test::More tests => 67; |
3 |
|
3 |
|
4 |
BEGIN {use_ok('C4::Budgets') } |
4 |
BEGIN {use_ok('C4::Budgets') } |
5 |
use C4::Biblio; |
5 |
use C4::Biblio; |
Lines 430-443
$budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod(
Link Here
|
430 |
budget_period_id => $budget_period_id, |
430 |
budget_period_id => $budget_period_id, |
431 |
budget_period_startdate => '2014-01-01', |
431 |
budget_period_startdate => '2014-01-01', |
432 |
budget_period_enddate => '2014-12-31', |
432 |
budget_period_enddate => '2014-12-31', |
433 |
reset_all_funds => 1, |
|
|
434 |
} |
433 |
} |
435 |
); |
434 |
); |
436 |
|
435 |
|
437 |
my $report = C4::Budgets::MoveOrders( |
436 |
my $report = C4::Budgets::MoveOrders( |
438 |
{ |
437 |
{ |
439 |
from_budget_period_id => $budget_period_id, |
438 |
from_budget_period_id => $budget_period_id, |
440 |
to_budget_period_id => $budget_period_id_cloned, |
439 |
to_budget_period_id => $budget_period_id_cloned, |
|
|
440 |
move_remaining_unspent => 1, |
441 |
} |
441 |
} |
442 |
); |
442 |
); |
443 |
is( scalar( @$report ), 6 , "MoveOrders has processed 6 funds" ); |
443 |
is( scalar( @$report ), 6 , "MoveOrders has processed 6 funds" ); |
Lines 446-451
my $number_of_orders_moved = 0;
Link Here
|
446 |
$number_of_orders_moved += scalar( @{ $_->{orders_moved} } ) for @$report; |
446 |
$number_of_orders_moved += scalar( @{ $_->{orders_moved} } ) for @$report; |
447 |
is( $number_of_orders_moved, $number_of_orders_to_move, "MoveOrders has moved $number_of_orders_to_move orders" ); |
447 |
is( $number_of_orders_moved, $number_of_orders_to_move, "MoveOrders has moved $number_of_orders_to_move orders" ); |
448 |
|
448 |
|
|
|
449 |
my @new_budget_ids = map { $_->{budget_id} } |
450 |
@{ C4::Budgets::GetBudgetHierarchy($budget_period_id_cloned) }; |
451 |
my @old_budget_ids = map { $_->{budget_id} } |
452 |
@{ C4::Budgets::GetBudgetHierarchy($budget_period_id) }; |
453 |
for my $budget_id ( keys %budgets ) { |
454 |
for my $ordernumber ( @{ $budgets{$budget_id} } ) { |
455 |
my $budget = GetBudgetByOrderNumber($ordernumber); |
456 |
my $is_in_new_budgets = grep /^$budget->{budget_id}$/, @new_budget_ids; |
457 |
my $is_in_old_budgets = grep /^$budget->{budget_id}$/, @old_budget_ids; |
458 |
is( $is_in_new_budgets, 1, "MoveOrders changed the budget_id for order $ordernumber" ); |
459 |
is( $is_in_old_budgets, 0, "MoveOrders changed the budget_id for order $ordernumber" ); |
460 |
} |
461 |
} |
462 |
|
463 |
|
464 |
# MoveOrders with param move_remaining_unspent |
465 |
my @new_budgets = @{ C4::Budgets::GetBudgetHierarchy($budget_period_id_cloned) }; |
466 |
my @old_budgets = @{ C4::Budgets::GetBudgetHierarchy($budget_period_id) }; |
467 |
|
468 |
for my $new_budget ( @new_budgets ) { |
469 |
my ( $old_budget ) = map { $_->{budget_code} eq $new_budget->{budget_code} ? $_ : () } @old_budgets; |
470 |
my $new_budget_amount_should_be = $old_budget->{budget_amount} * 2 - $old_budget->{total_spent}; |
471 |
is( $new_budget->{budget_amount} + 0, $new_budget_amount_should_be, "MoveOrders updated the budget amount with the previous unspent budget (for budget $new_budget->{budget_code})" ); |
472 |
} |
473 |
|
449 |
sub _get_dependencies { |
474 |
sub _get_dependencies { |
450 |
my ($budget_hierarchy) = @_; |
475 |
my ($budget_hierarchy) = @_; |
451 |
my $graph; |
476 |
my $graph; |
452 |
- |
|
|