xmlconv2 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/LICENCE.txt +339 -0
- data/Manifest.txt +107 -0
- data/README.txt +25 -0
- data/Rakefile +28 -0
- data/bin/admin +65 -0
- data/bin/xmlconvd +19 -0
- data/data/grammar/i2.grammar +73 -0
- data/src/conversion/bdd_geh.rb +281 -0
- data/src/conversion/bdd_i2.rb +102 -0
- data/src/conversion/bdd_xml.rb +242 -0
- data/src/conversion/geh_bdd.rb +165 -0
- data/src/conversion/i2_bdd.rb +271 -0
- data/src/conversion/xml_bdd.rb +125 -0
- data/src/custom/lookandfeel.rb +47 -0
- data/src/i2/address.rb +33 -0
- data/src/i2/date.rb +37 -0
- data/src/i2/document.rb +26 -0
- data/src/i2/header.rb +24 -0
- data/src/i2/order.rb +44 -0
- data/src/i2/parser.rb +25 -0
- data/src/i2/position.rb +37 -0
- data/src/i2/record.rb +11 -0
- data/src/model/address.rb +20 -0
- data/src/model/agreement.rb +10 -0
- data/src/model/bdd.rb +26 -0
- data/src/model/bsr.rb +16 -0
- data/src/model/delivery.rb +15 -0
- data/src/model/delivery_item.rb +18 -0
- data/src/model/freetext_container.rb +26 -0
- data/src/model/id_container.rb +15 -0
- data/src/model/invoice.rb +18 -0
- data/src/model/invoice_item.rb +11 -0
- data/src/model/item.rb +19 -0
- data/src/model/item_container.rb +15 -0
- data/src/model/name.rb +27 -0
- data/src/model/part_info.rb +10 -0
- data/src/model/part_info_container.rb +15 -0
- data/src/model/party.rb +23 -0
- data/src/model/party_container.rb +20 -0
- data/src/model/price.rb +10 -0
- data/src/model/price_container.rb +18 -0
- data/src/model/transaction.rb +28 -0
- data/src/state/global.rb +28 -0
- data/src/state/global_predefine.rb +11 -0
- data/src/state/login.rb +38 -0
- data/src/state/transaction.rb +13 -0
- data/src/state/transactions.rb +130 -0
- data/src/util/application.rb +143 -0
- data/src/util/destination.rb +130 -0
- data/src/util/invoicer.rb +72 -0
- data/src/util/known_user.rb +16 -0
- data/src/util/polling_manager.rb +78 -0
- data/src/util/session.rb +23 -0
- data/src/util/transaction.rb +105 -0
- data/src/util/validator.rb +20 -0
- data/src/view/foot.rb +27 -0
- data/src/view/head.rb +13 -0
- data/src/view/login.rb +36 -0
- data/src/view/navigation.rb +30 -0
- data/src/view/navigationlink.rb +21 -0
- data/src/view/pager.rb +73 -0
- data/src/view/preformatted.rb +39 -0
- data/src/view/template.rb +17 -0
- data/src/view/transaction.rb +42 -0
- data/src/view/transactions.rb +90 -0
- data/test/mock.rb +149 -0
- data/test/suite.rb +16 -0
- data/test/test_conversion/bdd_geh.rb +533 -0
- data/test/test_conversion/bdd_i2.rb +314 -0
- data/test/test_conversion/bdd_xml.rb +556 -0
- data/test/test_conversion/geh_bdd.rb +372 -0
- data/test/test_conversion/i2_bdd.rb +804 -0
- data/test/test_conversion/xml_bdd.rb +203 -0
- data/test/test_i2/address.rb +88 -0
- data/test/test_i2/date.rb +49 -0
- data/test/test_i2/document.rb +62 -0
- data/test/test_i2/header.rb +39 -0
- data/test/test_i2/order.rb +94 -0
- data/test/test_i2/parser.rb +309 -0
- data/test/test_i2/position.rb +65 -0
- data/test/test_integration/geh_i2.rb +312 -0
- data/test/test_integration/i2_geh.rb +449 -0
- data/test/test_integration/i2_xml.rb +162 -0
- data/test/test_integration/xml_i2.rb +254 -0
- data/test/test_model/address.rb +35 -0
- data/test/test_model/agreement.rb +22 -0
- data/test/test_model/bdd.rb +55 -0
- data/test/test_model/bsr.rb +38 -0
- data/test/test_model/delivery.rb +79 -0
- data/test/test_model/delivery_item.rb +52 -0
- data/test/test_model/freetext_container.rb +45 -0
- data/test/test_model/invoice.rb +65 -0
- data/test/test_model/invoice_item.rb +41 -0
- data/test/test_model/name.rb +57 -0
- data/test/test_model/part_info.rb +24 -0
- data/test/test_model/party.rb +96 -0
- data/test/test_model/price.rb +24 -0
- data/test/test_util/application.rb +168 -0
- data/test/test_util/destination.rb +197 -0
- data/test/test_util/invoicer.rb +36 -0
- data/test/test_util/polling_manager.rb +111 -0
- data/test/test_util/transaction.rb +129 -0
- data/user-stories/UserStories_XmlConv2.txt +381 -0
- data/user-stories/doku/ABB.incoming.HTTP.invoice.xml +315 -0
- data/user-stories/doku/ABB.received.xml +259 -0
- data/user-stories/doku/BO_OrderProcessing.sxw +0 -0
- metadata +195 -0
@@ -0,0 +1,309 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::TestParser -- xmlconv2 -- 28.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'i2/parser'
|
9
|
+
|
10
|
+
module XmlConv
|
11
|
+
module I2
|
12
|
+
class TestParser < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
@parser = XmlConv::I2.cached_parser
|
15
|
+
end
|
16
|
+
def test_parser_class
|
17
|
+
assert_instance_of(GeneralizedLrParser, @parser)
|
18
|
+
end
|
19
|
+
def test_parse_header
|
20
|
+
src = <<-EOS
|
21
|
+
"00" "Sender Identification" "Recipient Identification"
|
22
|
+
"20040628" "1159" "CONFIRM" "1"
|
23
|
+
EOS
|
24
|
+
ast = @parser.parse(src)
|
25
|
+
assert_instance_of(SyntaxTree, ast)
|
26
|
+
assert_instance_of(ArrayNode, ast.records)
|
27
|
+
header = ast.records.first
|
28
|
+
assert_instance_of(SyntaxTree, header)
|
29
|
+
assert_equal('Header', header.name)
|
30
|
+
rtype = header.rtype
|
31
|
+
assert_instance_of(SyntaxTree, rtype)
|
32
|
+
assert_equal('00', rtype.value)
|
33
|
+
sender = header.sender
|
34
|
+
assert_instance_of(SyntaxTree, sender)
|
35
|
+
assert_equal('Sender Identification', sender.value)
|
36
|
+
recipient = header.recipient
|
37
|
+
assert_instance_of(SyntaxTree, recipient)
|
38
|
+
assert_equal('Recipient Identification', recipient.value)
|
39
|
+
date = header.date
|
40
|
+
assert_instance_of(SyntaxTree, date)
|
41
|
+
assert_equal('20040628', date.value)
|
42
|
+
time = header.time
|
43
|
+
assert_instance_of(SyntaxTree, time)
|
44
|
+
assert_equal('1159', time.value)
|
45
|
+
mtype = header.mtype
|
46
|
+
assert_instance_of(SyntaxTree, mtype)
|
47
|
+
assert_equal('CONFIRM', mtype.value)
|
48
|
+
test = header.test
|
49
|
+
assert_instance_of(SyntaxTree, test)
|
50
|
+
assert_equal('1', test.value)
|
51
|
+
end
|
52
|
+
def test_parse_incomplete_header
|
53
|
+
src = <<-EOS
|
54
|
+
"00" "" "" "" "" "" ""
|
55
|
+
EOS
|
56
|
+
ast = nil
|
57
|
+
assert_nothing_raised {
|
58
|
+
ast = @parser.parse(src)
|
59
|
+
}
|
60
|
+
header = ast.records.first
|
61
|
+
assert_equal('Header', header.name)
|
62
|
+
end
|
63
|
+
def test_parse_commission
|
64
|
+
# commented fields are not in the current version
|
65
|
+
src = <<-EOS
|
66
|
+
"01" "456" "Receipt-Number" "20040627" "Order Number"
|
67
|
+
"Commission Number" "OC" "Employee"
|
68
|
+
EOS
|
69
|
+
ast = @parser.parse(src)
|
70
|
+
assert_instance_of(SyntaxTree, ast)
|
71
|
+
comm = ast.records.first
|
72
|
+
assert_instance_of(SyntaxTree, comm)
|
73
|
+
assert_equal('Commission', comm.name)
|
74
|
+
assert_equal('01', comm.rtype.value)
|
75
|
+
assert_equal('456', comm.btype.value)
|
76
|
+
assert_equal('Receipt-Number', comm.receipt.value)
|
77
|
+
assert_equal('20040627', comm.rdate.value)
|
78
|
+
#assert_equal('20040629', comm.ddate.value)
|
79
|
+
assert_equal('Order Number', comm.reference.value)
|
80
|
+
assert_equal('Commission Number', comm.commission.value)
|
81
|
+
assert_equal('OC', comm.contact.value)
|
82
|
+
assert_equal('Employee', comm.employee.value)
|
83
|
+
#assert_equal('TE', comm.medium.value)
|
84
|
+
#assert_equal('0041 1 350 85 87', comm.number.value)
|
85
|
+
end
|
86
|
+
def test_parse_incomplete_commission
|
87
|
+
src = <<-EOS
|
88
|
+
"01" "" "" "" "" "" "" ""
|
89
|
+
EOS
|
90
|
+
ast = nil
|
91
|
+
assert_nothing_raised {
|
92
|
+
ast = @parser.parse(src)
|
93
|
+
}
|
94
|
+
comm = ast.records.first
|
95
|
+
assert_equal('Commission', comm.name)
|
96
|
+
end
|
97
|
+
def test_parse_address
|
98
|
+
src = <<-EOS
|
99
|
+
"02" "BY" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
|
100
|
+
EOS
|
101
|
+
ast = @parser.parse(src)
|
102
|
+
assert_instance_of(SyntaxTree, ast)
|
103
|
+
addr = ast.records.first
|
104
|
+
assert_instance_of(SyntaxTree, addr)
|
105
|
+
assert_equal('Address', addr.name)
|
106
|
+
assert_equal('02', addr.rtype.value)
|
107
|
+
assert_equal('BY', addr.atype.value)
|
108
|
+
assert_equal('Name1', addr.name1.value)
|
109
|
+
assert_equal('Name2', addr.name2.value)
|
110
|
+
assert_equal('Street', addr.street.value)
|
111
|
+
assert_equal('City', addr.city.value)
|
112
|
+
assert_equal('AddressCode', addr.code.value)
|
113
|
+
assert_equal('Country', addr.country.value)
|
114
|
+
end
|
115
|
+
def test_parse_incomplete_address
|
116
|
+
src = <<-EOS
|
117
|
+
"02" "" "" "" "" "" "" ""
|
118
|
+
EOS
|
119
|
+
ast = nil
|
120
|
+
assert_nothing_raised {
|
121
|
+
ast = @parser.parse(src)
|
122
|
+
}
|
123
|
+
addr = ast.records.first
|
124
|
+
assert_equal('Address', addr.name)
|
125
|
+
end
|
126
|
+
def test_parse_header_text
|
127
|
+
src = <<-EOS
|
128
|
+
"05" "A single Header-Text"
|
129
|
+
EOS
|
130
|
+
ast = @parser.parse(src)
|
131
|
+
assert_instance_of(SyntaxTree, ast)
|
132
|
+
text = ast.records.first
|
133
|
+
assert_instance_of(SyntaxTree, text)
|
134
|
+
assert_equal('HeaderText', text.name)
|
135
|
+
assert_equal('05', text.rtype.value)
|
136
|
+
assert_equal('A single Header-Text', text.text.value)
|
137
|
+
end
|
138
|
+
def test_parse_incomplete_header_text
|
139
|
+
src = <<-EOS
|
140
|
+
"05" ""
|
141
|
+
EOS
|
142
|
+
ast = nil
|
143
|
+
assert_nothing_raised {
|
144
|
+
ast = @parser.parse(src)
|
145
|
+
}
|
146
|
+
text = ast.records.first
|
147
|
+
assert_equal('HeaderText', text.name)
|
148
|
+
end
|
149
|
+
def test_parse_position__delivery
|
150
|
+
src = <<-EOS
|
151
|
+
"10" "PositionNr" "EAN13" "IdBuyer"
|
152
|
+
"Quantity" "DeliveryDate" "PriceNetto" "PriceNetto * Quantity" "Discount"
|
153
|
+
"Discount * Quantity" "Special Discount" "Special Discount * Quantity"
|
154
|
+
"PriceBrutto" "PriceBrutto * Quantity"
|
155
|
+
EOS
|
156
|
+
# commented fields are not in the current version
|
157
|
+
ast = @parser.parse(src)
|
158
|
+
assert_instance_of(SyntaxTree, ast)
|
159
|
+
position = ast.records.first
|
160
|
+
assert_instance_of(SyntaxTree, position)
|
161
|
+
assert_equal('Position', position.name)
|
162
|
+
assert_equal('10', position.rtype.value)
|
163
|
+
assert_equal('PositionNr', position.lineno.value)
|
164
|
+
assert_equal('EAN13', position.eancode.value)
|
165
|
+
#assert_equal('IdSeller', position.sellercode.value)
|
166
|
+
assert_equal('IdBuyer', position.buyercode.value)
|
167
|
+
#assert_equal('Description 1', position.description1.value)
|
168
|
+
#assert_equal('Description 2', position.description2.value)
|
169
|
+
assert_equal('Quantity', position.qty.value)
|
170
|
+
#assert_equal('Commission', position.commission.value)
|
171
|
+
assert_equal('DeliveryDate', position.ddate.value)
|
172
|
+
#assert_equal('QuantityUnit', position.qtyunit.value)
|
173
|
+
#assert_equal('PriceUnit', position.priceunit.value)
|
174
|
+
assert_equal('PriceNetto', position.pricenettopce.value)
|
175
|
+
assert_equal('PriceNetto * Quantity', position.pricenetto.value)
|
176
|
+
assert_equal('Discount', position.discountpce.value)
|
177
|
+
assert_equal('Discount * Quantity', position.discount.value)
|
178
|
+
assert_equal('Special Discount', position.extradiscountpce.value)
|
179
|
+
assert_equal('Special Discount * Quantity', position.extradiscount.value)
|
180
|
+
assert_equal('PriceBrutto', position.pricebruttopce.value)
|
181
|
+
assert_equal('PriceBrutto * Quantity', position.pricebrutto.value)
|
182
|
+
#assert_equal('VAT', position.vat.value)
|
183
|
+
#assert_equal('OriginCountry', position.origin.value)
|
184
|
+
#assert_equal('Customs', position.customs.value)
|
185
|
+
end
|
186
|
+
def test_parse_position__invoice
|
187
|
+
src = <<-EOS
|
188
|
+
"10" "PositionNr" "EAN13" "IdBuyer"
|
189
|
+
"Quantity" "PriceNetto" "PriceNetto * Quantity" "Discount"
|
190
|
+
"Discount * Quantity" "Special Discount" "Special Discount * Quantity"
|
191
|
+
"PriceBrutto" "PriceBrutto * Quantity" "OriginCountry" "Customs"
|
192
|
+
EOS
|
193
|
+
# commented fields are not in the current version
|
194
|
+
ast = @parser.parse(src)
|
195
|
+
assert_instance_of(SyntaxTree, ast)
|
196
|
+
position = ast.records.first
|
197
|
+
assert_instance_of(SyntaxTree, position)
|
198
|
+
assert_equal('Position', position.name)
|
199
|
+
assert_equal('10', position.rtype.value)
|
200
|
+
assert_equal('PositionNr', position.lineno.value)
|
201
|
+
assert_equal('EAN13', position.eancode.value)
|
202
|
+
#assert_equal('IdSeller', position.sellercode.value)
|
203
|
+
assert_equal('IdBuyer', position.buyercode.value)
|
204
|
+
#assert_equal('Description 1', position.description1.value)
|
205
|
+
#assert_equal('Description 2', position.description2.value)
|
206
|
+
assert_equal('Quantity', position.qty.value)
|
207
|
+
#assert_equal('Commission', position.commission.value)
|
208
|
+
#assert_equal('DeliveryDate', position.ddate.value)
|
209
|
+
#assert_equal('QuantityUnit', position.qtyunit.value)
|
210
|
+
#assert_equal('PriceUnit', position.priceunit.value)
|
211
|
+
assert_equal('PriceNetto', position.pricenettopce.value)
|
212
|
+
assert_equal('PriceNetto * Quantity', position.pricenetto.value)
|
213
|
+
assert_equal('Discount', position.discountpce.value)
|
214
|
+
assert_equal('Discount * Quantity', position.discount.value)
|
215
|
+
assert_equal('Special Discount', position.extradiscountpce.value)
|
216
|
+
assert_equal('Special Discount * Quantity', position.extradiscount.value)
|
217
|
+
assert_equal('PriceBrutto', position.pricebruttopce.value)
|
218
|
+
assert_equal('PriceBrutto * Quantity', position.pricebrutto.value)
|
219
|
+
#assert_equal('VAT', position.vat.value)
|
220
|
+
assert_equal('OriginCountry', position.origin.value)
|
221
|
+
assert_equal('Customs', position.customs.value)
|
222
|
+
end
|
223
|
+
def test_parse_incomplete_position
|
224
|
+
src = <<-EOS
|
225
|
+
"10" "" "" "" "" "" "" "" "" "" "" "" "" ""
|
226
|
+
EOS
|
227
|
+
ast = nil
|
228
|
+
assert_nothing_raised {
|
229
|
+
ast = @parser.parse(src)
|
230
|
+
}
|
231
|
+
position = ast.records.first
|
232
|
+
assert_instance_of(SyntaxTree, position)
|
233
|
+
assert_equal('Position', position.name)
|
234
|
+
end
|
235
|
+
def test_parse_position_text
|
236
|
+
src = <<-EOS
|
237
|
+
"15" "A single Position-Text"
|
238
|
+
EOS
|
239
|
+
ast = @parser.parse(src)
|
240
|
+
assert_instance_of(SyntaxTree, ast)
|
241
|
+
text = ast.records.first
|
242
|
+
assert_instance_of(SyntaxTree, text)
|
243
|
+
assert_equal('PositionText', text.name)
|
244
|
+
assert_equal('15', text.rtype.value)
|
245
|
+
assert_equal('A single Position-Text', text.text.value)
|
246
|
+
end
|
247
|
+
def test_parse_incomplete_position_text
|
248
|
+
src = <<-EOS
|
249
|
+
"15" ""
|
250
|
+
EOS
|
251
|
+
ast = nil
|
252
|
+
assert_nothing_raised {
|
253
|
+
ast = @parser.parse(src)
|
254
|
+
}
|
255
|
+
text = ast.records.first
|
256
|
+
assert_equal('PositionText', text.name)
|
257
|
+
end
|
258
|
+
def test_parse_total
|
259
|
+
src = <<-EOS
|
260
|
+
"90" "Price Netto" "VAT %" "VAT Amount" "Price Brutto" "Agreement"
|
261
|
+
EOS
|
262
|
+
ast = @parser.parse(src)
|
263
|
+
assert_instance_of(SyntaxTree, ast)
|
264
|
+
total = ast.records.first
|
265
|
+
assert_instance_of(SyntaxTree, total)
|
266
|
+
assert_equal('Footer', total.name)
|
267
|
+
assert_equal('90', total.rtype.value)
|
268
|
+
assert_equal('Price Netto', total.pricenetto.value)
|
269
|
+
assert_equal('VAT %', total.vatpercent.value)
|
270
|
+
assert_equal('VAT Amount', total.vatamount.value)
|
271
|
+
assert_equal('Price Brutto', total.pricebrutto.value)
|
272
|
+
assert_equal('Agreement', total.agreement.value)
|
273
|
+
end
|
274
|
+
def test_parse_incomplete_total
|
275
|
+
src = <<-EOS
|
276
|
+
"90" "" "" "" "" ""
|
277
|
+
EOS
|
278
|
+
ast = nil
|
279
|
+
assert_nothing_raised {
|
280
|
+
ast = @parser.parse(src)
|
281
|
+
}
|
282
|
+
total = ast.records.first
|
283
|
+
assert_equal('Footer', total.name)
|
284
|
+
end
|
285
|
+
def test_parse
|
286
|
+
src = <<-EOS
|
287
|
+
"00" "Plica" "Winterhalter&Fenner" "20040630" "1621" "INVOIC" "0"
|
288
|
+
"01" "000" "00112327" "20040630" "PLVH-087/PLVH-087627" "D-473010 L" "OC" "SAD"
|
289
|
+
"02" "SE" "PLICA AG ***** TEST *********" "" "ZUERCHERSTRASSE 350" "FRAUENFELD" "8500" "CH"
|
290
|
+
"02" "CU" "WINTERHALTER + FENNER AG" "" "BIRGISTRASSE 10" "WALLISELLEN" "8304" "CH"
|
291
|
+
"02" "EP" "RUSSO GIOVANNI" "" "" "" "" ""
|
292
|
+
"02" "BY" "WINTERHALTER + FENNER AG" "" "BIRGISTRASSE 10" "WALLISELLEN" "8304" "CH"
|
293
|
+
"02" "DP" "WINTERHALTER + FENNER AG" "FILIALE LITTAU" "GROSSMATTE 11 / POSTFACH" "LITTAU" "6014" "CH"
|
294
|
+
"10" "5" "" "121.763.703" "10" "0" "0" "0" "0" "0" "0" "0" "0" "" ""
|
295
|
+
"10" "10" "" "125.001.309" "600" "115" "690" "21.85" "131.1" "0" "0" "93.15" "558.9" "CZ" "Z08151515"
|
296
|
+
"10" "15" "" "125.001.509" "60" "275" "165" "27.5" "16.5" "0" "0" "247.5" "148.5" "" ""
|
297
|
+
"10" "20" "" "125.091.409" "180" "420" "756" "0" "0" "0" "0" "420" "756" "" ""
|
298
|
+
"10" "25" "" "125.293.400" "50" "371" "185.5" "129.9" "64.95" "0" "0" "241.1" "120.55" "" ""
|
299
|
+
"10" "30" "" "125.293.600" "100" "773" "773" "270.55" "270.55" "0" "0" "502.45" "502.45" "" ""
|
300
|
+
"10" "90" "" "125.293.700" "100" "1082" "1082" "378.7" "378.7" "0" "0" "703.3" "703.3" "" ""
|
301
|
+
"90" "2789.7" "7.60" "212" "3001.7" "10 Tage 3%, 30 Tage 2%, 60 Tage netto"
|
302
|
+
EOS
|
303
|
+
assert_nothing_raised {
|
304
|
+
@parser.parse(src)
|
305
|
+
}
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# I2::TestPosition -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'i2/position'
|
9
|
+
require 'mock'
|
10
|
+
|
11
|
+
module XmlConv
|
12
|
+
module I2
|
13
|
+
class TestPosition < Test::Unit::TestCase
|
14
|
+
class ToSMock < Mock
|
15
|
+
def is_a?(klass)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
def to_s
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def setup
|
23
|
+
@position = Position.new
|
24
|
+
end
|
25
|
+
def test_attr_accessors
|
26
|
+
assert_respond_to(@position, :number)
|
27
|
+
assert_respond_to(@position, :number=)
|
28
|
+
assert_respond_to(@position, :article_ean)
|
29
|
+
assert_respond_to(@position, :article_ean=)
|
30
|
+
assert_respond_to(@position, :qty)
|
31
|
+
assert_respond_to(@position, :qty=)
|
32
|
+
assert_respond_to(@position, :delivery_date)
|
33
|
+
assert_respond_to(@position, :delivery_date=)
|
34
|
+
end
|
35
|
+
def test_to_s
|
36
|
+
@position.number = '12345'
|
37
|
+
@position.article_ean = '7654321098765'
|
38
|
+
@position.qty = 123
|
39
|
+
date = ToSMock.new('Date')
|
40
|
+
date.__next(:code=) {}
|
41
|
+
@position.delivery_date = date
|
42
|
+
date.__next(:is_a?) { |klass|
|
43
|
+
assert_equal(I2::Date, klass)
|
44
|
+
true
|
45
|
+
}
|
46
|
+
date.__next(:to_s) { "540:A Date\n" }
|
47
|
+
expected = <<-EOS
|
48
|
+
500:12345
|
49
|
+
501:7654321098765
|
50
|
+
520:123
|
51
|
+
540:A Date
|
52
|
+
EOS
|
53
|
+
assert_equal(expected, @position.to_s)
|
54
|
+
end
|
55
|
+
def test_delivery_date_writer
|
56
|
+
date = Mock.new('DeliveryDate')
|
57
|
+
date.__next(:code=) { |code|
|
58
|
+
assert_equal(:delivery, code)
|
59
|
+
}
|
60
|
+
@position.delivery_date = date
|
61
|
+
date.__verify
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,312 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Integration::TestGehI2 -- xmlconv2 -- 23.05.2006 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$: << File.expand_path('../../src', File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'test/unit'
|
8
|
+
require 'conversion/geh_bdd'
|
9
|
+
require 'conversion/bdd_i2'
|
10
|
+
require 'mock'
|
11
|
+
|
12
|
+
module XmlConv
|
13
|
+
module Integration
|
14
|
+
class TestGehI2 < Test::Unit::TestCase
|
15
|
+
def setup
|
16
|
+
@src = <<-EOS
|
17
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
18
|
+
<OrderRequest>
|
19
|
+
<OrderRequestHeader>
|
20
|
+
<OrderRequestNumber>
|
21
|
+
<BuyerOrderRequestNumber>B-999999</BuyerOrderRequestNumber>
|
22
|
+
</OrderRequestNumber>
|
23
|
+
<OrderRequestIssueDate>20060511T13:30:35</OrderRequestIssueDate>
|
24
|
+
<Purpose>
|
25
|
+
<PurposeCoded>InformationOnly</PurposeCoded>
|
26
|
+
</Purpose>
|
27
|
+
<RequestedResponse>
|
28
|
+
<RequestedResponseCoded>NoAcknowledgementNeeded</RequestedResponseCoded>
|
29
|
+
</RequestedResponse>
|
30
|
+
<OrderRequestCurrency>
|
31
|
+
<Currency>
|
32
|
+
<CurrencyCoded>CHF</CurrencyCoded>
|
33
|
+
</Currency>
|
34
|
+
</OrderRequestCurrency>
|
35
|
+
<OrderRequestLanguage>
|
36
|
+
<Language>
|
37
|
+
<LanguageCoded>ge</LanguageCoded>
|
38
|
+
</Language>
|
39
|
+
</OrderRequestLanguage>
|
40
|
+
<OrderRequestParty>
|
41
|
+
<BuyerParty>
|
42
|
+
<Party>
|
43
|
+
<PartyID>
|
44
|
+
<Identifier>
|
45
|
+
<Ident>123456</Ident>
|
46
|
+
</Identifier>
|
47
|
+
</PartyID>
|
48
|
+
<NameAddress>
|
49
|
+
<Name1>Grossauer Elektro - Handels AG</Name1>
|
50
|
+
<Name2></Name2>
|
51
|
+
<Street>Thalerstrasse 1</Street>
|
52
|
+
<City>Heiden</City>
|
53
|
+
<PostalCode>9410</PostalCode>
|
54
|
+
</NameAddress>
|
55
|
+
<OrderContact>
|
56
|
+
<Contact>
|
57
|
+
<ContactName>Danilo Lanzafame</ContactName>
|
58
|
+
</Contact>
|
59
|
+
</OrderContact>
|
60
|
+
</Party>
|
61
|
+
</BuyerParty>
|
62
|
+
<SellerParty>
|
63
|
+
<Party>
|
64
|
+
<NameAddress>
|
65
|
+
<Name1>Test AG</Name1>
|
66
|
+
<Name2>TestName2</Name2>
|
67
|
+
<Street>Brunnengasse 3</Street>
|
68
|
+
<City>8302</City>
|
69
|
+
<PostalCode>Kloten</PostalCode>
|
70
|
+
</NameAddress>
|
71
|
+
</Party>
|
72
|
+
</SellerParty>
|
73
|
+
</OrderRequestParty>
|
74
|
+
<OrderTermsOfDelivery>
|
75
|
+
<TermsOfDelivery>
|
76
|
+
<TermsOfDeliveryFunctionCoded>Other</TermsOfDeliveryFunctionCoded>
|
77
|
+
<TermsOfDeliveryFunctionCodedOther>wird abgeholt</TermsOfDeliveryFunctionCodedOther>
|
78
|
+
<TransportTermsCoded>Other</TransportTermsCoded>
|
79
|
+
<TransportTermsCodedOther>Auto EK</TransportTermsCodedOther>
|
80
|
+
<ShipmentMethodOfPaymentCoded>Other</ShipmentMethodOfPaymentCoded>
|
81
|
+
<ShipmentMethodOfPaymentCodedOther>Franko Domizil</ShipmentMethodOfPaymentCodedOther>
|
82
|
+
<Location>
|
83
|
+
<NameAddress>
|
84
|
+
<Name1>GROSSAUER Elektro-Handels AG</Name1>
|
85
|
+
<Name2>
|
86
|
+
</Name2>
|
87
|
+
<Street>Thalerstrasse 1</Street>
|
88
|
+
<City>Heiden</City>
|
89
|
+
<PostalCode>9410</PostalCode>
|
90
|
+
</NameAddress>
|
91
|
+
</Location>
|
92
|
+
</TermsOfDelivery>
|
93
|
+
</OrderTermsOfDelivery>
|
94
|
+
</OrderRequestHeader>
|
95
|
+
<OrderRequestDetail>
|
96
|
+
<OrderDetail>
|
97
|
+
<ListOfItemDetail>
|
98
|
+
<ItemDetail>
|
99
|
+
<BaseItemDetail>
|
100
|
+
<LineItemNum>
|
101
|
+
<BuyerLineItemNum>10</BuyerLineItemNum>
|
102
|
+
</LineItemNum>
|
103
|
+
<ItemIdentifiers>
|
104
|
+
<PartNumbers>
|
105
|
+
<SellerPartNumber>
|
106
|
+
<PartNum>
|
107
|
+
<SellerPartNumberPartID>123123123</SellerPartNumberPartID>
|
108
|
+
</PartNum>
|
109
|
+
</SellerPartNumber>
|
110
|
+
<BuyerPartNumber>
|
111
|
+
<PartNum>
|
112
|
+
<BuyerPartNumberPartID>123 890 390</BuyerPartNumberPartID>
|
113
|
+
</PartNum>
|
114
|
+
</BuyerPartNumber>
|
115
|
+
</PartNumbers>
|
116
|
+
<CommodityCode>
|
117
|
+
<Identifier>
|
118
|
+
<Agency>
|
119
|
+
<AgencyCoded>EAN</AgencyCoded>
|
120
|
+
</Agency>
|
121
|
+
</Identifier>
|
122
|
+
</CommodityCode>
|
123
|
+
</ItemIdentifiers>
|
124
|
+
<TotalQuantity>
|
125
|
+
<Quantity>
|
126
|
+
<QuantityValue>3</QuantityValue>
|
127
|
+
<UnitOfMeasurement>
|
128
|
+
<UOMCoded>Other</UOMCoded>
|
129
|
+
<UOMCodedOther>Other</UOMCodedOther>
|
130
|
+
</UnitOfMeasurement>
|
131
|
+
</Quantity>
|
132
|
+
</TotalQuantity>
|
133
|
+
</BaseItemDetail>
|
134
|
+
<PricingDetail>
|
135
|
+
<ListOfPrice>
|
136
|
+
<Price>
|
137
|
+
<UnitPrice>
|
138
|
+
<UnitPriceValue>780.00</UnitPriceValue>
|
139
|
+
<Currency>
|
140
|
+
<CurrencyCoded>CHF</CurrencyCoded>
|
141
|
+
</Currency>
|
142
|
+
</UnitPrice>
|
143
|
+
<PriceBasisQuantity>
|
144
|
+
<Quantity>
|
145
|
+
<UnitOfMeasurement>
|
146
|
+
<UOMCoded>100</UOMCoded>
|
147
|
+
</UnitOfMeasurement>
|
148
|
+
</Quantity>
|
149
|
+
</PriceBasisQuantity>
|
150
|
+
<PriceMultiplier>
|
151
|
+
<PriceMultiplierCoded>DiscountMultiplier</PriceMultiplierCoded>
|
152
|
+
<Multiplier>.68</Multiplier>
|
153
|
+
</PriceMultiplier>
|
154
|
+
</Price>
|
155
|
+
</ListOfPrice>
|
156
|
+
<Tax>
|
157
|
+
<TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded>
|
158
|
+
<TaxAmount>1.17</TaxAmount>
|
159
|
+
</Tax>
|
160
|
+
</PricingDetail>
|
161
|
+
<DeliveryDetail>
|
162
|
+
<ListOfScheduleLine>
|
163
|
+
<ScheduleLine>
|
164
|
+
<Quantity>
|
165
|
+
<QuantityValue>3</QuantityValue>
|
166
|
+
<UnitOfMeasurement>
|
167
|
+
<UOMCoded>STK</UOMCoded>
|
168
|
+
</UnitOfMeasurement>
|
169
|
+
</Quantity>
|
170
|
+
<RequestedDeliveryDate>20060516T13:30:35</RequestedDeliveryDate>
|
171
|
+
</ScheduleLine>
|
172
|
+
</ListOfScheduleLine>
|
173
|
+
</DeliveryDetail>
|
174
|
+
<LineItemNote></LineItemNote>
|
175
|
+
</ItemDetail>
|
176
|
+
<ItemDetail>
|
177
|
+
<BaseItemDetail>
|
178
|
+
<LineItemNum>
|
179
|
+
<BuyerLineItemNum>20</BuyerLineItemNum>
|
180
|
+
</LineItemNum>
|
181
|
+
<ItemIdentifiers>
|
182
|
+
<PartNumbers>
|
183
|
+
<SellerPartNumber>
|
184
|
+
<PartNum>
|
185
|
+
<SellerPartNumberPartID>234236837482</SellerPartNumberPartID>
|
186
|
+
</PartNum>
|
187
|
+
</SellerPartNumber>
|
188
|
+
<BuyerPartNumber>
|
189
|
+
<PartNum>
|
190
|
+
<BuyerPartNumberPartID>283 222 011</BuyerPartNumberPartID>
|
191
|
+
</PartNum>
|
192
|
+
</BuyerPartNumber>
|
193
|
+
</PartNumbers>
|
194
|
+
<CommodityCode>
|
195
|
+
<Identifier>
|
196
|
+
<Agency>
|
197
|
+
<AgencyCoded>EAN</AgencyCoded>
|
198
|
+
</Agency>
|
199
|
+
</Identifier>
|
200
|
+
</CommodityCode>
|
201
|
+
</ItemIdentifiers>
|
202
|
+
<TotalQuantity>
|
203
|
+
<Quantity>
|
204
|
+
<QuantityValue>10</QuantityValue>
|
205
|
+
<UnitOfMeasurement>
|
206
|
+
<UOMCoded>Other</UOMCoded>
|
207
|
+
<UOMCodedOther>Other</UOMCodedOther>
|
208
|
+
</UnitOfMeasurement>
|
209
|
+
</Quantity>
|
210
|
+
</TotalQuantity>
|
211
|
+
</BaseItemDetail>
|
212
|
+
<PricingDetail>
|
213
|
+
<ListOfPrice>
|
214
|
+
<Price>
|
215
|
+
<UnitPrice>
|
216
|
+
<UnitPriceValue>330.00</UnitPriceValue>
|
217
|
+
<Currency>
|
218
|
+
<CurrencyCoded>CHF</CurrencyCoded>
|
219
|
+
</Currency>
|
220
|
+
</UnitPrice>
|
221
|
+
<PriceBasisQuantity>
|
222
|
+
<Quantity>
|
223
|
+
<UnitOfMeasurement>
|
224
|
+
<UOMCoded>100</UOMCoded>
|
225
|
+
</UnitOfMeasurement>
|
226
|
+
</Quantity>
|
227
|
+
</PriceBasisQuantity>
|
228
|
+
<PriceMultiplier>
|
229
|
+
<PriceMultiplierCoded>DiscountMultiplier</PriceMultiplierCoded>
|
230
|
+
<Multiplier>.68</Multiplier>
|
231
|
+
</PriceMultiplier>
|
232
|
+
</Price>
|
233
|
+
</ListOfPrice>
|
234
|
+
<Tax>
|
235
|
+
<TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded>
|
236
|
+
<TaxAmount>1.71</TaxAmount>
|
237
|
+
</Tax>
|
238
|
+
</PricingDetail>
|
239
|
+
<DeliveryDetail>
|
240
|
+
<ListOfScheduleLine>
|
241
|
+
<ScheduleLine>
|
242
|
+
<Quantity>
|
243
|
+
<QuantityValue>10</QuantityValue>
|
244
|
+
<UnitOfMeasurement>
|
245
|
+
<UOMCoded>STK</UOMCoded>
|
246
|
+
</UnitOfMeasurement>
|
247
|
+
</Quantity>
|
248
|
+
<RequestedDeliveryDate>20060516T13:30:35</RequestedDeliveryDate>
|
249
|
+
</ScheduleLine>
|
250
|
+
</ListOfScheduleLine>
|
251
|
+
</DeliveryDetail>
|
252
|
+
<LineItemNote></LineItemNote>
|
253
|
+
</ItemDetail>
|
254
|
+
</ListOfItemDetail>
|
255
|
+
</OrderDetail>
|
256
|
+
</OrderRequestDetail>
|
257
|
+
</OrderRequest>
|
258
|
+
EOS
|
259
|
+
@xml_doc = REXML::Document.new(@src)
|
260
|
+
end
|
261
|
+
def test_geh_i2
|
262
|
+
bdd = Conversion::GehBdd.convert(@xml_doc)
|
263
|
+
i2_doc = Conversion::BddI2.convert(bdd)
|
264
|
+
result = i2_doc.to_s.split("\n")
|
265
|
+
expected = <<-EOS
|
266
|
+
001:EPIN_PL
|
267
|
+
002:ORDERX
|
268
|
+
003:220
|
269
|
+
010:#{i2_doc.filename}
|
270
|
+
100:123456
|
271
|
+
101:B-999999
|
272
|
+
201:EP
|
273
|
+
220:Danilo Lanzafame
|
274
|
+
201:BY
|
275
|
+
202:123456
|
276
|
+
220:Grossauer Elektro - Handels AG
|
277
|
+
222:Thalerstrasse 1
|
278
|
+
223:Heiden
|
279
|
+
225:9410
|
280
|
+
201:DP
|
281
|
+
220:GROSSAUER Elektro-Handels AG
|
282
|
+
222:Thalerstrasse 1
|
283
|
+
223:Heiden
|
284
|
+
225:9410
|
285
|
+
237:61
|
286
|
+
238:070
|
287
|
+
300:4
|
288
|
+
301:#{Date.today.strftime('%Y%m%d')}
|
289
|
+
500:10
|
290
|
+
501:123123123
|
291
|
+
502:123 890 390
|
292
|
+
520:3
|
293
|
+
521:Other
|
294
|
+
540:2
|
295
|
+
541:20060516
|
296
|
+
604:780.00
|
297
|
+
500:20
|
298
|
+
501:234236837482
|
299
|
+
502:283 222 011
|
300
|
+
520:10
|
301
|
+
521:Other
|
302
|
+
540:2
|
303
|
+
541:20060516
|
304
|
+
604:330.00
|
305
|
+
EOS
|
306
|
+
expected.split("\n").each_with_index { |line, index|
|
307
|
+
assert_equal(line, result[index])
|
308
|
+
}
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
end
|