Lines 1005-1010
sub ConvertCurrency {
Link Here
|
1005 |
return ( $price / $cur ); |
1005 |
return ( $price / $cur ); |
1006 |
} |
1006 |
} |
1007 |
|
1007 |
|
|
|
1008 |
sub _round { |
1009 |
my ($value, $increment) = @_; |
1010 |
|
1011 |
if ($increment && $increment != 0) { |
1012 |
$value = int($value / $increment) * $increment; |
1013 |
} |
1014 |
|
1015 |
return $value; |
1016 |
} |
1008 |
|
1017 |
|
1009 |
=head2 CloneBudgetPeriod |
1018 |
=head2 CloneBudgetPeriod |
1010 |
|
1019 |
|
Lines 1031-1036
sub CloneBudgetPeriod {
Link Here
|
1031 |
my $budget_period_startdate = $params->{budget_period_startdate}; |
1040 |
my $budget_period_startdate = $params->{budget_period_startdate}; |
1032 |
my $budget_period_enddate = $params->{budget_period_enddate}; |
1041 |
my $budget_period_enddate = $params->{budget_period_enddate}; |
1033 |
my $budget_period_description = $params->{budget_period_description}; |
1042 |
my $budget_period_description = $params->{budget_period_description}; |
|
|
1043 |
my $amount_change_percentage = $params->{amount_change_percentage}; |
1044 |
my $amount_change_round_increment = $params->{amount_change_round_increment}; |
1034 |
my $mark_original_budget_as_inactive = |
1045 |
my $mark_original_budget_as_inactive = |
1035 |
$params->{mark_original_budget_as_inactive} || 0; |
1046 |
$params->{mark_original_budget_as_inactive} || 0; |
1036 |
my $reset_all_budgets = $params->{reset_all_budgets} || 0; |
1047 |
my $reset_all_budgets = $params->{reset_all_budgets} || 0; |
Lines 1042-1047
sub CloneBudgetPeriod {
Link Here
|
1042 |
$budget_period->{budget_period_description} = $budget_period_description; |
1053 |
$budget_period->{budget_period_description} = $budget_period_description; |
1043 |
# The new budget (budget_period) should be active by default |
1054 |
# The new budget (budget_period) should be active by default |
1044 |
$budget_period->{budget_period_active} = 1; |
1055 |
$budget_period->{budget_period_active} = 1; |
|
|
1056 |
|
1057 |
if ($amount_change_percentage) { |
1058 |
my $total = $budget_period->{budget_period_total}; |
1059 |
$total += $total * $amount_change_percentage / 100; |
1060 |
$total = _round($total, $amount_change_round_increment); |
1061 |
$budget_period->{budget_period_total} = $total; |
1062 |
} |
1063 |
|
1045 |
my $original_budget_period_id = $budget_period->{budget_period_id}; |
1064 |
my $original_budget_period_id = $budget_period->{budget_period_id}; |
1046 |
delete $budget_period->{budget_period_id}; |
1065 |
delete $budget_period->{budget_period_id}; |
1047 |
my $new_budget_period_id = AddBudgetPeriod( $budget_period ); |
1066 |
my $new_budget_period_id = AddBudgetPeriod( $budget_period ); |
Lines 1069-1074
sub CloneBudgetPeriod {
Link Here
|
1069 |
$budget->{budget_amount} = 0; |
1088 |
$budget->{budget_amount} = 0; |
1070 |
ModBudget( $budget ); |
1089 |
ModBudget( $budget ); |
1071 |
} |
1090 |
} |
|
|
1091 |
} elsif ($amount_change_percentage) { |
1092 |
my $budgets = GetBudgets({ budget_period_id => $new_budget_period_id }); |
1093 |
for my $budget ( @$budgets ) { |
1094 |
my $amount = $budget->{budget_amount}; |
1095 |
$amount += $amount * $amount_change_percentage / 100; |
1096 |
$amount = _round($amount, $amount_change_round_increment); |
1097 |
$budget->{budget_amount} = $amount; |
1098 |
ModBudget( $budget ); |
1099 |
} |
1072 |
} |
1100 |
} |
1073 |
|
1101 |
|
1074 |
return $new_budget_period_id; |
1102 |
return $new_budget_period_id; |