diff --git a/C4/Budgets.pm b/C4/Budgets.pm index 409548823d..aed5e82db4 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -1013,15 +1013,19 @@ sub ConvertCurrency { my $new_budget_period_id = CloneBudgetPeriod({ budget_period_id => $budget_period_id, - budget_period_startdate => $budget_period_startdate; - budget_period_enddate => $budget_period_enddate; - mark_original_budget_as_inactive => 1 + budget_period_startdate => $budget_period_startdate, + budget_period_enddate => $budget_period_enddate, + mark_original_budget_as_inactive => 1n + reset_all_budgets => 1, }); Clone a budget period with all budgets. If the mark_origin_budget_as_inactive is set (0 by default), the original budget will be marked as inactive. +If the reset_all_budgets is set (0 by default), all budget (fund) +amounts will be reset. + =cut sub CloneBudgetPeriod { @@ -1031,6 +1035,7 @@ sub CloneBudgetPeriod { my $budget_period_enddate = $params->{budget_period_enddate}; my $mark_original_budget_as_inactive = $params->{mark_original_budget_as_inactive} || 0; + my $reset_all_budgets = $params->{reset_all_budgets} || 0; my $budget_period = GetBudgetPeriod($budget_period_id); @@ -1057,6 +1062,14 @@ sub CloneBudgetPeriod { ); } + if ( $reset_all_budgets ) { + my $budgets = GetBudgets({ budget_period_id => $new_budget_period_id }); + for my $budget ( @$budgets ) { + $budget->{budget_amount} = 0; + ModBudget( $budget ); + } + } + return $new_budget_period_id; } diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index a256b15599..2d1376ebc9 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -190,6 +190,7 @@ elsif ( $op eq 'duplicate_budget' ){ my $budget_period_startdate = dt_from_string $input->param('budget_period_startdate'); my $budget_period_enddate = dt_from_string $input->param('budget_period_enddate'); my $mark_original_budget_as_inactive = $input->param('mark_original_budget_as_inactive'); + my $reset_all_budgets = $input->param('reset_all_budgets'); my $new_budget_period_id = C4::Budgets::CloneBudgetPeriod( { @@ -197,6 +198,7 @@ elsif ( $op eq 'duplicate_budget' ){ budget_period_startdate => $budget_period_startdate, budget_period_enddate => $budget_period_enddate, mark_original_budget_as_inactive => $mark_original_budget_as_inactive, + reset_all_budgets => $reset_all_budgets, } ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index 0f4bca67e9..6dc9a4dfdb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -190,6 +190,11 @@ +