Module: Workarea::Storefront::GiftCardOrderPricing

Extended by:
ActiveSupport::Concern
Defined in:
app/view_models/workarea/storefront/gift_card_order_pricing.rb

Instance Method Summary collapse

Instance Method Details

#advance_payment_amountObject



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_cardObject



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

Returns:

  • (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_amountObject



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_balanceObject



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_cardsObject



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_cardsObject



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