Sha256: 2b7d65f1308741cd7bed688d6d469622c3cefe88617b886697e444a95c3e05f6

Contents?: true

Size: 593 Bytes

Versions: 28

Compression:

Stored size: 593 Bytes

Contents

module Workarea
  class CreateFulfillment
    def initialize(order)
      @order = order
    end

    def fulfillment
      @fulfillment ||= Fulfillment.find_or_initialize_by(id: @order.id)
    end

    def perform
      @order.items.each do |item|
        next if fulfillment.items.detect { |i| i.order_item_id == item.id.to_s }
        fulfillment.items.build(order_item_id: item.id, quantity: item.quantity)

        Fulfillment::Sku.process!(
          item.sku,
          order_item: item,
          fulfillment: fulfillment
        )
      end

      fulfillment.save!
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.26 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.25 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.23 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.22 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.21 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.20 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.19 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.18 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.17 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.16 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.15 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.14 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.13 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.12 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.11 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.10 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.9 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.8 app/services/workarea/create_fulfillment.rb
workarea-core-3.5.7 app/services/workarea/create_fulfillment.rb