Module: Workarea::Storefront::GiftCardOrderPricing
- Defined in:
- app/view_models/workarea/storefront/gift_card_order_pricing.rb
Instance Method Summary collapse
- #gift_card ⇒ Object
- #gift_card_amount ⇒ Object
- #gift_card_balance ⇒ Object
- #order_balance ⇒ Object
- #total_after_store_credit ⇒ Object
Instance Method Details
#gift_card ⇒ Object
4 5 6 7 8 9 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 4 def gift_card return unless payment.gift_card.present? @gift_card ||= Workarea::Payment::GiftCard.find_by_token( payment.gift_card.number ) end |
#gift_card_amount ⇒ Object
19 20 21 22 23 24 25 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 19 def gift_card_amount if gift_card_balance > total_after_store_credit total_after_store_credit else gift_card_balance end end |
#gift_card_balance ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 11 def gift_card_balance if gift_card.present? gift_card.balance else 0.to_m end end |
#order_balance ⇒ Object
31 32 33 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 31 def order_balance super - gift_card_amount end |
#total_after_store_credit ⇒ Object
27 28 29 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 27 def total_after_store_credit order.total_price - store_credit_amount end |