Sha256: c4f88a06797ab07406e1a6e8f48205e9788d670f8e6466bf22ebfda30e1f8acd

Contents?: true

Size: 707 Bytes

Versions: 8

Compression:

Stored size: 707 Bytes

Contents

module Returnly
  module Builders
    class CustomerReturn
      class << self
        def build_by_return_items(return_items)
          Spree::CustomerReturn.create(
            return_items: return_items,
            stock_location_id: stock_location_id(return_items.first)
          )
        end

        def build_by_stock_location(stock_location)
          Spree::CustomerReturn.new(stock_location: stock_location)
        end

        private

        def stock_location_id(return_item)
          return_item_order(return_item).shipments.last.stock_location_id
        end

        def return_item_order(return_item)
          return_item.inventory_unit.order
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
spree-returnly-0.13.1 lib/returnly/builders/customer_return.rb
solidus-returnly-0.13.1 lib/returnly/builders/customer_return.rb
spree-returnly-0.13.0 lib/returnly/builders/customer_return.rb
solidus-returnly-0.13.0 lib/returnly/builders/customer_return.rb
solidus-returnly-0.12.0 lib/returnly/builders/customer_return.rb
solidus-returnly-0.11.0 lib/returnly/builders/customer_return.rb
solidus-returnly-0.10.0 lib/returnly/builders/customer_return.rb
solidus-returnly-0.9.0 lib/returnly/builders/customer_return.rb