Class: Spree::CustomerReturn

Inherits:
Base
  • Object
show all
Defined in:
app/models/spree/customer_return.rb

Instance Method Summary collapse

Methods inherited from Base

page

Methods included from Preferences::Preferable

#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference

Instance Method Details

#completely_decided?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'app/models/spree/customer_return.rb', line 40

def completely_decided?
  !return_items.undecided.exists?
end

#display_pre_tax_totalObject


22
23
24
# File 'app/models/spree/customer_return.rb', line 22

def display_pre_tax_total
  Spree::Money.new(pre_tax_total, { currency: Spree::Config[:currency] })
end

#fully_reimbursed?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'app/models/spree/customer_return.rb', line 36

def fully_reimbursed?
  completely_decided? && return_items.accepted.includes(:reimbursement).all? { |return_item| return_item.reimbursement.try(:reimbursed?) }
end

#orderObject

Temporarily tie a customer_return to one order


27
28
29
30
# File 'app/models/spree/customer_return.rb', line 27

def order
  return nil if return_items.blank?
  return_items.first.inventory_unit.order
end

#order_idObject


32
33
34
# File 'app/models/spree/customer_return.rb', line 32

def order_id
  order.try(:id)
end

#pre_tax_totalObject


18
19
20
# File 'app/models/spree/customer_return.rb', line 18

def pre_tax_total
  return_items.sum(:pre_tax_amount)
end