Module: Workarea::Storefront::GiftCardOrderPricing
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/view_models/workarea/storefront/gift_card_order_pricing.rb
Instance Method Summary collapse
- #advance_payment_amount ⇒ Object
- #failed_gift_card ⇒ Object
- #gift_card? ⇒ Boolean
- #gift_card_amount ⇒ Object
- #gift_card_balance ⇒ Object
- #gift_cards ⇒ Object
- #total_before_gift_cards ⇒ Object
Instance Method Details
#advance_payment_amount ⇒ Object
26 27 28 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 26 def advance_payment_amount super + gift_card_amount end |
#failed_gift_card ⇒ Object
30 31 32 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 30 def failed_gift_card @failed_gift_card ||= payment.gift_cards.reject(&:persisted?).first end |
#gift_card? ⇒ Boolean
10 11 12 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 10 def gift_card? gift_cards.present? end |
#gift_card_amount ⇒ Object
14 15 16 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 14 def gift_card_amount gift_cards.sum(0.to_m, &:amount) end |
#gift_card_balance ⇒ Object
18 19 20 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 18 def gift_card_balance gift_cards.sum(0.to_m, &:balance) end |
#gift_cards ⇒ Object
6 7 8 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 6 def gift_cards @gift_cards ||= payment.gift_cards.select(&:persisted?) end |
#total_before_gift_cards ⇒ Object
22 23 24 |
# File 'app/view_models/workarea/storefront/gift_card_order_pricing.rb', line 22 def total_before_gift_cards order.total_price - advance_payment_amount + gift_card_amount end |