Class: Spree::CustomerReturn
Instance Method Summary
collapse
money_methods
Methods included from Metadata
#metadata, #metadata=, #public_metadata=
Instance Method Details
#can_create_reimbursement? ⇒ Boolean
59
60
61
|
# File 'app/models/spree/customer_return.rb', line 59
def can_create_reimbursement?
!fully_reimbursed? && completely_decided? && no_pending_reimbursements?
end
|
#completely_decided? ⇒ Boolean
35
36
37
|
# File 'app/models/spree/customer_return.rb', line 35
def completely_decided?
!return_items.undecided.exists?
end
|
#currency ⇒ Object
43
44
45
|
# File 'app/models/spree/customer_return.rb', line 43
def currency
order&.currency
end
|
#fully_reimbursed? ⇒ Boolean
39
40
41
|
# File 'app/models/spree/customer_return.rb', line 39
def fully_reimbursed?
completely_decided? && return_items.accepted.includes(:reimbursement).all? { |return_item| return_item.reimbursement.try(:reimbursed?) }
end
|
#no_pending_reimbursements? ⇒ Boolean
63
64
65
66
67
68
69
|
# File 'app/models/spree/customer_return.rb', line 63
def no_pending_reimbursements?
if association(:reimbursements).loaded?
reimbursements.select(&:pending?).empty?
else
reimbursements.where(reimbursement_status: :pending).none?
end
end
|
#order ⇒ Object
Temporarily tie a customer_return to one order
48
49
50
51
52
53
|
# File 'app/models/spree/customer_return.rb', line 48
def order
return nil if return_items.blank?
return nil if return_items.first.inventory_unit.blank?
return_items.first.inventory_unit.order
end
|
#pre_tax_total ⇒ Object
55
56
57
|
# File 'app/models/spree/customer_return.rb', line 55
def pre_tax_total
return_items.sum(:pre_tax_amount)
end
|