Class: Effective::CartItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::CartItem
- Defined in:
- app/models/effective/cart_item.rb
Instance Method Summary collapse
Instance Method Details
#price ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/models/effective/cart_item.rb', line 19 def price if (purchasable.price || 0).kind_of?(Integer) purchasable.price || 0 else ActiveSupport::Deprecation.warn('price is a non-integer. It should be an Integer representing the number of cents. Continuing with (price * 100.0).round(0).to_i conversion') unless EffectiveOrders.silence_deprecation_warnings (purchasable.price * 100.0).round(0).to_i rescue 0 end end |
#subtotal ⇒ Object
28 29 30 |
# File 'app/models/effective/cart_item.rb', line 28 def subtotal price * quantity end |
#tax ⇒ Object
32 33 34 |
# File 'app/models/effective/cart_item.rb', line 32 def tax tax_exempt ? 0 : (subtotal * tax_rate).round(0).to_i end |
#total ⇒ Object
36 37 38 |
# File 'app/models/effective/cart_item.rb', line 36 def total subtotal + tax end |