Class: Iiko::Warehouse

Inherits:
Object
  • Object
show all
Defined in:
lib/iiko/warehouse.rb

Class Method Summary collapse

Class Method Details

.ingredients(data = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/iiko/warehouse.rb', line 6

def self.ingredients(data = nil)
  validate_arguments(data)
  goods = data[:goods]
  goods.headers['ingredients'] = goods.headers.length
  gh = goods.headers

  goods_map = {}
  goods.data.each do |item|
    goods_map[item[gh['NUM']]] = item
  end


  ttk = data[:ttk]
  th = ttk.headers

  ttk.data.each do |ingredient|
    goods_map[ingredient[th['PRODUCT_CODE']]][gh['ingredients']] ||= []
    goods_map[ingredient[th['PRODUCT_CODE']]][gh['ingredients']].push(ingredient)
  end
end