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,372 @@
1
+ #!/usr/bin/env ruby
2
+ # TestGehBdd -- xmlconv2 -- 17.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 'date'
10
+
11
+ module XmlConv
12
+ module Conversion
13
+ class TestGehBdd < Test::Unit::TestCase
14
+ def setup
15
+ @src = <<-EOS
16
+ <?xml version="1.0" encoding="UTF-8"?>
17
+ <OrderRequest>
18
+ <OrderRequestHeader>
19
+ <OrderRequestNumber>
20
+ <BuyerOrderRequestNumber>B-999999</BuyerOrderRequestNumber>
21
+ </OrderRequestNumber>
22
+ <OrderRequestIssueDate>20060511T13:30:35</OrderRequestIssueDate>
23
+ <Purpose>
24
+ <PurposeCoded>InformationOnly</PurposeCoded>
25
+ </Purpose>
26
+ <RequestedResponse>
27
+ <RequestedResponseCoded>NoAcknowledgementNeeded</RequestedResponseCoded>
28
+ </RequestedResponse>
29
+ <OrderRequestCurrency>
30
+ <Currency>
31
+ <CurrencyCoded>CHF</CurrencyCoded>
32
+ </Currency>
33
+ </OrderRequestCurrency>
34
+ <OrderRequestLanguage>
35
+ <Language>
36
+ <LanguageCoded>ge</LanguageCoded>
37
+ </Language>
38
+ </OrderRequestLanguage>
39
+ <OrderRequestParty>
40
+ <BuyerParty>
41
+ <Party>
42
+ <PartyID>
43
+ <Identifier>
44
+ <Ident>123456</Ident>
45
+ </Identifier>
46
+ </PartyID>
47
+ <NameAddress>
48
+ <Name1>Grossauer Elektro - Handels AG</Name1>
49
+ <Name2></Name2>
50
+ <Street>Thalerstrasse 1</Street>
51
+ <City>Heiden</City>
52
+ <PostalCode>9410</PostalCode>
53
+ </NameAddress>
54
+ <OrderContact>
55
+ <Contact>
56
+ <ContactName>Danilo Lanzafame</ContactName>
57
+ </Contact>
58
+ </OrderContact>
59
+ </Party>
60
+ </BuyerParty>
61
+ <SellerParty>
62
+ <Party>
63
+ <NameAddress>
64
+ <Name1>Test AG</Name1>
65
+ <Name2>TestName2</Name2>
66
+ <Street>Brunnengasse 3</Street>
67
+ <City>Kloten</City>
68
+ <PostalCode>8302</PostalCode>
69
+ </NameAddress>
70
+ </Party>
71
+ </SellerParty>
72
+ </OrderRequestParty>
73
+ <OrderTermsOfDelivery>
74
+ <TermsOfDelivery>
75
+ <TermsOfDeliveryFunctionCoded>Other</TermsOfDeliveryFunctionCoded>
76
+ <TermsOfDeliveryFunctionCodedOther>V2</TermsOfDeliveryFunctionCodedOther>
77
+ <TransportTermsCoded>Other</TransportTermsCoded>
78
+ <TransportTermsCodedOther>Auto EK</TransportTermsCodedOther>
79
+ <ShipmentMethodOfPaymentCoded>Other</ShipmentMethodOfPaymentCoded>
80
+ <ShipmentMethodOfPaymentCodedOther>Franko Domizil</ShipmentMethodOfPaymentCodedOther>
81
+ <Location>
82
+ <NameAddress>
83
+ <Name1>GROSSAUER Elektro-Handels AG</Name1>
84
+ <Name2>
85
+ </Name2>
86
+ <Street>Thalerstrasse 1</Street>
87
+ <City>Heiden</City>
88
+ <PostalCode>9410</PostalCode>
89
+ </NameAddress>
90
+ </Location>
91
+ </TermsOfDelivery>
92
+ </OrderTermsOfDelivery>
93
+ </OrderRequestHeader>
94
+ <OrderRequestDetail>
95
+ <OrderDetail>
96
+ <ListOfItemDetail>
97
+ <ItemDetail>
98
+ <BaseItemDetail>
99
+ <LineItemNum>
100
+ <BuyerLineItemNum>10</BuyerLineItemNum>
101
+ </LineItemNum>
102
+ <ItemIdentifiers>
103
+ <PartNumbers>
104
+ <SellerPartNumber>
105
+ <PartNum>
106
+ <SellerPartNumberPartID>123123123</SellerPartNumberPartID>
107
+ </PartNum>
108
+ </SellerPartNumber>
109
+ <BuyerPartNumber>
110
+ <PartNum>
111
+ <BuyerPartNumberPartID>123 890 390</BuyerPartNumberPartID>
112
+ </PartNum>
113
+ </BuyerPartNumber>
114
+ </PartNumbers>
115
+ <CommodityCode>
116
+ <Identifier>
117
+ <Agency>
118
+ <AgencyCoded>EAN</AgencyCoded>
119
+ </Agency>
120
+ </Identifier>
121
+ </CommodityCode>
122
+ </ItemIdentifiers>
123
+ <TotalQuantity>
124
+ <Quantity>
125
+ <QuantityValue>3</QuantityValue>
126
+ <UnitOfMeasurement>
127
+ <UOMCoded>Other</UOMCoded>
128
+ <UOMCodedOther>Other</UOMCodedOther>
129
+ </UnitOfMeasurement>
130
+ </Quantity>
131
+ </TotalQuantity>
132
+ </BaseItemDetail>
133
+ <PricingDetail>
134
+ <ListOfPrice>
135
+ <Price>
136
+ <UnitPrice>
137
+ <UnitPriceValue>780.00</UnitPriceValue>
138
+ <Currency>
139
+ <CurrencyCoded>CHF</CurrencyCoded>
140
+ </Currency>
141
+ </UnitPrice>
142
+ <PriceBasisQuantity>
143
+ <Quantity>
144
+ <UnitOfMeasurement>
145
+ <UOMCoded>100</UOMCoded>
146
+ </UnitOfMeasurement>
147
+ </Quantity>
148
+ </PriceBasisQuantity>
149
+ <PriceMultiplier>
150
+ <PriceMultiplierCoded>DiscountMultiplier</PriceMultiplierCoded>
151
+ <Multiplier>.68</Multiplier>
152
+ </PriceMultiplier>
153
+ </Price>
154
+ </ListOfPrice>
155
+ <Tax>
156
+ <TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded>
157
+ <TaxAmount>1.17</TaxAmount>
158
+ </Tax>
159
+ </PricingDetail>
160
+ <DeliveryDetail>
161
+ <ListOfScheduleLine>
162
+ <ScheduleLine>
163
+ <Quantity>
164
+ <QuantityValue>3</QuantityValue>
165
+ <UnitOfMeasurement>
166
+ <UOMCoded>STK</UOMCoded>
167
+ </UnitOfMeasurement>
168
+ </Quantity>
169
+ <RequestedDeliveryDate>20060516T13:30:35</RequestedDeliveryDate>
170
+ </ScheduleLine>
171
+ </ListOfScheduleLine>
172
+ </DeliveryDetail>
173
+ <LineItemNote></LineItemNote>
174
+ </ItemDetail>
175
+ <ItemDetail>
176
+ <BaseItemDetail>
177
+ <LineItemNum>
178
+ <BuyerLineItemNum>20</BuyerLineItemNum>
179
+ </LineItemNum>
180
+ <ItemIdentifiers>
181
+ <PartNumbers>
182
+ <SellerPartNumber>
183
+ <PartNum>
184
+ <SellerPartNumberPartID>234236837482</SellerPartNumberPartID>
185
+ </PartNum>
186
+ </SellerPartNumber>
187
+ <BuyerPartNumber>
188
+ <PartNum>
189
+ <BuyerPartNumberPartID>283 222 011</BuyerPartNumberPartID>
190
+ </PartNum>
191
+ </BuyerPartNumber>
192
+ </PartNumbers>
193
+ <CommodityCode>
194
+ <Identifier>
195
+ <Agency>
196
+ <AgencyCoded>EAN</AgencyCoded>
197
+ </Agency>
198
+ </Identifier>
199
+ </CommodityCode>
200
+ </ItemIdentifiers>
201
+ <TotalQuantity>
202
+ <Quantity>
203
+ <QuantityValue>10</QuantityValue>
204
+ <UnitOfMeasurement>
205
+ <UOMCoded>Other</UOMCoded>
206
+ <UOMCodedOther>Other</UOMCodedOther>
207
+ </UnitOfMeasurement>
208
+ </Quantity>
209
+ </TotalQuantity>
210
+ </BaseItemDetail>
211
+ <PricingDetail>
212
+ <ListOfPrice>
213
+ <Price>
214
+ <UnitPrice>
215
+ <UnitPriceValue>330.00</UnitPriceValue>
216
+ <Currency>
217
+ <CurrencyCoded>CHF</CurrencyCoded>
218
+ </Currency>
219
+ </UnitPrice>
220
+ <PriceBasisQuantity>
221
+ <Quantity>
222
+ <UnitOfMeasurement>
223
+ <UOMCoded>100</UOMCoded>
224
+ </UnitOfMeasurement>
225
+ </Quantity>
226
+ </PriceBasisQuantity>
227
+ <PriceMultiplier>
228
+ <PriceMultiplierCoded>DiscountMultiplier</PriceMultiplierCoded>
229
+ <Multiplier>.68</Multiplier>
230
+ </PriceMultiplier>
231
+ </Price>
232
+ </ListOfPrice>
233
+ <Tax>
234
+ <TaxFunctionQualifierCoded>Tax</TaxFunctionQualifierCoded>
235
+ <TaxAmount>1.71</TaxAmount>
236
+ </Tax>
237
+ </PricingDetail>
238
+ <DeliveryDetail>
239
+ <ListOfScheduleLine>
240
+ <ScheduleLine>
241
+ <Quantity>
242
+ <QuantityValue>10</QuantityValue>
243
+ <UnitOfMeasurement>
244
+ <UOMCoded>STK</UOMCoded>
245
+ </UnitOfMeasurement>
246
+ </Quantity>
247
+ <RequestedDeliveryDate>20060516T13:30:35</RequestedDeliveryDate>
248
+ </ScheduleLine>
249
+ </ListOfScheduleLine>
250
+ </DeliveryDetail>
251
+ <LineItemNote></LineItemNote>
252
+ </ItemDetail>
253
+ </ListOfItemDetail>
254
+ </OrderDetail>
255
+ </OrderRequestDetail>
256
+ </OrderRequest>
257
+ EOS
258
+ @xml_doc = REXML::Document.new(@src)
259
+ end
260
+ def test_convert
261
+ bdd = GehBdd.convert(@xml_doc)
262
+ assert_instance_of(Model::Bdd, bdd)
263
+ bsr = bdd.bsr
264
+ assert_instance_of(Model::Bsr, bsr)
265
+ delivery = bdd.deliveries.first
266
+ assert_instance_of(Model::Delivery, delivery)
267
+ assert_equal(bsr, delivery.bsr)
268
+ end
269
+ def test_parse
270
+ document = GehBdd.parse(@src)
271
+ assert_instance_of(REXML::Document, document)
272
+ end
273
+ def test__bdd_add_xml_delivery
274
+ bdd = Model::Bdd.new
275
+ GehBdd._bdd_add_xml_delivery(bdd, @xml_doc)
276
+ delivery = bdd.deliveries.first
277
+ assert_instance_of(Model::Delivery, delivery)
278
+ assert_equal('B-999999', delivery.customer_id)
279
+ seller = delivery.seller
280
+ assert_instance_of(Model::Party, seller)
281
+ customer = delivery.customer
282
+ assert_instance_of(Model::Party, customer)
283
+ items = delivery.items
284
+ assert_equal(2, items.size)
285
+ item1 = items.first
286
+ assert_instance_of(Model::DeliveryItem, item1)
287
+ assert_equal('10', item1.line_no)
288
+ assert_equal('123123123', item1.et_nummer_id)
289
+ assert_equal('3', item1.qty)
290
+ assert_equal(Date.new(2006,5,16), item1.delivery_date)
291
+ item2 = items.last
292
+ assert_instance_of(Model::DeliveryItem, item2)
293
+ assert_equal('20', item2.line_no)
294
+ assert_equal('234236837482', item2.et_nummer_id)
295
+ assert_equal('10', item2.qty)
296
+ assert_equal(Date.new(2006,5,16), item2.delivery_date)
297
+ end
298
+ def test__bdd_add_xml_header
299
+ header = REXML::XPath.first(@xml_doc, '//OrderRequestHeader')
300
+ bdd = Model::Bdd.new
301
+ GehBdd._bdd_add_xml_header(bdd, header)
302
+ bsr = bdd.bsr
303
+ assert_instance_of(Model::Bsr, bsr)
304
+ buyer = bsr.parties.first
305
+ assert_instance_of(Model::Party, buyer)
306
+ assert_equal('123456', buyer.acc_id)
307
+ end
308
+ def test__container_add_xml_party__buyer
309
+ xml_party = REXML::XPath.first(@xml_doc, "//BuyerParty/Party")
310
+ delivery = Model::Delivery.new
311
+ GehBdd._container_add_xml_party(delivery, xml_party, 'Customer')
312
+ customer = delivery.customer
313
+ assert_instance_of(Model::Party, customer)
314
+ assert_equal('Grossauer Elektro - Handels AG', customer.name.to_s)
315
+ assert_equal('123456', customer.acc_id)
316
+ cust_addr = customer.address
317
+ assert_instance_of(Model::Address, cust_addr)
318
+ assert_equal(['Thalerstrasse 1'], cust_addr.lines)
319
+ assert_equal('Heiden', cust_addr.city)
320
+ assert_equal('9410', cust_addr.zip_code)
321
+ employee = customer.employee
322
+ assert_instance_of(Model::Party, employee)
323
+ assert_instance_of(Model::Name, employee.name)
324
+ assert_equal('Danilo Lanzafame', employee.name.last)
325
+ assert_equal('Danilo Lanzafame', employee.name.to_s)
326
+ end
327
+ def test__container_add_xml_party__seller
328
+ xml_party = REXML::XPath.first(@xml_doc, "//SellerParty/Party")
329
+ delivery = Model::Delivery.new
330
+ GehBdd._container_add_xml_party(delivery, xml_party, 'Seller')
331
+ seller = delivery.seller
332
+ assert_equal('Test AG', seller.name.to_s)
333
+ assert_instance_of(Model::Party, seller)
334
+ cust_addr = seller.address
335
+ assert_instance_of(Model::Address, cust_addr)
336
+ assert_equal(['Brunnengasse 3'], cust_addr.lines)
337
+ assert_equal('Kloten', cust_addr.city)
338
+ assert_equal('8302', cust_addr.zip_code)
339
+ end
340
+ def test__delivery_add_xml_header
341
+ header = REXML::XPath.first(@xml_doc, '//OrderRequestHeader')
342
+ delivery = Model::Delivery.new
343
+ GehBdd._delivery_add_xml_header(delivery, header)
344
+ assert_equal('B-999999', delivery.customer_id)
345
+ ship_to = delivery.customer.ship_to
346
+ assert_instance_of(Model::Party, ship_to)
347
+ assert_equal('GROSSAUER Elektro-Handels AG', ship_to.name.to_s)
348
+ assert_instance_of(Model::Party, ship_to)
349
+ ship_addr = ship_to.address
350
+ assert_instance_of(Model::Address, ship_addr)
351
+ assert_equal(['Thalerstrasse 1'], ship_addr.lines)
352
+ assert_equal('Heiden', ship_addr.city)
353
+ assert_equal('9410', ship_addr.zip_code)
354
+ end
355
+ def test__delivery_add_xml_item
356
+ xml_item = REXML::XPath.first(@xml_doc, '//ItemDetail')
357
+ delivery = Model::Delivery.new
358
+ GehBdd._delivery_add_xml_item(delivery, xml_item)
359
+ item = delivery.items.first
360
+ assert_instance_of(Model::DeliveryItem, item)
361
+ assert_equal('10', item.line_no)
362
+ assert_equal('123123123', item.et_nummer_id)
363
+ assert_equal('123 890 390', item.ids['LIEFERANTENARTIKEL'])
364
+ assert_equal('3', item.qty)
365
+ assert_equal(Date.new(2006, 5, 16), item.delivery_date)
366
+ price = item.get_price('NettoPreis')
367
+ assert_instance_of(Model::Price, price)
368
+ assert_equal('780.00', price.amount)
369
+ end
370
+ end
371
+ end
372
+ end
@@ -0,0 +1,804 @@
1
+ #!/usr/bin/env ruby
2
+ # TestI2Bdd -- xmlconv2 -- 02.06.2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../src', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/i2_bdd'
9
+ require 'mock'
10
+
11
+ module XmlConv
12
+ module Conversion
13
+ class TestI2Bdd < Test::Unit::TestCase
14
+ class IsAMock < Mock
15
+ def is_a?(klass)
16
+ true
17
+ end
18
+ end
19
+ def setup
20
+ @src = <<-EOS
21
+ "00" "Sender Identification" "Recipient Identification"
22
+ "20040628" "1159" "CONFIRM" "1"
23
+ "01" "456" "Receipt-Number" "20040627" "Order Number" "Commission"
24
+ "OC" "Employee"
25
+ "02" "BY" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
26
+ "02" "SE" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
27
+ "02" "DP" "Name1" "Name2" "Street" "City" "AddressCode" "Country"
28
+ "05" "A single Header-Text"
29
+ "05" "Another single Header-Text"
30
+ "10" "LineNo" "EAN13" "IdBuyer" "Quantity"
31
+ "DeliveryDate" "PriceNetto" "PriceNetto * Quantity" "Discount"
32
+ "Discount * Quantity" "Special Discount" "Special Discount * Quantity"
33
+ "PriceBrutto" "PriceBrutto * Quantity"
34
+ "10" "LineNo" "EAN13" "IdBuyer" "Quantity"
35
+ "DeliveryDate" "PriceNetto" "PriceNetto * Quantity" "Discount"
36
+ "Discount * Quantity" "Special Discount" "Special Discount * Quantity"
37
+ "PriceBrutto" "PriceBrutto * Quantity"
38
+ "10" "LineNo" "EAN13" "IdBuyer" "Quantity"
39
+ "DeliveryDate" "PriceNetto" "PriceNetto * Quantity" "Discount"
40
+ "Discount * Quantity" "Special Discount" "Special Discount * Quantity"
41
+ "PriceBrutto" "PriceBrutto * Quantity"
42
+ "90" "Price Netto" "VAT %" "VAT Amount" "Price Brutto" "Agreement"
43
+ EOS
44
+ end
45
+ def ast_mock(name, value)
46
+ ast = Mock.new(name)
47
+ ast.__next(:attributes) { {'value' => value} }
48
+ ast.__next(:value) { value }
49
+ ast
50
+ end
51
+ def test_convert
52
+ ast = Mock.new('AbstractSyntaxTree')
53
+ records = Mock.new('ArrayNode')
54
+ record = Mock.new('Record')
55
+ text = Mock.new('Text')
56
+ text.__next(:attributes) { {} }
57
+ record.__next(:name) { 'HeaderText' }
58
+ record.__next(:text) { text }
59
+ records.__next(:each_node) { |block| block.call(record) }
60
+ ast.__next(:records) { records }
61
+ bdd = I2Bdd.convert(ast)
62
+ assert_instance_of(Model::Bdd, bdd)
63
+ ast.__verify
64
+ records.__verify
65
+ record.__verify
66
+ text.__verify
67
+ end
68
+ def test__bdd_add_header__confirm
69
+ bdd = Mock.new('Bdd')
70
+ ast = Mock.new('AST')
71
+ date = Mock.new('Date')
72
+ time = Mock.new('Time')
73
+ mtype = Mock.new('MType')
74
+ recipient = Mock.new('Recipient')
75
+ recipient.__next(:attributes) { 'value' }
76
+ recipient.__next(:value) { 'RecipientName' }
77
+ mtype.__next(:attributes) { 'value' }
78
+ mtype.__next(:value) { 'CONFIRM' }
79
+ time.__next(:attributes) { 'value' }
80
+ time.__next(:value) { '1754' }
81
+ date.__next(:attributes) { 'value' }
82
+ date.__next(:value) { '20040628' }
83
+ ast.__next(:date) { date }
84
+ ast.__next(:time) { time }
85
+ ast.__next(:mtype) { mtype }
86
+ ast.__next(:recipient) { recipient }
87
+ bdd.__next(:bsr=) { |bsr|
88
+ assert_instance_of(Model::Bsr, bsr)
89
+ assert_equal(Time.local(2004, 6, 28, 17, 54), bsr.timestamp)
90
+ assert_equal('Return', bsr.verb)
91
+ assert_equal('Status', bsr.noun)
92
+ assert_equal(1, bsr.parties.size)
93
+ party = bsr.parties.first
94
+ assert_instance_of(Model::Party, party)
95
+ assert_equal('Customer', party.role)
96
+ name = party.name
97
+ assert_instance_of(Model::Name, name)
98
+ assert_equal('RecipientName', name.to_s)
99
+ }
100
+ I2Bdd._bdd_add_header(bdd, ast)
101
+ bdd.__verify
102
+ ast.__verify
103
+ date.__verify
104
+ time.__verify
105
+ mtype.__verify
106
+ recipient.__verify
107
+ end
108
+ def test__bdd_add_header__invoice
109
+ bdd = Mock.new('Bdd')
110
+ ast = Mock.new('AST')
111
+ date = Mock.new('Date')
112
+ time = Mock.new('Time')
113
+ mtype = Mock.new('MType')
114
+ recipient = Mock.new('Recipient')
115
+ recipient.__next(:attributes) { 'value' }
116
+ recipient.__next(:value) { 'RecipientName' }
117
+ mtype.__next(:attributes) { 'value' }
118
+ mtype.__next(:value) { 'INVOIC' }
119
+ time.__next(:attributes) { 'value' }
120
+ time.__next(:value) { '1754' }
121
+ date.__next(:attributes) { 'value' }
122
+ date.__next(:value) { '20040628' }
123
+ ast.__next(:date) { date }
124
+ ast.__next(:time) { time }
125
+ ast.__next(:mtype) { mtype }
126
+ ast.__next(:recipient) { recipient }
127
+ bdd.__next(:bsr=) { |bsr|
128
+ assert_instance_of(Model::Bsr, bsr)
129
+ assert_equal(Time.local(2004, 6, 28, 17, 54), bsr.timestamp)
130
+ assert_equal('Return', bsr.verb)
131
+ assert_equal('Invoice', bsr.noun)
132
+ assert_equal(1, bsr.parties.size)
133
+ party = bsr.parties.first
134
+ assert_instance_of(Model::Party, party)
135
+ assert_equal('Customer', party.role)
136
+ name = party.name
137
+ assert_instance_of(Model::Name, name)
138
+ assert_equal('RecipientName', name.to_s)
139
+ }
140
+ I2Bdd._bdd_add_header(bdd, ast)
141
+ bdd.__verify
142
+ ast.__verify
143
+ date.__verify
144
+ time.__verify
145
+ mtype.__verify
146
+ end
147
+ def test__bdd_add_header_text
148
+ ast = Mock.new('AST')
149
+ bdd = Mock.new('BDD')
150
+ bsr = Mock.new('BSR')
151
+ invoice = Mock.new('Invoice')
152
+ text = ast_mock('Text', 'Free Text')
153
+ invoice.__next(:free_text) {}
154
+ invoice.__next(:add_free_text) { |type, free_text|
155
+ assert_nil(type)
156
+ assert_equal('Free Text', free_text)
157
+ }
158
+ bsr.__next(:noun) { 'Invoice' }
159
+ bdd.__next(:bsr) { bsr }
160
+ bdd.__next(:invoices) { [ invoice ] }
161
+ ast.__next(:text) { text }
162
+ I2Bdd._bdd_add_header_text(bdd, ast)
163
+ ast.__verify
164
+ bdd.__verify
165
+ bsr.__verify
166
+ invoice.__verify
167
+ text.__verify
168
+ end
169
+ def test__bdd_add_commission__invalid
170
+ ast = Mock.new('AST')
171
+ bdd = Mock.new('Bdd')
172
+ bdd.__next(:bsr) { }
173
+ assert_raises(RuntimeError) {
174
+ I2Bdd._bdd_add_commission(bdd, ast)
175
+ }
176
+ bsr = Mock.new('Bsr')
177
+ bsr.__next(:noun) { }
178
+ bdd.__next(:bsr) { bsr }
179
+ assert_raises(RuntimeError) {
180
+ I2Bdd._bdd_add_commission(bdd, ast)
181
+ }
182
+ ast.__verify
183
+ bdd.__verify
184
+ bsr.__verify
185
+ end
186
+ def test__bdd_add_delivery
187
+ bdd = Mock.new('Bdd')
188
+ ast = Mock.new('AST')
189
+ reference = ast_mock('Reference', 'Reference-Id')
190
+ commission = ast_mock('Commission', 'Commission-Id')
191
+ rdate = ast_mock('RDate', '20040629')
192
+ empl = ast_mock('Employee', 'Employee Name')
193
+ ast.__next(:reference) { reference }
194
+ ast.__next(:rdate) { rdate }
195
+ ast.__next(:commission) { commission }
196
+ ast.__next(:employee) { empl }
197
+ bdd.__next(:add_delivery) { |delivery|
198
+ assert_instance_of(Model::Delivery, delivery)
199
+ assert_equal('Confirmed', delivery.status)
200
+ assert_equal(2, delivery.ids.size)
201
+ assert_equal(Date.new(2004, 6, 29), delivery.status_date)
202
+ assert_equal('Commission-Id', delivery.ids['Customer'])
203
+ assert_equal(2, delivery.parties.size)
204
+ seller = delivery.parties.first
205
+ assert_equal('Seller', seller.role)
206
+ assert_instance_of(Model::Party, seller)
207
+ customer = delivery.parties.last
208
+ assert_equal('Customer', customer.role)
209
+ assert_instance_of(Model::Party, customer)
210
+ assert_equal(1, customer.parties.size)
211
+ employee = customer.parties.first
212
+ assert_instance_of(Model::Party, employee)
213
+ assert_equal('Employee', employee.role)
214
+ name = employee.name
215
+ assert_instance_of(Model::Name, name)
216
+ assert_equal('Employee Name', name.text)
217
+ }
218
+ I2Bdd._bdd_add_delivery(bdd, ast)
219
+ bdd.__verify
220
+ ast.__verify
221
+ reference.__verify
222
+ commission.__verify
223
+ rdate.__verify
224
+ empl.__verify
225
+ end
226
+ def test__bdd_add_invoice
227
+ bdd = Mock.new('Bdd')
228
+ ast = Mock.new('AST')
229
+ reference = ast_mock('Reference', 'Reference-Id')
230
+ receipt = ast_mock('Invoice', 'Receipt-Number')
231
+ commission = ast_mock('Commission', 'Commission-Id')
232
+ rdate = ast_mock('RDate', '20040629')
233
+ empl = ast_mock('Employee', 'Employee Name')
234
+ ast.__next(:receipt) { receipt }
235
+ ast.__next(:reference) { reference }
236
+ ast.__next(:rdate) { rdate }
237
+ ast.__next(:commission) { commission }
238
+ ast.__next(:employee) { empl }
239
+ bdd.__next(:add_invoice) { |invoice|
240
+ assert_instance_of(Model::Invoice, invoice)
241
+ assert_equal(['ACC', 'Reference-Id'], invoice.delivery_id)
242
+ assert_equal(['Invoice', 'Receipt-Number'], invoice.invoice_id)
243
+ assert_equal('Invoiced', invoice.status)
244
+ assert_equal(1, invoice.ids.size)
245
+ assert_equal(Date.new(2004, 6, 29), invoice.status_date)
246
+ assert_equal('Commission-Id', invoice.ids['Customer'])
247
+ assert_equal(2, invoice.parties.size)
248
+ seller = invoice.parties.first
249
+ assert_equal('Seller', seller.role)
250
+ assert_instance_of(Model::Party, seller)
251
+ customer = invoice.parties.last
252
+ assert_equal('Customer', customer.role)
253
+ assert_instance_of(Model::Party, customer)
254
+ assert_equal(1, customer.parties.size)
255
+ employee = customer.parties.first
256
+ assert_instance_of(Model::Party, employee)
257
+ assert_equal('Employee', employee.role)
258
+ name = employee.name
259
+ assert_instance_of(Model::Name, name)
260
+ assert_equal('Employee Name', name.text)
261
+ }
262
+ I2Bdd._bdd_add_invoice(bdd, ast)
263
+ bdd.__verify
264
+ ast.__verify
265
+ reference.__verify
266
+ commission.__verify
267
+ rdate.__verify
268
+ empl.__verify
269
+ end
270
+ def test__bdd_transaction_type
271
+ bdd = Mock.new('Bdd')
272
+ bdd.__next(:bsr) { }
273
+ assert_raises(RuntimeError) { I2Bdd._bdd_transaction_type(bdd) }
274
+ bsr = Mock.new('Bsr')
275
+ bsr.__next(:noun) { }
276
+ bdd.__next(:bsr) { bsr }
277
+ assert_raises(RuntimeError) { I2Bdd._bdd_transaction_type(bdd) }
278
+ bsr.__next(:noun) { 'Invoice' }
279
+ bdd.__next(:bsr) { bsr }
280
+ assert_equal('Invoice', I2Bdd._bdd_transaction_type(bdd))
281
+ bsr.__next(:noun) { 'Delivery' }
282
+ bdd.__next(:bsr) { bsr }
283
+ assert_equal('Delivery', I2Bdd._bdd_transaction_type(bdd))
284
+ bdd.__verify
285
+ bsr.__verify
286
+ end
287
+ def test__bdd_add_address__se
288
+ bdd = Mock.new('Bdd')
289
+ bsr = Mock.new('Bsr')
290
+ delivery = Mock.new('Delivery')
291
+ seller = Mock.new('Seller')
292
+ address = Mock.new('Address')
293
+ atype = ast_mock('AType', 'SE')
294
+ name1 = ast_mock('Name1', 'Name 1')
295
+ name2 = ast_mock('Name2', 'Name 2')
296
+ street = ast_mock('Street', 'Street')
297
+ city = ast_mock('City', 'City')
298
+ code = ast_mock('Code', 'Code')
299
+ country = ast_mock('Country', 'Country')
300
+ address.__next(:atype) { atype }
301
+ address.__next(:name1) { name1 }
302
+ address.__next(:name2) { name2 }
303
+ address.__next(:street) { street }
304
+ address.__next(:city) { city }
305
+ address.__next(:code) { code }
306
+ address.__next(:country) { country }
307
+ seller.__next(:address=) { |bdd_addr|
308
+ assert_instance_of(Model::Address, bdd_addr)
309
+ assert_equal(3, bdd_addr.lines.size)
310
+ assert_equal('Name 1', bdd_addr.lines.at(0))
311
+ assert_equal('Name 2', bdd_addr.lines.at(1))
312
+ assert_equal('Street', bdd_addr.lines.at(2))
313
+ assert_equal('City', bdd_addr.city)
314
+ assert_equal('Code', bdd_addr.zip_code)
315
+ assert_equal('Country', bdd_addr.country)
316
+ }
317
+ delivery.__next(:seller) { seller }
318
+ bsr.__next(:noun) { 'Delivery' }
319
+ bdd.__next(:bsr) { bsr }
320
+ bdd.__next(:deliveries) { [delivery] }
321
+ I2Bdd._bdd_add_address(bdd, address)
322
+ bdd.__verify
323
+ bsr.__verify
324
+ delivery.__verify
325
+ address.__verify
326
+ atype.__verify
327
+ name1.__verify
328
+ name2.__verify
329
+ street.__verify
330
+ city.__verify
331
+ code.__verify
332
+ country.__verify
333
+ end
334
+ def test__bdd_add_address__cu
335
+ bdd = Mock.new('Bdd')
336
+ bsr = Mock.new('Bsr')
337
+ delivery = Mock.new('Delivery')
338
+ customer = Mock.new('Customer')
339
+ address = Mock.new('Address')
340
+ atype = ast_mock('AType', 'CU')
341
+ name1 = ast_mock('Name1', 'Name 1')
342
+ name2 = ast_mock('Name2', 'Name 2')
343
+ street = ast_mock('Street', 'Street')
344
+ city = ast_mock('City', 'City')
345
+ code = ast_mock('Code', 'Code')
346
+ country = ast_mock('Country', 'Country')
347
+ address.__next(:atype) { atype }
348
+ address.__next(:name1) { name1 }
349
+ address.__next(:name2) { name2 }
350
+ address.__next(:street) { street }
351
+ address.__next(:city) { city }
352
+ address.__next(:code) { code }
353
+ address.__next(:country) { country }
354
+ customer.__next(:address=) { |bdd_addr|
355
+ assert_instance_of(Model::Address, bdd_addr)
356
+ assert_equal(3, bdd_addr.lines.size)
357
+ assert_equal('Name 1', bdd_addr.lines.at(0))
358
+ assert_equal('Name 2', bdd_addr.lines.at(1))
359
+ assert_equal('Street', bdd_addr.lines.at(2))
360
+ assert_equal('City', bdd_addr.city)
361
+ assert_equal('Code', bdd_addr.zip_code)
362
+ assert_equal('Country', bdd_addr.country)
363
+ }
364
+ delivery.__next(:customer) { customer }
365
+ bsr.__next(:noun) { 'Delivery' }
366
+ bdd.__next(:bsr) { bsr }
367
+ bdd.__next(:deliveries) { [delivery] }
368
+ I2Bdd._bdd_add_address(bdd, address)
369
+ bdd.__verify
370
+ bsr.__verify
371
+ delivery.__verify
372
+ address.__verify
373
+ atype.__verify
374
+ name1.__verify
375
+ name2.__verify
376
+ street.__verify
377
+ city.__verify
378
+ code.__verify
379
+ country.__verify
380
+ end
381
+ def test__bdd_add_address__dp
382
+ bdd = Mock.new('Bdd')
383
+ bsr = Mock.new('Bsr')
384
+ delivery = Mock.new('Delivery')
385
+ customer = Mock.new('Customer')
386
+ address = Mock.new('Address')
387
+ atype = ast_mock('AType', 'DP')
388
+ name1 = ast_mock('Name1', 'Name 1')
389
+ name2 = ast_mock('Name2', 'Name 2')
390
+ street = ast_mock('Street', 'Street')
391
+ city = ast_mock('City', 'City')
392
+ code = ast_mock('Code', 'Code')
393
+ country = ast_mock('Country', 'Country')
394
+ address.__next(:atype) { atype }
395
+ address.__next(:name1) { name1 }
396
+ address.__next(:name2) { name2 }
397
+ address.__next(:street) { street }
398
+ address.__next(:city) { city }
399
+ address.__next(:code) { code }
400
+ address.__next(:country) { country }
401
+ customer.__next(:add_party) { |bdd_party|
402
+ assert_equal('ShipTo', bdd_party.role)
403
+ bdd_addr = bdd_party.address
404
+ assert_instance_of(Model::Address, bdd_addr)
405
+ assert_equal(3, bdd_addr.lines.size)
406
+ assert_equal('Name 1', bdd_addr.lines.at(0))
407
+ assert_equal('Name 2', bdd_addr.lines.at(1))
408
+ assert_equal('Street', bdd_addr.lines.at(2))
409
+ assert_equal('City', bdd_addr.city)
410
+ assert_equal('Code', bdd_addr.zip_code)
411
+ assert_equal('Country', bdd_addr.country)
412
+ }
413
+ delivery.__next(:customer) { customer }
414
+ bsr.__next(:noun) { 'Delivery' }
415
+ bdd.__next(:bsr) { bsr }
416
+ bdd.__next(:deliveries) { [delivery] }
417
+ I2Bdd._bdd_add_address(bdd, address)
418
+ bdd.__verify
419
+ bsr.__verify
420
+ delivery.__verify
421
+ address.__verify
422
+ atype.__verify
423
+ name1.__verify
424
+ name2.__verify
425
+ street.__verify
426
+ city.__verify
427
+ code.__verify
428
+ country.__verify
429
+ end
430
+ def test__bdd_add_address__by
431
+ bdd = Mock.new('Bdd')
432
+ bsr = Mock.new('Bsr')
433
+ delivery = Mock.new('Delivery')
434
+ customer = Mock.new('Customer')
435
+ address = Mock.new('Address')
436
+ atype = ast_mock('AType', 'BY')
437
+ name1 = ast_mock('Name1', 'Name 1')
438
+ name2 = ast_mock('Name2', 'Name 2')
439
+ street = ast_mock('Street', 'Street')
440
+ city = ast_mock('City', 'City')
441
+ code = ast_mock('Code', 'Code')
442
+ country = ast_mock('Country', 'Country')
443
+ address.__next(:atype) { atype }
444
+ address.__next(:name1) { name1 }
445
+ address.__next(:name2) { name2 }
446
+ address.__next(:street) { street }
447
+ address.__next(:city) { city }
448
+ address.__next(:code) { code }
449
+ address.__next(:country) { country }
450
+ customer.__next(:add_party) { |bdd_party|
451
+ assert_equal('BillTo', bdd_party.role)
452
+ bdd_addr = bdd_party.address
453
+ assert_instance_of(Model::Address, bdd_addr)
454
+ assert_equal(3, bdd_addr.lines.size)
455
+ assert_equal('Name 1', bdd_addr.lines.at(0))
456
+ assert_equal('Name 2', bdd_addr.lines.at(1))
457
+ assert_equal('Street', bdd_addr.lines.at(2))
458
+ assert_equal('City', bdd_addr.city)
459
+ assert_equal('Code', bdd_addr.zip_code)
460
+ assert_equal('Country', bdd_addr.country)
461
+ }
462
+ delivery.__next(:customer) { customer }
463
+ bsr.__next(:noun) { 'Delivery' }
464
+ bdd.__next(:bsr) { bsr }
465
+ bdd.__next(:deliveries) { [delivery] }
466
+ I2Bdd._bdd_add_address(bdd, address)
467
+ bdd.__verify
468
+ bsr.__verify
469
+ delivery.__verify
470
+ address.__verify
471
+ atype.__verify
472
+ name1.__verify
473
+ name2.__verify
474
+ street.__verify
475
+ city.__verify
476
+ code.__verify
477
+ country.__verify
478
+ end
479
+ def test__bdd_add_address__ep
480
+ bdd = Mock.new('Bdd')
481
+ bsr = Mock.new('Bsr')
482
+ delivery = Mock.new('Delivery')
483
+ customer = Mock.new('Customer')
484
+ address = Mock.new('Address')
485
+ employee = Mock.new('Employee')
486
+ atype = ast_mock('AType', 'EP')
487
+ name1 = ast_mock('Name1', 'Name 1')
488
+ name2 = ast_mock('Name2', 'Name 2')
489
+ street = ast_mock('Street', 'Street')
490
+ city = ast_mock('City', 'City')
491
+ code = ast_mock('Code', 'Code')
492
+ country = ast_mock('Country', 'Country')
493
+ address.__next(:atype) { atype }
494
+ address.__next(:name1) { name1 }
495
+ address.__next(:name2) { name2 }
496
+ address.__next(:street) { street }
497
+ address.__next(:city) { city }
498
+ address.__next(:code) { code }
499
+ address.__next(:country) { country }
500
+ employee.__next(:address=) { |bdd_addr|
501
+ assert_instance_of(Model::Address, bdd_addr)
502
+ assert_equal(3, bdd_addr.lines.size)
503
+ assert_equal('Name 1', bdd_addr.lines.at(0))
504
+ assert_equal('Name 2', bdd_addr.lines.at(1))
505
+ assert_equal('Street', bdd_addr.lines.at(2))
506
+ assert_equal('City', bdd_addr.city)
507
+ assert_equal('Code', bdd_addr.zip_code)
508
+ assert_equal('Country', bdd_addr.country)
509
+ }
510
+ customer.__next(:employee) { employee }
511
+ delivery.__next(:customer) { customer }
512
+ bsr.__next(:noun) { 'Delivery' }
513
+ bdd.__next(:bsr) { bsr }
514
+ bdd.__next(:deliveries) { [delivery] }
515
+ I2Bdd._bdd_add_address(bdd, address)
516
+ bdd.__verify
517
+ bsr.__verify
518
+ delivery.__verify
519
+ address.__verify
520
+ atype.__verify
521
+ name1.__verify
522
+ name2.__verify
523
+ street.__verify
524
+ city.__verify
525
+ code.__verify
526
+ country.__verify
527
+ end
528
+ def test__bdd_add_position__delivery
529
+ bdd = Mock.new('Bdd')
530
+ bsr = Mock.new('Bsr')
531
+ delivery = IsAMock.new('Delivery')
532
+ position = Mock.new('Position')
533
+ lineno = ast_mock('LineNo', '10')
534
+ eancode = ast_mock('EanCode', '1234567890987')
535
+ #sellercode = ast_mock('SellerCode', 'Seller-Code')
536
+ buyercode = ast_mock('BuyerCode', 'Buyer-Code')
537
+ #description1 = ast_mock('Description1', 'Description 1')
538
+ #description2 = ast_mock('Description2', 'Description 2')
539
+ quantity = ast_mock('Quantity', '100')
540
+ price1 = ast_mock('Price1', '123.45')
541
+ price2 = ast_mock('Price2', '246.90')
542
+ price3 = ast_mock('Price3', '3')
543
+ price4 = ast_mock('Price4', '6')
544
+ price5 = ast_mock('Price5', '1')
545
+ price6 = ast_mock('Price6', '2')
546
+ price7 = ast_mock('Price7', '119.45')
547
+ price8 = ast_mock('Price8', '238.90')
548
+ ddate = ast_mock('DDate', '20040629')
549
+ position.__next(:lineno) { lineno }
550
+ position.__next(:eancode) { eancode }
551
+ #position.__next(:sellercode) { sellercode }
552
+ position.__next(:buyercode) { buyercode }
553
+ #position.__next(:description1) { description1 }
554
+ #position.__next(:description2) { description2 }
555
+ position.__next(:qty) { quantity }
556
+ position.__next(:pricenettopce) { price1 }
557
+ position.__next(:pricenetto) { price2 }
558
+ position.__next(:discountpce) { price3 }
559
+ position.__next(:discount) { price4 }
560
+ position.__next(:extradiscountpce) { price5 }
561
+ position.__next(:extradiscount) { price6 }
562
+ position.__next(:pricebruttopce) { price7 }
563
+ position.__next(:pricebrutto) { price8 }
564
+ position.__next(:ddate) { ddate }
565
+ delivery.__next(:is_a?) { |klass|
566
+ assert_equal(Model::Invoice, klass)
567
+ false
568
+ }
569
+ delivery.__next(:add_item) { |item|
570
+ assert_instance_of(Model::DeliveryItem, item)
571
+ #assert_equal('10', item.line_no)
572
+ assert_equal(2, item.ids.size)
573
+ assert_equal('1234567890987', item.ids['EAN-Nummer'])
574
+ #assert_equal('Seller-Code', item.ids['Lieferantenartikel'])
575
+ assert_equal('Buyer-Code', item.ids['ET-Nummer'])
576
+ assert_nil(item.free_text)
577
+ #free_text = item.free_text
578
+ #assert_instance_of(Model::FreeText, free_text)
579
+ #assert_equal('Bezeichnung', free_text.type)
580
+ #assert_equal("Description 1\nDescription 2", free_text)
581
+ assert_equal('100', item.qty)
582
+ assert_equal(8, item.prices.size)
583
+ assert_equal('NettoPreis', item.prices.at(0).purpose)
584
+ assert_equal('123.45', item.prices.at(0).amount)
585
+ assert_equal('NettoPreisME', item.prices.at(1).purpose)
586
+ assert_equal('246.90', item.prices.at(1).amount)
587
+ assert_equal('Grundrabatt', item.prices.at(2).purpose)
588
+ assert_equal('3.00', item.prices.at(2).amount)
589
+ assert_equal('GrundrabattME', item.prices.at(3).purpose)
590
+ assert_equal('6.00', item.prices.at(3).amount)
591
+ assert_equal('Sonderrabatt', item.prices.at(4).purpose)
592
+ assert_equal('1.00', item.prices.at(4).amount)
593
+ assert_equal('SonderrabattME', item.prices.at(5).purpose)
594
+ assert_equal('2.00', item.prices.at(5).amount)
595
+ assert_equal('BruttoPreis', item.prices.at(6).purpose)
596
+ assert_equal('119.45', item.prices.at(6).amount)
597
+ assert_equal('BruttoPreisME', item.prices.at(7).purpose)
598
+ assert_equal('238.90', item.prices.at(7).amount)
599
+ assert_equal(Date.new(2004, 6, 29), item.delivery_date)
600
+ }
601
+ bsr.__next(:noun) { 'Delivery' }
602
+ bdd.__next(:bsr) { bsr }
603
+ bdd.__next(:deliveries) { [delivery] }
604
+ I2Bdd._bdd_add_position(bdd, position)
605
+ bdd.__verify
606
+ bsr.__verify
607
+ delivery.__verify
608
+ position.__verify
609
+ lineno.__verify
610
+ eancode.__verify
611
+ #sellercode.__verify
612
+ buyercode.__verify
613
+ #description1.__verify
614
+ #description2.__verify
615
+ price1.__verify
616
+ price2.__verify
617
+ price3.__verify
618
+ price4.__verify
619
+ price5.__verify
620
+ price6.__verify
621
+ price7.__verify
622
+ price8.__verify
623
+ ddate.__verify
624
+ end
625
+ def test__bdd_add_position__invoice
626
+ bdd = Mock.new('Bdd')
627
+ bsr = Mock.new('Bsr')
628
+ invoice = IsAMock.new('Invoice')
629
+ position = Mock.new('Position')
630
+ lineno = ast_mock('LineNo', '10')
631
+ eancode = ast_mock('EanCode', '1234567890987')
632
+ #sellercode = ast_mock('SellerCode', 'Seller-Code')
633
+ buyercode = ast_mock('BuyerCode', 'Buyer-Code')
634
+ #description1 = ast_mock('Description1', 'Description 1')
635
+ #description2 = ast_mock('Description2', 'Description 2')
636
+ quantity = ast_mock('Quantity', '100')
637
+ price1 = ast_mock('Price1', '123.45')
638
+ price2 = ast_mock('Price2', '246.90')
639
+ price3 = ast_mock('Price3', '3')
640
+ price4 = ast_mock('Price4', '6')
641
+ price5 = ast_mock('Price5', '1')
642
+ price6 = ast_mock('Price6', '2')
643
+ price7 = ast_mock('Price7', '119.45')
644
+ price8 = ast_mock('Price8', '238.90')
645
+ origin = ast_mock('Origin', 'CH')
646
+ customs = ast_mock('Customs', 'Customs-Number')
647
+ position.__next(:lineno) { lineno }
648
+ position.__next(:eancode) { eancode }
649
+ #position.__next(:sellercode) { sellercode }
650
+ position.__next(:buyercode) { buyercode }
651
+ #position.__next(:description1) { description1 }
652
+ #position.__next(:description2) { description2 }
653
+ position.__next(:qty) { quantity }
654
+ position.__next(:pricenettopce) { price1 }
655
+ position.__next(:pricenetto) { price2 }
656
+ position.__next(:discountpce) { price3 }
657
+ position.__next(:discount) { price4 }
658
+ position.__next(:extradiscountpce) { price5 }
659
+ position.__next(:extradiscount) { price6 }
660
+ position.__next(:pricebruttopce) { price7 }
661
+ position.__next(:pricebrutto) { price8 }
662
+ position.__next(:origin) { origin }
663
+ position.__next(:customs) { customs }
664
+ invoice.__next(:is_a?) { |klass|
665
+ assert_equal(Model::Invoice, klass)
666
+ true
667
+ }
668
+ invoice.__next(:add_item) { |item|
669
+ assert_instance_of(Model::InvoiceItem, item)
670
+ #assert_equal('10', item.line_no)
671
+ assert_equal(2, item.ids.size)
672
+ assert_equal('1234567890987', item.ids['EAN-Nummer'])
673
+ #assert_equal('Seller-Code', item.ids['Lieferantenartikel'])
674
+ assert_equal('Buyer-Code', item.ids['ET-Nummer'])
675
+ assert_nil(item.free_text)
676
+ #free_text = item.free_text
677
+ #assert_instance_of(Model::FreeText, free_text)
678
+ #assert_equal('Bezeichnung', free_text.type)
679
+ #assert_equal("Description 1\nDescription 2", free_text)
680
+ assert_equal('100', item.qty)
681
+ assert_equal(8, item.prices.size)
682
+ assert_equal('NettoPreis', item.prices.at(0).purpose)
683
+ assert_equal('123.45', item.prices.at(0).amount)
684
+ assert_equal('NettoPreisME', item.prices.at(1).purpose)
685
+ assert_equal('246.90', item.prices.at(1).amount)
686
+ assert_equal('Grundrabatt', item.prices.at(2).purpose)
687
+ assert_equal('3.00', item.prices.at(2).amount)
688
+ assert_equal('GrundrabattME', item.prices.at(3).purpose)
689
+ assert_equal('6.00', item.prices.at(3).amount)
690
+ assert_equal('Sonderrabatt', item.prices.at(4).purpose)
691
+ assert_equal('1.00', item.prices.at(4).amount)
692
+ assert_equal('SonderrabattME', item.prices.at(5).purpose)
693
+ assert_equal('2.00', item.prices.at(5).amount)
694
+ assert_equal('BruttoPreis', item.prices.at(6).purpose)
695
+ assert_equal('119.45', item.prices.at(6).amount)
696
+ assert_equal('BruttoPreisME', item.prices.at(7).purpose)
697
+ assert_equal('238.90', item.prices.at(7).amount)
698
+ assert_equal(2, item.part_infos.size)
699
+ origin_info = item.part_infos.first
700
+ assert_instance_of(Model::PartInfo, origin_info)
701
+ assert_equal('Ursprungsland', origin_info.dimension)
702
+ assert_equal('CH', origin_info.value)
703
+ customs_info = item.part_infos.last
704
+ assert_instance_of(Model::PartInfo, customs_info)
705
+ assert_equal('Zolltarifnr.', customs_info.dimension)
706
+ assert_equal('Customs-Number', customs_info.value)
707
+ }
708
+ bsr.__next(:noun) { 'Invoice' }
709
+ bdd.__next(:bsr) { bsr }
710
+ bdd.__next(:invoices) { [invoice] }
711
+ I2Bdd._bdd_add_position(bdd, position)
712
+ bdd.__verify
713
+ bsr.__verify
714
+ invoice.__verify
715
+ position.__verify
716
+ lineno.__verify
717
+ eancode.__verify
718
+ #sellercode.__verify
719
+ buyercode.__verify
720
+ #description1.__verify
721
+ #description2.__verify
722
+ price1.__verify
723
+ price2.__verify
724
+ price3.__verify
725
+ price4.__verify
726
+ price5.__verify
727
+ price6.__verify
728
+ price7.__verify
729
+ price8.__verify
730
+ end
731
+ def test__bdd_add_footer
732
+ ast = Mock.new('AST')
733
+ bdd = Mock.new('Bdd')
734
+ bsr = Mock.new('Bsr')
735
+ delivery = Mock.new('Delivery')
736
+ pricenetto = ast_mock('PriceNetto', '100')
737
+ vatpercent = ast_mock('VatPercent', '7.6')
738
+ vatamount = ast_mock('VatAmount', '7.6')
739
+ pricebrutto = ast_mock('PriceBrutto', '107.6')
740
+ agreement = ast_mock('Agreement', 'Agreement-Text')
741
+ delivery.__next(:add_price) { |price|
742
+ assert_instance_of(Model::Price, price)
743
+ assert_equal('SummePositionen', price.purpose)
744
+ assert_equal('100.00', price.amount)
745
+ }
746
+ delivery.__next(:add_price) { |price|
747
+ assert_instance_of(Model::Price, price)
748
+ assert_equal('MehrwertsteuerPct', price.purpose)
749
+ assert_equal('7.60', price.amount)
750
+ }
751
+ delivery.__next(:add_price) { |price|
752
+ assert_instance_of(Model::Price, price)
753
+ assert_equal('Mehrwertsteuer', price.purpose)
754
+ assert_equal('7.60', price.amount)
755
+ }
756
+ delivery.__next(:add_price) { |price|
757
+ assert_instance_of(Model::Price, price)
758
+ assert_equal('Endbetrag', price.purpose)
759
+ assert_equal('107.60', price.amount)
760
+ }
761
+ delivery.__next(:agreement=) { |bdd_agr|
762
+ assert_instance_of(Model::Agreement, bdd_agr)
763
+ assert_equal('Agreement-Text', bdd_agr.terms_cond)
764
+ }
765
+ bsr.__next(:noun) { 'Delivery' }
766
+ bdd.__next(:bsr) { bsr }
767
+ bdd.__next(:deliveries) { [delivery] }
768
+ ast.__next(:pricenetto) { pricenetto }
769
+ ast.__next(:vatpercent) { vatpercent }
770
+ ast.__next(:vatamount) { vatamount }
771
+ ast.__next(:pricebrutto) { pricebrutto }
772
+ ast.__next(:agreement) { agreement }
773
+ I2Bdd._bdd_add_footer(bdd, ast)
774
+ ast.__verify
775
+ bdd.__verify
776
+ bsr.__verify
777
+ delivery.__verify
778
+ pricenetto.__verify
779
+ vatpercent.__verify
780
+ vatamount.__verify
781
+ pricebrutto.__verify
782
+ end
783
+ def test__select_bdd_transaction
784
+ bdd = Mock.new('Bdd')
785
+ bsr = Mock.new('Bsr')
786
+ bdd.__next(:bsr) { bsr }
787
+ bsr.__next(:noun) { 'Delivery' }
788
+ bdd.__next(:deliveries) { ['Delivery 1', 'Delivery 2'] }
789
+ assert_equal('Delivery 2', I2Bdd._select_bdd_transaction(bdd))
790
+ bdd.__next(:bsr) { bsr }
791
+ bsr.__next(:noun) { 'Invoice' }
792
+ bdd.__next(:invoices) { ['Invoice 1', 'Invoice 2'] }
793
+ assert_equal('Invoice 2', I2Bdd._select_bdd_transaction(bdd))
794
+ bdd.__verify
795
+ bsr.__verify
796
+ end
797
+ def test_parse
798
+ ast = I2Bdd.parse(@src)
799
+ assert_instance_of(SyntaxTree, ast)
800
+ assert_equal(11, ast.records.size)
801
+ end
802
+ end
803
+ end
804
+ end