Class: Spree::InventoryUnit
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::InventoryUnit
- Defined in:
- app/models/spree/inventory_unit.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.backordered_for_stock_item(stock_item) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/spree/inventory_unit.rb', line 29 def self.backordered_for_stock_item(stock_item) stock_locations_table = Spree::StockLocation.table_name shipments_table = Spree::Shipment.table_name joins(shipment: :stock_location). where("#{stock_locations_table}.id = ?", stock_item.stock_location_id). where(variant_id: stock_item.variant_id). where("#{shipments_table}.state != 'canceled'"). backordered.order('created_at ASC') end |
.finalize_units!(inventory_units) ⇒ Object
39 40 41 |
# File 'app/models/spree/inventory_unit.rb', line 39 def self.finalize_units!(inventory_units) inventory_units.map { |iu| iu.update_column(:pending, false) } end |