7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/inputs/item_moved_scrap_grouping_picker_input.rb', line 7
def collection
result_data = []
sql = "
select distinct trim(split_part(lineage_expanded,'>',1)) as group1,trim(split_part(lineage_expanded,'>',1)) as group1_position
from item_ledger_entries le
inner join items it on le.item_id = it.id
inner join product_lines pl on it.primary_product_line_id = pl.id
inner join supplier_items sp on it.id = sp.item_id
inner join parties pt on sp.supplier_id = pt.id
where location = 'SCRAP'
and quantity > 0
and category = 'RMA_RECEIPT';
"
result = ActiveRecord::Base.connection.execute(sql)
result.each { |r| result_data << [r['group1'],r['group1_position']]}
result_data.map{|r| [r[0],r[1]]}.uniq.sort
end
|