diff --git a/app/models/chargeback.rb b/app/models/chargeback.rb index d1bfacc1fd7..6894b1a413a 100644 --- a/app/models/chargeback.rb +++ b/app/models/chargeback.rb @@ -144,9 +144,7 @@ def calculate_costs(metric_rollup_records, rates, hours_in_interval) if !chargeback_fields_present && r.fixed? cost = 0 else - r.hours_in_interval = hours_in_interval - metric_value = r.metric_value_by(metric_rollup_records) - cost = r.hourly_cost(metric_value) * hours_in_interval + metric_value, cost = r.metric_and_cost_by(metric_rollup_records, hours_in_interval) end accumulate_metrics_and_costs_per_rate(r.rate_name, r.group, metric_value, cost) diff --git a/app/models/chargeback_rate_detail.rb b/app/models/chargeback_rate_detail.rb index ac99375788e..0a817cd7140 100644 --- a/app/models/chargeback_rate_detail.rb +++ b/app/models/chargeback_rate_detail.rb @@ -210,6 +210,12 @@ def contiguous_tiers? !error end + def metric_and_cost_by(metric_rollup_records, hours_in_interval) + @hours_in_interval = hours_in_interval + metric_value = metric_value_by(metric_rollup_records) + [metric_value, hourly_cost(metric_value) * hours_in_interval] + end + private def first_tier?(tier,tiers)