Skip to content

Commit

Permalink
Charge only, when it is relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed Nov 18, 2016
1 parent d714d67 commit 4588c62
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/models/chargeback_rate_detail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ class ChargebackRateDetail < ApplicationRecord
attr_accessor :hours_in_interval

def charge(relevant_fields, chargeback_fields_present, metric_rollup_records, hours_in_interval)
if !chargeback_fields_present && fixed?
cost = 0
else
metric_value, cost = metric_and_cost_by(metric_rollup_records, hours_in_interval)
end

result = {}
if (relevant_fields & [metric_keys[0], cost_keys[0]]).present?
if !chargeback_fields_present && fixed?
cost = 0
else
metric_value, cost = metric_and_cost_by(metric_rollup_records, hours_in_interval)
end
metric_keys.each { |field| result[field] = metric_value }
cost_keys.each { |field| result[field] = cost }
end
Expand Down

0 comments on commit 4588c62

Please sign in to comment.