Sha256: f286e4a61df252487d6747c44c15fa9407a4bc1a66accce30a5141b9343e8929

Contents?: true

Size: 825 Bytes

Versions: 28

Compression:

Stored size: 825 Bytes

Contents

module Workarea
  module Inventory
    module CollectionStatus
      class Backordered
        include StatusCalculator::Status

        def in_status?
          model.any?(&:allow_backorder?) &&
            model.sum(&:backordered).positive? &&
            model.sum(&:available).zero?
        end
      end

      class LowInventory
        include StatusCalculator::Status

        def in_status?
          model.purchasable? &&
            !model.purchasable?(Workarea.config.low_inventory_threshold)
        end
      end

      class OutOfStock
        include StatusCalculator::Status

        def in_status?
          !model.purchasable?
        end
      end

      class Available
        include StatusCalculator::Status

        def in_status?
          model.purchasable?
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.6 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.5 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.4 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.3 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.2 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.1 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.0 app/models/workarea/inventory/collection_status.rb
workarea-core-3.5.0.beta.1 app/models/workarea/inventory/collection_status.rb