Class: Spree::ReturnItem
- Inherits:
-
Base
- Object
- ActiveRecord::Base
- Base
- Spree::ReturnItem
show all
- Extended by:
- DisplayMoney
- Defined in:
- app/models/spree/return_item.rb
Defined Under Namespace
Modules: ExchangeVariantEligibility
Constant Summary
collapse
- COMPLETED_RECEPTION_STATUSES =
%w(received given_to_customer)
Class Method Summary
collapse
Instance Method Summary
collapse
money_methods
Methods inherited from Base
page
#clear_preferences, #default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.from_inventory_unit(inventory_unit) ⇒ Object
106
107
108
109
|
# File 'app/models/spree/return_item.rb', line 106
def self.from_inventory_unit(inventory_unit)
not_cancelled.find_by(inventory_unit: inventory_unit) ||
new(inventory_unit: inventory_unit).tap(&:set_default_pre_tax_amount)
end
|
Instance Method Details
#build_exchange_inventory_unit ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'app/models/spree/return_item.rb', line 131
def build_exchange_inventory_unit
super(variant: exchange_variant, line_item: inventory_unit.line_item, order: inventory_unit.order) if exchange_required?
end
|
#eligible_exchange_variants ⇒ Object
127
128
129
|
# File 'app/models/spree/return_item.rb', line 127
def eligible_exchange_variants
exchange_variant_engine.eligible_variants(variant)
end
|
#exchange_processed? ⇒ Boolean
115
116
117
|
# File 'app/models/spree/return_item.rb', line 115
def exchange_processed?
exchange_inventory_unit.present?
end
|
#exchange_requested? ⇒ Boolean
111
112
113
|
# File 'app/models/spree/return_item.rb', line 111
def exchange_requested?
exchange_variant.present?
end
|
#exchange_required? ⇒ Boolean
119
120
121
|
# File 'app/models/spree/return_item.rb', line 119
def exchange_required?
exchange_requested? && !exchange_processed?
end
|
#exchange_shipment ⇒ Object
140
141
142
|
# File 'app/models/spree/return_item.rb', line 140
def exchange_shipment
exchange_inventory_unit.try(:shipment)
end
|
#reception_completed? ⇒ Boolean
76
77
78
|
# File 'app/models/spree/return_item.rb', line 76
def reception_completed?
COMPLETED_RECEPTION_STATUSES.include?(reception_status)
end
|
#set_default_pre_tax_amount ⇒ Object
144
145
146
|
# File 'app/models/spree/return_item.rb', line 144
def set_default_pre_tax_amount
self.pre_tax_amount = refund_amount_calculator.new.compute(self)
end
|
#total ⇒ Object
123
124
125
|
# File 'app/models/spree/return_item.rb', line 123
def total
pre_tax_amount + included_tax_total + additional_tax_total
end
|