Lines 985-990
sub ConvertCurrency {
Link Here
|
985 |
return ( $price / $cur ); |
985 |
return ( $price / $cur ); |
986 |
} |
986 |
} |
987 |
|
987 |
|
|
|
988 |
sub _round { |
989 |
my ($value, $increment) = @_; |
990 |
|
991 |
if ($increment && $increment != 0) { |
992 |
$value = int($value / $increment) * $increment; |
993 |
} |
994 |
|
995 |
return $value; |
996 |
} |
988 |
|
997 |
|
989 |
=head2 CloneBudgetPeriod |
998 |
=head2 CloneBudgetPeriod |
990 |
|
999 |
|
Lines 1011-1016
sub CloneBudgetPeriod {
Link Here
|
1011 |
my $budget_period_startdate = $params->{budget_period_startdate}; |
1020 |
my $budget_period_startdate = $params->{budget_period_startdate}; |
1012 |
my $budget_period_enddate = $params->{budget_period_enddate}; |
1021 |
my $budget_period_enddate = $params->{budget_period_enddate}; |
1013 |
my $budget_period_description = $params->{budget_period_description}; |
1022 |
my $budget_period_description = $params->{budget_period_description}; |
|
|
1023 |
my $amount_change_percentage = $params->{amount_change_percentage}; |
1024 |
my $amount_change_round_increment = $params->{amount_change_round_increment}; |
1014 |
my $mark_original_budget_as_inactive = |
1025 |
my $mark_original_budget_as_inactive = |
1015 |
$params->{mark_original_budget_as_inactive} || 0; |
1026 |
$params->{mark_original_budget_as_inactive} || 0; |
1016 |
my $reset_all_budgets = $params->{reset_all_budgets} || 0; |
1027 |
my $reset_all_budgets = $params->{reset_all_budgets} || 0; |
Lines 1022-1027
sub CloneBudgetPeriod {
Link Here
|
1022 |
$budget_period->{budget_period_description} = $budget_period_description; |
1033 |
$budget_period->{budget_period_description} = $budget_period_description; |
1023 |
# The new budget (budget_period) should be active by default |
1034 |
# The new budget (budget_period) should be active by default |
1024 |
$budget_period->{budget_period_active} = 1; |
1035 |
$budget_period->{budget_period_active} = 1; |
|
|
1036 |
|
1037 |
if ($amount_change_percentage) { |
1038 |
my $total = $budget_period->{budget_period_total}; |
1039 |
$total += $total * $amount_change_percentage / 100; |
1040 |
$total = _round($total, $amount_change_round_increment); |
1041 |
$budget_period->{budget_period_total} = $total; |
1042 |
} |
1043 |
|
1025 |
my $original_budget_period_id = $budget_period->{budget_period_id}; |
1044 |
my $original_budget_period_id = $budget_period->{budget_period_id}; |
1026 |
delete $budget_period->{budget_period_id}; |
1045 |
delete $budget_period->{budget_period_id}; |
1027 |
my $new_budget_period_id = AddBudgetPeriod( $budget_period ); |
1046 |
my $new_budget_period_id = AddBudgetPeriod( $budget_period ); |
Lines 1049-1054
sub CloneBudgetPeriod {
Link Here
|
1049 |
$budget->{budget_amount} = 0; |
1068 |
$budget->{budget_amount} = 0; |
1050 |
ModBudget( $budget ); |
1069 |
ModBudget( $budget ); |
1051 |
} |
1070 |
} |
|
|
1071 |
} elsif ($amount_change_percentage) { |
1072 |
my $budgets = GetBudgets({ budget_period_id => $new_budget_period_id }); |
1073 |
for my $budget ( @$budgets ) { |
1074 |
my $amount = $budget->{budget_amount}; |
1075 |
$amount += $amount * $amount_change_percentage / 100; |
1076 |
$amount = _round($amount, $amount_change_round_increment); |
1077 |
$budget->{budget_amount} = $amount; |
1078 |
ModBudget( $budget ); |
1079 |
} |
1052 |
} |
1080 |
} |
1053 |
|
1081 |
|
1054 |
return $new_budget_period_id; |
1082 |
return $new_budget_period_id; |