Class: Spree::CustomerReturn

Inherits:
Base
  • Object
show all
Extended by:
DisplayMoney
Defined in:
core/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

Instance Method Details

#amountObject



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

def amount
  return_items.sum(:amount)
end

#completely_decided?Boolean

Returns:

  • (Boolean)


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

def completely_decided?
  !return_items.undecided.exists?
end

#fully_reimbursed?Boolean

Returns:

  • (Boolean)


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

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



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

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

#process_return!Object



55
56
57
# File 'core/app/models/spree/customer_return.rb', line 55

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

#totalObject



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

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

#total_excluding_vatObject Also known as: pre_tax_total



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

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