Class: Spree::CustomerReturn

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

Instance Method Summary collapse

Methods included from DisplayMoney

money_methods

Methods inherited from Base

#initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

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

Instance Method Details

#amountObject



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

def amount
  return_items.sum(:amount)
end

#completely_decided?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'app/models/spree/customer_return.rb', line 46

def completely_decided?
  !return_items.undecided.exists?
end

#fully_reimbursed?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/spree/customer_return.rb', line 42

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



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

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

#pre_tax_totalObject



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

def pre_tax_total
  return_items.map(&:pre_tax_amount).sum
end

#process_return!Object



50
51
52
# File 'app/models/spree/customer_return.rb', line 50

def process_return!
  order.return! if order.all_inventory_units_returned?
end

#totalObject



24
25
26
# File 'app/models/spree/customer_return.rb', line 24

def total
  return_items.map(&:total).sum
end