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

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

Instance Method Details

- (Object) amount



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

def amount
  return_items.sum(:amount)
end

- (Boolean) completely_decided?

Returns:

  • (Boolean)


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

def completely_decided?
  !return_items.undecided.exists?
end

- (Boolean) fully_reimbursed?

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

- (Object) order

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

- (Object) pre_tax_total



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

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

- (Object) process_return!



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

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

- (Object) total



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

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