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

Methods included from Spree::Core::Permalinks

#generate_permalink, #save_permalink

Instance Method Details

#amountObject



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

def amount
  return_items.sum(:amount)
end

#completely_decided?Boolean

Returns:

  • (Boolean)


51
52
53
# File '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 '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



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

def order
  return nil if return_items.blank?

  return_items.first.inventory_unit&.order
end

#process_return!Object



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

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

#totalObject



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

def total
  return_items.sum(&:total)
end

#total_excluding_vatObject



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

def total_excluding_vat
  return_items.sum(&:total_excluding_vat)
end