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, spree_base_scopes
#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
108
109
110
111
|
# File 'app/models/spree/return_item.rb', line 108
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
133
134
135
136
137
138
139
140
|
# File 'app/models/spree/return_item.rb', line 133
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
129
130
131
|
# File 'app/models/spree/return_item.rb', line 129
def eligible_exchange_variants
exchange_variant_engine.eligible_variants(variant)
end
|
#exchange_processed? ⇒ Boolean
117
118
119
|
# File 'app/models/spree/return_item.rb', line 117
def exchange_processed?
exchange_inventory_unit.present?
end
|
#exchange_requested? ⇒ Boolean
113
114
115
|
# File 'app/models/spree/return_item.rb', line 113
def exchange_requested?
exchange_variant.present?
end
|
#exchange_required? ⇒ Boolean
121
122
123
|
# File 'app/models/spree/return_item.rb', line 121
def exchange_required?
exchange_requested? && !exchange_processed?
end
|
#exchange_shipment ⇒ Object
142
143
144
|
# File 'app/models/spree/return_item.rb', line 142
def exchange_shipment
exchange_inventory_unit.try(:shipment)
end
|
#reception_completed? ⇒ Boolean
78
79
80
|
# File 'app/models/spree/return_item.rb', line 78
def reception_completed?
COMPLETED_RECEPTION_STATUSES.include?(reception_status)
end
|
#set_default_pre_tax_amount ⇒ Object
146
147
148
|
# File 'app/models/spree/return_item.rb', line 146
def set_default_pre_tax_amount
self.pre_tax_amount = refund_amount_calculator.new.compute(self)
end
|
#total ⇒ Object
125
126
127
|
# File 'app/models/spree/return_item.rb', line 125
def total
pre_tax_amount + included_tax_total + additional_tax_total
end
|