Slide 24
Slide 24 text
Taxes
class
LineItem < ActiveRecord::Base
def
self.for_product_variant(product_variant_id, address = nil)
pv
=
ProductVariant.find(product_variant_id,
:include
=>
[
:variant,
:product
])
rescue
nil
return
false
if
pv.nil?
||
!pv.can_order?
self.new(:product_variant
=>
pv,
:price
=>
pv.price,
:cost
=>
pv.cost,
:quantity
=>
1,
:weight
=>
pv.weight.to_f,
:tax
=>
Tax.on_product(pv.product,
pv.price,
address))
end
end