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

display_includes, #initialize_preference_defaults, page, preference

Methods included from Preferences::Preferable

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

Instance Method Details

#amountObject



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

def amount
  return_items.sum(:amount)
end

#completely_decided?Boolean

Returns:

  • (Boolean)


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

def completely_decided?
  !return_items.undecided.exists?
end

#fully_reimbursed?Boolean

Returns:

  • (Boolean)


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

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



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

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

#process_return!Object



53
54
55
# File 'app/models/spree/customer_return.rb', line 53

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

#totalObject



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

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

#total_excluding_vatObject Also known as: pre_tax_total



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

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