Sha256: 12e35655f14e5479b950d572605fc561154ddf00abc10ba91986fbc7108f100d
Contents?: true
Size: 1.07 KB
Versions: 62
Compression:
Stored size: 1.07 KB
Contents
module Workarea module Pricing class Discount module Conditions module ItemQuantity extend ActiveSupport::Concern included do # @!attribute item_quantity # @return [Integer] the number to check against # field :item_quantity, type: Integer, default: 0 add_qualifier :items_qualify? end # Whether this discount uses item quantity # as a condition. # # @return [Boolean] # def item_quantity? item_quantity.present? && item_quantity > 0 end # Whether this discount's item quantity passes # for this order. # # @param [Pricing::Discount::Order] order # @return [Boolean] # def items_qualify?(order) order.items.any? { |item| item_qualifies?(item) } end def item_qualifies?(item) !item_quantity? || item.quantity >= item_quantity end end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems