xmlconv2 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/History.txt +6 -0
  2. data/LICENCE.txt +339 -0
  3. data/Manifest.txt +107 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +28 -0
  6. data/bin/admin +65 -0
  7. data/bin/xmlconvd +19 -0
  8. data/data/grammar/i2.grammar +73 -0
  9. data/src/conversion/bdd_geh.rb +281 -0
  10. data/src/conversion/bdd_i2.rb +102 -0
  11. data/src/conversion/bdd_xml.rb +242 -0
  12. data/src/conversion/geh_bdd.rb +165 -0
  13. data/src/conversion/i2_bdd.rb +271 -0
  14. data/src/conversion/xml_bdd.rb +125 -0
  15. data/src/custom/lookandfeel.rb +47 -0
  16. data/src/i2/address.rb +33 -0
  17. data/src/i2/date.rb +37 -0
  18. data/src/i2/document.rb +26 -0
  19. data/src/i2/header.rb +24 -0
  20. data/src/i2/order.rb +44 -0
  21. data/src/i2/parser.rb +25 -0
  22. data/src/i2/position.rb +37 -0
  23. data/src/i2/record.rb +11 -0
  24. data/src/model/address.rb +20 -0
  25. data/src/model/agreement.rb +10 -0
  26. data/src/model/bdd.rb +26 -0
  27. data/src/model/bsr.rb +16 -0
  28. data/src/model/delivery.rb +15 -0
  29. data/src/model/delivery_item.rb +18 -0
  30. data/src/model/freetext_container.rb +26 -0
  31. data/src/model/id_container.rb +15 -0
  32. data/src/model/invoice.rb +18 -0
  33. data/src/model/invoice_item.rb +11 -0
  34. data/src/model/item.rb +19 -0
  35. data/src/model/item_container.rb +15 -0
  36. data/src/model/name.rb +27 -0
  37. data/src/model/part_info.rb +10 -0
  38. data/src/model/part_info_container.rb +15 -0
  39. data/src/model/party.rb +23 -0
  40. data/src/model/party_container.rb +20 -0
  41. data/src/model/price.rb +10 -0
  42. data/src/model/price_container.rb +18 -0
  43. data/src/model/transaction.rb +28 -0
  44. data/src/state/global.rb +28 -0
  45. data/src/state/global_predefine.rb +11 -0
  46. data/src/state/login.rb +38 -0
  47. data/src/state/transaction.rb +13 -0
  48. data/src/state/transactions.rb +130 -0
  49. data/src/util/application.rb +143 -0
  50. data/src/util/destination.rb +130 -0
  51. data/src/util/invoicer.rb +72 -0
  52. data/src/util/known_user.rb +16 -0
  53. data/src/util/polling_manager.rb +78 -0
  54. data/src/util/session.rb +23 -0
  55. data/src/util/transaction.rb +105 -0
  56. data/src/util/validator.rb +20 -0
  57. data/src/view/foot.rb +27 -0
  58. data/src/view/head.rb +13 -0
  59. data/src/view/login.rb +36 -0
  60. data/src/view/navigation.rb +30 -0
  61. data/src/view/navigationlink.rb +21 -0
  62. data/src/view/pager.rb +73 -0
  63. data/src/view/preformatted.rb +39 -0
  64. data/src/view/template.rb +17 -0
  65. data/src/view/transaction.rb +42 -0
  66. data/src/view/transactions.rb +90 -0
  67. data/test/mock.rb +149 -0
  68. data/test/suite.rb +16 -0
  69. data/test/test_conversion/bdd_geh.rb +533 -0
  70. data/test/test_conversion/bdd_i2.rb +314 -0
  71. data/test/test_conversion/bdd_xml.rb +556 -0
  72. data/test/test_conversion/geh_bdd.rb +372 -0
  73. data/test/test_conversion/i2_bdd.rb +804 -0
  74. data/test/test_conversion/xml_bdd.rb +203 -0
  75. data/test/test_i2/address.rb +88 -0
  76. data/test/test_i2/date.rb +49 -0
  77. data/test/test_i2/document.rb +62 -0
  78. data/test/test_i2/header.rb +39 -0
  79. data/test/test_i2/order.rb +94 -0
  80. data/test/test_i2/parser.rb +309 -0
  81. data/test/test_i2/position.rb +65 -0
  82. data/test/test_integration/geh_i2.rb +312 -0
  83. data/test/test_integration/i2_geh.rb +449 -0
  84. data/test/test_integration/i2_xml.rb +162 -0
  85. data/test/test_integration/xml_i2.rb +254 -0
  86. data/test/test_model/address.rb +35 -0
  87. data/test/test_model/agreement.rb +22 -0
  88. data/test/test_model/bdd.rb +55 -0
  89. data/test/test_model/bsr.rb +38 -0
  90. data/test/test_model/delivery.rb +79 -0
  91. data/test/test_model/delivery_item.rb +52 -0
  92. data/test/test_model/freetext_container.rb +45 -0
  93. data/test/test_model/invoice.rb +65 -0
  94. data/test/test_model/invoice_item.rb +41 -0
  95. data/test/test_model/name.rb +57 -0
  96. data/test/test_model/part_info.rb +24 -0
  97. data/test/test_model/party.rb +96 -0
  98. data/test/test_model/price.rb +24 -0
  99. data/test/test_util/application.rb +168 -0
  100. data/test/test_util/destination.rb +197 -0
  101. data/test/test_util/invoicer.rb +36 -0
  102. data/test/test_util/polling_manager.rb +111 -0
  103. data/test/test_util/transaction.rb +129 -0
  104. data/user-stories/UserStories_XmlConv2.txt +381 -0
  105. data/user-stories/doku/ABB.incoming.HTTP.invoice.xml +315 -0
  106. data/user-stories/doku/ABB.received.xml +259 -0
  107. data/user-stories/doku/BO_OrderProcessing.sxw +0 -0
  108. metadata +195 -0
