Sha256: 2f9725300c5be7c69159cbe6c843c6c1e3b93e164567ff75f45bbca762025f5f

Contents?: true

Size: 495 Bytes

Versions: 34

Compression:

Stored size: 495 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
        )
      end

      fulfillment.save!
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.45 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.44 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.43 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.42 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.41 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.40 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.39 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.38 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.37 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.36 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.35 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.34 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.33 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.32 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.31 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.30 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.29 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.28 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.27 app/services/workarea/create_fulfillment.rb
workarea-core-3.4.26 app/services/workarea/create_fulfillment.rb