Module: Workarea::Storefront::OrderPricing

Included in:
CartViewModel, Checkout::PaymentViewModel, Checkout::SummaryViewModel, OrderViewModel
Defined in:
app/view_models/workarea/storefront/order_pricing.rb

Instance Method Summary collapse

Instance Method Details

#advance_payment_amountMoney

The total amount of payment the customer would perceive as prepaid - i.e. would be deducted from the total order balance. Examples of these types of payments would be store credit and gift cards.

Returns:

  • (Money)


32
33
34
# File 'app/view_models/workarea/storefront/order_pricing.rb', line 32

def advance_payment_amount
  store_credit_amount
end

#order_balanceObject



22
23
24
# File 'app/view_models/workarea/storefront/order_pricing.rb', line 22

def order_balance
  order.total_price - advance_payment_amount
end

#store_credit?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/view_models/workarea/storefront/order_pricing.rb', line 10

def store_credit?
  store_credit_amount > 0
end

#store_credit_amountObject



14
15
16
17
18
19
20
# File 'app/view_models/workarea/storefront/order_pricing.rb', line 14

def store_credit_amount
  if store_credit_balance > order.total_price
    order.total_price
  else
    store_credit_balance
  end
end

#total_adjustmentsObject



6
7
8
# File 'app/view_models/workarea/storefront/order_pricing.rb', line 6

def total_adjustments
  @total_adjustments ||= price_adjustments.reduce_by_description('order')
end