@@ -0,0 +1,271 @@
1
+ #!/usr/bin/env ruby
2
+ # I2Bdd -- xmlconv2 -- 28.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'i2/parser'
5
+ require 'model/address'
6
+ require 'model/agreement'
7
+ require 'model/bdd'
8
+ require 'model/bsr'
9
+ require 'model/delivery'
10
+ require 'model/delivery_item'
11
+ require 'model/invoice'
12
+ require 'model/invoice_item'
13
+ require 'model/name'
14
+ require 'model/party'
15
+ require 'model/part_info'
16
+ require 'model/price'
17
+ require 'time'
18
+ require 'date'
19
+
20
+ module XmlConv
21
+ module Conversion
22
+ class I2Bdd
23
+ I2_ADDR_CODES = {
24
+ 'BY' => 'BillTo',
25
+ 'DP' => 'ShipTo',
26
+ }
27
+ class << self
28
+ def convert(ast)
29
+ bdd = Model::Bdd.new
30
+ ast.records.each_node { |node|
31
+ _bdd_add_ast_node(bdd, node)
32
+ }
33
+ bdd
34
+ end
35
+ def parse(src)
36
+ I2.cached_parser.parse(src)
37
+ end
38
+ def _bdd_add_address(bdd, address)
39
+ transaction = _select_bdd_transaction(bdd)
40
+ atype = _value(address.atype)
41
+ case(atype)
42
+ when 'SE'
43
+ transaction.seller.address = _bdd_assemble_address(address)
44
+ when 'CU'
45
+ transaction.customer.address = _bdd_assemble_address(address)
46
+ when 'DP', 'BY'
47
+ delivery_party = Model::Party.new
48
+ delivery_party.role = I2_ADDR_CODES[atype]
49
+ delivery_party.address = _bdd_assemble_address(address)
50
+ transaction.customer.add_party(delivery_party)
51
+ when 'EP'
52
+ employee = transaction.customer.employee \
53
+ || _customer_add_employee(customer)
54
+ employee.address = _bdd_assemble_address(address)
55
+ end
56
+ end
57
+ def _bdd_add_ast_node(bdd, node)
58
+ case node.name
59
+ when 'Address'
60
+ _bdd_add_address(bdd, node)
61
+ when 'Commission'
62
+ _bdd_add_commission(bdd, node)
63
+ when 'Header'
64
+ _bdd_add_header(bdd, node)
65
+ when 'HeaderText'
66
+ _bdd_add_header_text(bdd, node)
67
+ when 'Position'
68
+ _bdd_add_position(bdd, node)
69
+ when 'Footer'
70
+ _bdd_add_footer(bdd, node)
71
+ end
72
+ end
73
+ def _bdd_add_commission(bdd, ast)
74
+ if(_bdd_transaction_type(bdd) == 'Invoice')
75
+ _bdd_add_invoice(bdd, ast)
76
+ else
77
+ _bdd_add_delivery(bdd, ast)
78
+ end
79
+ end
80
+ def _bdd_add_delivery(bdd, ast)
81
+ delivery = Model::Delivery.new
82
+ delivery.status = 'Confirmed'
83
+ delivery.add_id('ACC', _value(ast.reference))
84
+ _bdd_assemble_transaction(delivery, ast)
85
+ bdd.add_delivery(delivery)
86
+ end
87
+ def _bdd_add_footer(bdd, ast)
88
+ transaction = _select_bdd_transaction(bdd)
89
+ _item_add_price(transaction, ast.pricenetto, 'SummePositionen')
90
+ _item_add_price(transaction, ast.vatpercent, 'MehrwertsteuerPct')
91
+ _item_add_price(transaction, ast.vatamount, 'Mehrwertsteuer')
92
+
93
+ _item_add_price(transaction, ast.pricebrutto, 'Endbetrag')
94
+ if(terms = ast.agreement)
95
+ agreement = Model::Agreement.new
96
+ agreement.terms_cond = _value(terms)
97
+ transaction.agreement = agreement
98
+ end
99
+ end
100
+ def _bdd_add_free_text(obj, text, type=nil)
101
+ if(txt = obj.free_text)
102
+ txt << text
103
+ else
104
+ obj.add_free_text(type, text)
105
+ end
106
+ end
107
+ def _bdd_add_header(bdd, ast)
108
+ bsr = Model::Bsr.new
109
+ bsr.timestamp = Time.parse(_value(ast.date).to_s <<
110
+ _value(ast.time).to_s)
111
+ case _value(ast.mtype)
112
+ when 'CONFIRM'
113
+ bsr.verb = 'Return'
114
+ bsr.noun = 'Status'
115
+ when 'INVOIC'
116
+ bsr.verb = 'Return'
117
+ bsr.noun = 'Invoice'
118
+ end
119
+ if(customer_name = _value(ast.recipient))
120
+ customer = Model::Party.new
121
+ customer.role = 'Customer'
122
+ name = Model::Name.new
123
+ name.text = customer_name
124
+ customer.name = name
125
+ bsr.add_party(customer)
126
+ end
127
+ bdd.bsr = bsr
128
+ end
129
+ def _bdd_add_header_text(bdd, ast)
130
+ if(text = _value(ast.text))
131
+ transaction = _select_bdd_transaction(bdd)
132
+ _bdd_add_free_text(transaction, text)
133
+ end
134
+ end
135
+ def _bdd_add_invoice(bdd, ast)
136
+ invoice = Model::Invoice.new
137
+ invoice.status = 'Invoiced'
138
+ invoice.add_invoice_id('Invoice', _value(ast.receipt))
139
+ invoice.add_delivery_id('ACC', _value(ast.reference))
140
+ _bdd_assemble_transaction(invoice, ast)
141
+ bdd.add_invoice(invoice)
142
+ end
143
+ def _bdd_add_position(bdd, ast)
144
+ transaction = _select_bdd_transaction(bdd)
145
+ if(transaction.is_a?(Model::Invoice))
146
+ _invoice_add_item(transaction, ast)
147
+ else
148
+ _delivery_add_item(transaction, ast)
149
+ end
150
+ end
151
+ def _bdd_assemble_address(address)
152
+ bdd_addr = Model::Address.new
153
+ bdd_addr.add_line(_value(address.name1))
154
+ if(name2 = _value(address.name2))
155
+ bdd_addr.add_line(name2)
156
+ end
157
+ bdd_addr.add_line(_value(address.street))
158
+ bdd_addr.city = _value(address.city)
159
+ bdd_addr.zip_code = _value(address.code)
160
+ bdd_addr.country = _value(address.country)
161
+ bdd_addr
162
+ end
163
+ def _bdd_assemble_item(item, ast)
164
+ item.line_no = _value(ast.lineno)
165
+ if(etnr = _value(ast.eancode))
166
+ item.add_id('EAN-Nummer', etnr)
167
+ end
168
+ =begin
169
+ if(sellercode = _value(ast.sellercode))
170
+ item.add_id('Lieferantenartikel', sellercode)
171
+ end
172
+ =end
173
+ if(buyercode = _value(ast.buyercode))
174
+ item.add_id('ET-Nummer', buyercode)
175
+ end
176
+ =begin
177
+ [:description1, :description2].collect { |symbol|
178
+ _value(ast.send(symbol))
179
+ }.compact.each { |descr|
180
+ _bdd_add_free_text(item, descr, 'Bezeichnung')
181
+ }
182
+ =end
183
+ item.qty = _value(ast.qty)
184
+ _item_add_price(item, ast.pricenettopce, 'NettoPreis')
185
+ _item_add_price(item, ast.pricenetto, 'NettoPreisME')
186
+ _item_add_price(item, ast.discountpce, 'Grundrabatt')
187
+ _item_add_price(item, ast.discount, 'GrundrabattME')
188
+ _item_add_price(item, ast.extradiscountpce, 'Sonderrabatt')
189
+ _item_add_price(item, ast.extradiscount, 'SonderrabattME')
190
+ _item_add_price(item, ast.pricebruttopce, 'BruttoPreis')
191
+ _item_add_price(item, ast.pricebrutto, 'BruttoPreisME')
192
+ end
193
+ def _bdd_assemble_transaction(transaction, ast)
194
+ if(datestr = _value(ast.rdate))
195
+ transaction.status_date = Date.parse(datestr)
196
+ end
197
+ transaction.add_id('Customer', _value(ast.commission))
198
+ seller = Model::Party.new
199
+ seller.role = 'Seller'
200
+ transaction.add_party(seller)
201
+ customer = Model::Party.new
202
+ customer.role = 'Customer'
203
+ if(emp = _value(ast.employee))
204
+ employee = _customer_add_employee(customer)
205
+ name = Model::Name.new
206
+ name.text = emp
207
+ employee.name = name
208
+ end
209
+ transaction.add_party(customer)
210
+ end
211
+ def _bdd_transaction_type(bdd)
212
+ unless((bsr = bdd.bsr) && (noun = bsr.noun))
213
+ raise 'Invalid Conversion: there was no valid Header in AST'
214
+ end
215
+ noun
216
+ end
217
+ def _customer_add_employee(customer)
218
+ employee = Model::Party.new
219
+ employee.role = 'Employee'
220
+ customer.add_party(employee)
221
+ employee
222
+ end
223
+ def _delivery_add_item(delivery, ast)
224
+ item = Model::DeliveryItem.new
225
+ _bdd_assemble_item(item, ast)
226
+ if(datestr = _value(ast.ddate))
227
+ item.delivery_date = Date.parse(datestr)
228
+ end
229
+ delivery.add_item(item)
230
+ end
231
+ def _invoice_add_item(invoice, ast)
232
+ item = Model::InvoiceItem.new
233
+ _bdd_assemble_item(item, ast)
234
+ if(origin = _value(ast.origin))
235
+ _item_add_part_info(item, 'Ursprungsland', origin)
236
+ end
237
+ if(customs = _value(ast.customs))
238
+ _item_add_part_info(item, 'Zolltarifnr.', customs)
239
+ end
240
+ invoice.add_item(item)
241
+ end
242
+ def _item_add_part_info(item, dimension, value)
243
+ info = Model::PartInfo.new
244
+ info.dimension = dimension
245
+ info.value = value
246
+ item.add_part_info(info)
247
+ end
248
+ def _item_add_price(item, ast, purpose)
249
+ if(price = _value(ast))
250
+ bdd_price = Model::Price.new
251
+ bdd_price.purpose = purpose
252
+ bdd_price.amount = sprintf('%1.2f', price)
253
+ item.add_price(bdd_price)
254
+ end
255
+ end
256
+ def _select_bdd_transaction(bdd)
257
+ if(_bdd_transaction_type(bdd) == 'Invoice')
258
+ bdd.invoices.last
259
+ else
260
+ bdd.deliveries.last
261
+ end
262
+ end
263
+ def _value(node)
264
+ unless(node.attributes.empty?)
265
+ node.value
266
+ end
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby
2
+ # XmlBdd -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'date'
5
+ require 'iconv'
6
+ require 'rexml/document'
7
+ require 'rexml/xpath'
8
+ require 'model/address'
9
+ require 'model/bdd'
10
+ require 'model/bsr'
11
+ require 'model/delivery'
12
+ require 'model/delivery_item'
13
+ require 'model/name'
14
+ require 'model/party'
15
+
16
+ module XmlConv
17
+ module Conversion
18
+ class XmlBdd
19
+ class << self
20
+ def convert(xml_document)
21
+ bdd = Model::Bdd.new
22
+ if(xml_bsr = REXML::XPath.first(xml_document, 'BDD/BSR'))
23
+ _bdd_add_xml_bsr(bdd, xml_bsr)
24
+ end
25
+ REXML::XPath.each(xml_document, 'BDD/Delivery') { |xml_delivery|
26
+ _bdd_add_xml_delivery(bdd, xml_delivery)
27
+ }
28
+ bdd
29
+ end
30
+ def parse(xml_src)
31
+ REXML::Document.new(xml_src)
32
+ end
33
+ def _bdd_add_xml_bsr(bdd, xml_bsr)
34
+ bsr = Model::Bsr.new
35
+ REXML::XPath.each(xml_bsr, 'Party') { |xml_party|
36
+ _container_add_xml_party(bsr, xml_party)
37
+ }
38
+ bdd.bsr = bsr
39
+ end
40
+ def _bdd_add_xml_delivery(bdd, xml_delivery)
41
+ delivery = Model::Delivery.new
42
+ delivery.bsr = bdd.bsr
43
+ REXML::XPath.each(xml_delivery, 'DeliveryId') { |xml_id|
44
+ _container_add_xml_id(delivery, xml_id)
45
+ }
46
+ REXML::XPath.each(xml_delivery, 'Party') { |xml_party|
47
+ _container_add_xml_party(delivery, xml_party)
48
+ }
49
+ REXML::XPath.each(xml_delivery, 'DeliveryItem') { |xml_item|
50
+ _delivery_add_xml_item(delivery, xml_item)
51
+ }
52
+ bdd.add_delivery(delivery)
53
+ end
54
+ def _container_add_xml_party(container, xml_party)
55
+ party = Model::Party.new
56
+ party.role = _latin1(xml_party.attribute('Role').value)
57
+ REXML::XPath.each(xml_party, 'PartyId') { |xml_id|
58
+ _container_add_xml_id(party, xml_id)
59
+ }
60
+ if(xml_name = REXML::XPath.first(xml_party, 'Name'))
61
+ _party_add_xml_name(party, xml_name)
62
+ end
63
+ if(xml_address = REXML::XPath.first(xml_party, 'Address'))
64
+ _party_add_xml_address(party, xml_address)
65
+ end
66
+ REXML::XPath.each(xml_party, 'Party') { |xml_inner_party|
67
+ _container_add_xml_party(party, xml_inner_party)
68
+ }
69
+ container.add_party(party)
70
+ end
71
+ def _container_add_xml_id(container, xml_id)
72
+ domain = _latin1(xml_id.attribute('Domain').value)
73
+ value = _latin1(xml_id.text)
74
+ container.add_id(domain, value)
75
+ end
76
+ def _delivery_add_xml_item(delivery, xml_item)
77
+ item = Model::DeliveryItem.new
78
+ xml_line_no = REXML::XPath.first(xml_item, 'LineNo')
79
+ item.line_no = _latin1(xml_line_no.text)
80
+ REXML::XPath.each(xml_item, 'PartId/IdentNo') { |xml_id|
81
+ _container_add_xml_id(item, xml_id)
82
+ }
83
+ xml_qty = REXML::XPath.first(xml_item, 'Qty')
84
+ item.qty = xml_qty.text
85
+ if(xml_date = REXML::XPath.first(xml_item, 'DeliveryDate'))
86
+ raw = _latin1(xml_date.text)
87
+ item.delivery_date = begin
88
+ Date.parse(raw.gsub(/\./, '-'))
89
+ rescue
90
+ Date.today
91
+ end
92
+ end
93
+ delivery.add_item(item)
94
+ end
95
+ def _party_add_xml_address(party, xml_address)
96
+ address = Model::Address.new
97
+ REXML::XPath.each(xml_address, 'AddressLine') { |xml_addr_line|
98
+ address.add_line(_latin1(xml_addr_line.text))
99
+ }
100
+ xml_city = REXML::XPath.first(xml_address, 'City')
101
+ address.city = _latin1(xml_city.text)
102
+ xml_zip_code = REXML::XPath.first(xml_address, 'ZipCode')
103
+ address.zip_code = _latin1(xml_zip_code.text)
104
+ party.address = address
105
+ end
106
+ def _party_add_xml_name(party, xml_name)
107
+ name = Model::Name.new
108
+ name.text = _latin1(xml_name.text)
109
+ if(xml_first = REXML::XPath.first(xml_name, 'FirstName'))
110
+ name.first = _latin1(xml_first.text)
111
+ end
112
+ if(xml_last = REXML::XPath.first(xml_name, 'LastName'))
113
+ name.last = _latin1(xml_last.text)
114
+ end
115
+ party.name = name
116
+ end
117
+ def _latin1(str)
118
+ Iconv.iconv('ISO-8859-1', 'UTF8', str).first.strip
119
+ rescue Exception => err
120
+ str
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ # Custom::Lookandfeel -- xmlconv2 -- 09.06.2004 -- hwyss@ywesee.com
3
+
4
+ require 'sbsm/lookandfeel'
5
+
6
+ module XmlConv
7
+ module Custom
8
+ class Lookandfeel < SBSM::Lookandfeel
9
+ DICTIONARIES = {
10
+ 'de' => {
11
+ :copyright0 => '&copy;ywesee.com&nbsp;',
12
+ :copyright1 => '',
13
+ :home => 'Home',
14
+ :login => 'Anmelden',
15
+ :login_welcome => 'Willkommen bei XmlConv',
16
+ :logout => 'Abmelden',
17
+ :navigation_divider => '|',
18
+ :page_back => "&lt;&lt;",
19
+ :page_fwd => "&gt;&gt;",
20
+ :page_number0 => "Seite&nbsp;",
21
+ :page_number1 => "&nbsp;von&nbsp;",
22
+ :page_number2 => "",
23
+ :pass => 'Passwort',
24
+ :status_error => 'Fehler',
25
+ :status_http_ok => '&Uuml;bertragung erfolgreich',
26
+ :status_http_not_found => 'URI nicht gefunden',
27
+ :status_http_unauthorized => 'Keine Berechtigung',
28
+ :status_open => 'Offen',
29
+ :status_pending_pickup => 'Bereit zum Abholen',
30
+ :status_picked_up => 'Abgeholt',
31
+ :th_commit_time => 'Zeit',
32
+ :th_error => 'Fehler',
33
+ :th_input => 'Input',
34
+ :th_uri_comparable => 'Empf�nger',
35
+ :th_filename => 'Filename',
36
+ :th_transaction_id => 'ID',
37
+ :th_origin => 'Absender',
38
+ :th_output => 'Output',
39
+ :th_status_comparable => 'Status',
40
+ }
41
+ }
42
+ RESOURCES = {
43
+ :css => 'xmlconv.css'
44
+ }
45
+ end
46
+ end
47
+ end
data/src/i2/address.rb ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ # I2::Address -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ module XmlConv
5
+ module I2
6
+ class Address
7
+ attr_accessor :code, :party_id
8
+ attr_accessor :name1, :name2, :street1, :city, :zip_code, :street2
9
+ I2_ADDR_CODES = {
10
+ :buyer => 'BY',
11
+ :delivery => 'DP',
12
+ :employee => 'EP',
13
+ }
14
+ def initialize
15
+ @code = :buyer
16
+ end
17
+ def to_s
18
+ output = []
19
+ numerals = [ 201, 202, 220, 221, 222, 223, 225, 226 ]
20
+ [
21
+ I2_ADDR_CODES[@code],
22
+ @party_id, @name1, @name2, @street1,
23
+ @city, @zip_code, @street2,
24
+ ].each_with_index { |value, idx|
25
+ unless(value.nil?)
26
+ output << "#{numerals[idx]}:#{value}"
27
+ end
28
+ }
29
+ output.join("\n") << "\n"
30
+ end
31
+ end
32
+ end
33
+ end