Class: Spree::CustomerReturn
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Spree::CustomerReturn
show all
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/customer_return.rb
Instance Method Summary
collapse
money_methods
Methods inherited from Base
display_includes
#generate_permalink, #save_permalink
Instance Method Details
#amount ⇒ Object
36
37
38
|
# File 'app/models/spree/customer_return.rb', line 36
def amount
return_items.sum(:amount)
end
|
#completely_decided? ⇒ Boolean
51
52
53
|
# File 'app/models/spree/customer_return.rb', line 51
def completely_decided?
!return_items.undecided.exists?
end
|
#fully_reimbursed? ⇒ 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
|
#order ⇒ Object
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
|
#total ⇒ Object
28
29
30
|
# File 'app/models/spree/customer_return.rb', line 28
def total
return_items.sum(&:total)
end
|
#total_excluding_vat ⇒ Object
32
33
34
|
# File 'app/models/spree/customer_return.rb', line 32
def total_excluding_vat
return_items.sum(&:total_excluding_vat)
end
|