Sha256: c7911b2384a5ca147205f5e806a8f5c2832a62cea50b45154c545b57937eb513

Contents?: true

Size: 736 Bytes

Versions: 5

Compression:

Stored size: 736 Bytes

Contents

module Seko
  class Receipt

    def self.line_items(items)
      items.map.collect.with_index do |item, index|
        {
          "LineNumber"  => index + 1,
          "ProductCode" => item[:upc],
          "Quantity"    => item[:quantity],
          "SupplierCompanyCode" => Seko.config[:supplier_code]
        }
      end
    end

    def self.format(items, warehouse)
      {
        "Request" => {
          "List" => {
            "ReceiptLineItem" => line_items(items)
          },
          "Receipt" => {
            "ASNNumber" => random_asn
          },
          "ReceiptHeader" => {
            "DCCode" => warehouse
          }
        }
      }
    end

    def self.random_asn
      rand.to_s[2..11]
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
seko-0.0.5 lib/seko/receipt.rb
seko-0.0.4 lib/seko/receipt.rb
seko-0.0.3 lib/seko/receipt.rb
seko-0.0.2 lib/seko/receipt.rb
seko-0.0.1 lib/seko/receipt.rb