Bug 7498 - Cloning a budget, enable change of description
Patch sponsored by the CCSR ( http://www.ccsr.qc.ca ) This new patch builds on the work of Bug 12164 by allowing the user to enter a new name (budget_period_description) for the cloned budget. A test was added to t/db_dependent/Budgets.t. Sponsored-by: CCSR Signed-off-by: Paola Rossi <paola.rossi@cineca.it> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Works as described, passes tests and QA script. Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com> Edit: added the sponsored-by line.
This commit is contained in:
parent
c14d91fcd0
commit
c6716d3e22
|
|
@ -1029,18 +1029,20 @@ amounts will be reset.
|
|||
=cut
|
||||
|
||||
sub CloneBudgetPeriod {
|
||||
my ($params) = @_;
|
||||
my $budget_period_id = $params->{budget_period_id};
|
||||
my $budget_period_startdate = $params->{budget_period_startdate};
|
||||
my $budget_period_enddate = $params->{budget_period_enddate};
|
||||
my ($params) = @_;
|
||||
my $budget_period_id = $params->{budget_period_id};
|
||||
my $budget_period_startdate = $params->{budget_period_startdate};
|
||||
my $budget_period_enddate = $params->{budget_period_enddate};
|
||||
my $budget_period_description = $params->{budget_period_description};
|
||||
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);
|
||||
|
||||
$budget_period->{budget_period_startdate} = $budget_period_startdate;
|
||||
$budget_period->{budget_period_enddate} = $budget_period_enddate;
|
||||
$budget_period->{budget_period_startdate} = $budget_period_startdate;
|
||||
$budget_period->{budget_period_enddate} = $budget_period_enddate;
|
||||
$budget_period->{budget_period_description} = $budget_period_description;
|
||||
# The new budget (budget_period) should be active by default
|
||||
$budget_period->{budget_period_active} = 1;
|
||||
my $original_budget_period_id = $budget_period->{budget_period_id};
|
||||
|
|
|
|||
|
|
@ -177,9 +177,11 @@ elsif ( $op eq 'delete_confirmed' ) {
|
|||
|
||||
# display the form for duplicating
|
||||
elsif ( $op eq 'duplicate_form'){
|
||||
my $budgetperiod = GetBudgetPeriod($budget_period_id, $input);
|
||||
$template->param(
|
||||
'duplicate_form' => '1',
|
||||
'budget_period_id' => $budget_period_id,
|
||||
'budgetperiod' => $budgetperiod,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -189,6 +191,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 $budget_period_description = $input->param('budget_period_description');
|
||||
my $mark_original_budget_as_inactive = $input->param('mark_original_budget_as_inactive');
|
||||
my $reset_all_budgets = $input->param('reset_all_budgets');
|
||||
|
||||
|
|
@ -197,6 +200,7 @@ elsif ( $op eq 'duplicate_budget' ){
|
|||
budget_period_id => $budget_period_id,
|
||||
budget_period_startdate => $budget_period_startdate,
|
||||
budget_period_enddate => $budget_period_enddate,
|
||||
budget_period_description => $budget_period_description,
|
||||
mark_original_budget_as_inactive => $mark_original_budget_as_inactive,
|
||||
reset_all_budgets => $reset_all_budgets,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
if( f.budget_period_startdate > f.budget_period_enddate ) {
|
||||
_alertString += "\n- " + _("Start date must be before end date");
|
||||
}
|
||||
if (!(isNotNull(f.budget_period_description,1))){
|
||||
_alertString += "\n- " + _("Budget description missing");
|
||||
}
|
||||
|
||||
if(_alertString.length==0){
|
||||
f.submit();
|
||||
|
|
@ -263,6 +266,11 @@
|
|||
<div class="hint">[% INCLUDE 'date-format.inc' %]</div>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label class="required" for="budget_period_description">Description</label>
|
||||
<input type="text" id="budget_period_description" name="budget_period_description" value="[% budgetperiod.budget_period_description %]" />
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<label for="mark_as_inactive">Mark the original budget as inactive</label>
|
||||
<input type="checkbox" id="mark_as_inactive" name="mark_original_budget_as_inactive" />
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use Modern::Perl;
|
||||
use Test::More tests => 107;
|
||||
use Test::More tests => 108;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Budgets')
|
||||
|
|
@ -367,9 +367,13 @@ my $budget_period_id_cloned = C4::Budgets::CloneBudgetPeriod(
|
|||
budget_period_id => $budget_period_id,
|
||||
budget_period_startdate => '2014-01-01',
|
||||
budget_period_enddate => '2014-12-31',
|
||||
budget_period_description => 'Budget Period Cloned',
|
||||
}
|
||||
);
|
||||
|
||||
my $budget_period_cloned = C4::Budgets::GetBudgetPeriod($budget_period_id_cloned);
|
||||
is($budget_period_cloned->{budget_period_description}, 'Budget Period Cloned', 'Cloned budget\'s description is updated.');
|
||||
|
||||
my $budget_hierarchy = GetBudgetHierarchy($budget_period_id);
|
||||
my $budget_hierarchy_cloned = GetBudgetHierarchy($budget_period_id_cloned);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue