Sha256: 4ff4d6616b7710eab65de0be834d40352a71cebee1eda7e0182952d2a99413d5
Contents?: true
Size: 619 Bytes
Versions: 20
Compression:
Stored size: 619 Bytes
Contents
module Spree module Stock class Quantifier attr_reader :stock_items, :variant def initialize(variant) @variant = variant @stock_items = @variant.stock_items.with_active_stock_location end def total_on_hand if variant.should_track_inventory? stock_items.sum(:count_on_hand) else Float::INFINITY end end def backorderable? stock_items.any?(&:backorderable) end def can_supply?(required = 1) variant.available? && (total_on_hand >= required || backorderable?) end end end end
Version data entries
20 entries across 20 versions & 1 rubygems