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
#initialize_preference_defaults, page, preference
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#amount ⇒ Object
32
33
34
|
# File 'app/models/spree/customer_return.rb', line 32
def amount
return_items.sum(:amount)
end
|
#completely_decided? ⇒ Boolean
46
47
48
|
# File 'app/models/spree/customer_return.rb', line 46
def completely_decided?
!return_items.undecided.exists?
end
|
#fully_reimbursed? ⇒ 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
|
#order ⇒ Object
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
|
#pre_tax_total ⇒ Object
28
29
30
|
# File 'app/models/spree/customer_return.rb', line 28
def pre_tax_total
return_items.map(&:pre_tax_amount).sum
end
|
#process_return! ⇒ Object
50
51
52
|
# File 'app/models/spree/customer_return.rb', line 50
def process_return!
order.return! if order.all_inventory_units_returned?
end
|
#total ⇒ Object
24
25
26
|
# File 'app/models/spree/customer_return.rb', line 24
def total
return_items.map(&:total).sum
end
|