Sha256: 7e16255055718e35e0607cd951d7ff3fd6f7fb78a8f4951a8b886edb209b2a65

Contents?: true

Size: 583 Bytes

Versions: 10

Compression:

Stored size: 583 Bytes

Contents

module Returnly
  module Services
    class MarkItemsAsReturned
      attr_accessor :order, :line_items

      def initialize(order, line_items)
        @order      = order
        @line_items = line_items
      end

      def perform!
        line_items.each do |line_item|
          quantity = line_item[:units].to_i
          inventory_units_by(line_item[:order_line_item_id]).take(quantity).each(&:return)
        end
      end

      private

      def inventory_units_by(line_item_id)
        order.inventory_units.where(line_item_id: line_item_id)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
spree-returnly-0.13.1 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.13.1 lib/returnly/services/mark_items_as_returned.rb
spree-returnly-0.13.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.13.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.12.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.11.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.10.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.9.0 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.8.1 lib/returnly/services/mark_items_as_returned.rb
solidus-returnly-0.8.0 lib/returnly/services/mark_items_as_returned.rb