Class: MerchantSidekick::LineItem

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/merchant_sidekick/line_item.rb

Instance Method Summary collapse

Instance Method Details

#amountObject Also known as: net_total

There used to be a money :amount declration. When we added taxable line items, we assume that amount will refer to the net_amount (net_cents)



37
38
39
# File 'lib/merchant_sidekick/line_item.rb', line 37

def amount
  self.net_amount
end

#amount=(net_money_amount) ⇒ Object Also known as: net_total=

Amount amounts to the net, for compatibility reasons



43
44
45
# File 'lib/merchant_sidekick/line_item.rb', line 43

def amount=(net_money_amount)
  self.net_amount = net_money_amount
end

#evaluateObject

calculates the amounts, like after an address change in the order and tries to save the line_item unless locked TODO find a better way to determine if the line item can still be updated



63
64
65
66
# File 'lib/merchant_sidekick/line_item.rb', line 63

def evaluate
  calculate(self.sellable)
  save(false) unless new_record?
end

#sellable_with_price=(a_sellable) ⇒ Object

set #amount when adding sellable. This method is aliased to sellable=.



28
29
30
31
# File 'lib/merchant_sidekick/line_item.rb', line 28

def sellable_with_price=(a_sellable)
  calculate(a_sellable)
  self.sellable_without_price = a_sellable
end

#taxObject Also known as: tax_total

short for tax_amount



55
56
57
# File 'lib/merchant_sidekick/line_item.rb', line 55

def tax
  self.tax_amount
end

#totalObject Also known as: gross_total

shorter for gross_amount



49
50
51
# File 'lib/merchant_sidekick/line_item.rb', line 49

def total
  self.gross_amount
end