Sha256: 5f6d5e9aaa8957c1796d3701e384c5b301ac0ee1a49773a724c39cafc3da76e1
Contents?: true
Size: 664 Bytes
Versions: 7
Compression:
Stored size: 664 Bytes
Contents
module Spree module Stock class Quantifier attr_reader :stock_items def initialize(variant) @variant = variant @stock_items = Spree::StockItem.joins(:stock_location).where(:variant_id => @variant, Spree::StockLocation.table_name =>{ :active => true}) end def total_on_hand if Spree::Config.track_inventory_levels stock_items.sum(&:count_on_hand) else Float::INFINITY end end def backorderable? stock_items.any?(&:backorderable) end def can_supply?(required) total_on_hand >= required || backorderable? end end end end
Version data entries
7 entries across 7 versions & 1 rubygems