Class: OrderLineItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/order_line_item.rb

Instance Method Summary collapse

Instance Method Details

#get_total_chargesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/models/order_line_item.rb', line 12

def get_total_charges
  # get all of the charge lines associated with the order_line
  total_hash = Hash.new
  charge_lines.each do |charge|
    cur_money = charge.money
    cur_total = total_hash[cur_money.currency.internal_identifier]
    if (cur_total.nil?)
      cur_total = cur_money.clone
    else
      cur_total.amount = 0 if cur_total.amount.nil?
      cur_total.amount += cur_money.amount if !cur_money.amount.nil?
    end
    total_hash[cur_money.currency.internal_identifier] = cur_total
  end
  return total_hash.values
end