Class: Spree::StockItem
- Inherits:
-
Base
- Object
- ApplicationRecord
- Base
- Spree::StockItem
show all
- Defined in:
- app/models/spree/stock_item.rb
Instance Method Summary
collapse
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
Instance Method Details
#adjust_count_on_hand(value) ⇒ Object
36
37
38
39
40
|
# File 'app/models/spree/stock_item.rb', line 36
def adjust_count_on_hand(value)
self.with_lock do
set_count_on_hand(count_on_hand + value)
end
end
|
#available? ⇒ Boolean
Tells whether it’s available to be included in a shipment
54
55
56
|
# File 'app/models/spree/stock_item.rb', line 54
def available?
self.in_stock? || self.backorderable?
end
|
#backordered_inventory_units ⇒ Object
#in_stock? ⇒ Boolean
49
50
51
|
# File 'app/models/spree/stock_item.rb', line 49
def in_stock?
self.count_on_hand > 0
end
|
#reduce_count_on_hand_to_zero ⇒ Object
62
63
64
|
# File 'app/models/spree/stock_item.rb', line 62
def reduce_count_on_hand_to_zero
self.set_count_on_hand(0) if count_on_hand > 0
end
|
#set_count_on_hand(value) ⇒ Object
42
43
44
45
46
47
|
# File 'app/models/spree/stock_item.rb', line 42
def set_count_on_hand(value)
self.count_on_hand = value
process_backorders(count_on_hand - count_on_hand_was)
self.save!
end
|
#variant ⇒ Object
58
59
60
|
# File 'app/models/spree/stock_item.rb', line 58
def variant
Spree::Variant.unscoped { super }
end
|