Class: Seko::Receipt

Inherits:
Object
  • Object
show all
Defined in:
lib/seko/receipt.rb

Class Method Summary collapse

Class Method Details

.format(items, warehouse) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/seko/receipt.rb', line 15

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

.line_items(items) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/seko/receipt.rb', line 4

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

.random_asnObject



31
32
33
# File 'lib/seko/receipt.rb', line 31

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