15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_materialRequest.rb', line 15
def self.build(aDistribution)
materialRequest = ''
aDistribution.each do |hDistribution|
aDistributor = hDistribution[:distributor]
aDistributor.each do |hDistributor|
instructions = nil
unless hDistributor[:orderProcess].empty?
instructions = hDistributor[:orderProcess][0][:orderingInstructions]
end
unless hDistributor[:contact].empty?
role = hDistributor[:contact][:roleName]
sbRole = Codelists.codelist_adiwg2sb('role_adiwg2sb', role)
sbRole = sbRole.nil? ? role : sbRole
aParties = hDistributor[:contact][:parties]
aParties.each do |hParty|
contactIndex = hParty[:contactIndex]
unless contactIndex.nil?
hContact = ADIWG::Mdtranslator::Writers::SbJson.get_contact_by_index(contactIndex)
unless hContact.empty?
name = hContact[:name]
if instructions.nil?
materialRequest += name + '(' + sbRole + '); '
else
materialRequest += name + '(' + sbRole + ' - ' + instructions + '); '
end
end
end
end
end
end
end
if materialRequest.length > 0
materialRequest = materialRequest[0...-2]
end
materialRequest
end
|