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
data/test/suite.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# TestSuite -- xmlconv2 -- 01.06.2004 -- hwyss@ywesee.com
|
3
|
+
|
4
|
+
$: << File.dirname(File.expand_path(__FILE__))
|
5
|
+
|
6
|
+
current_dir = File.dirname(__FILE__)
|
7
|
+
Dir.foreach(current_dir) { |dirname|
|
8
|
+
dirpath = File.expand_path(dirname, current_dir)
|
9
|
+
if(/^test_/o.match(dirname) && (File.ftype(dirpath) == 'directory'))
|
10
|
+
Dir.foreach(dirpath) { |filename|
|
11
|
+
if(/\.rb$/o.match(filename))
|
12
|
+
require "#{dirname}/#{filename}"
|
13
|
+
end
|
14
|
+
}
|
15
|
+
end
|
16
|
+
}
|
@@ -0,0 +1,533 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Conversion::TestBddGeh -- xmlconv2 -- 18.05.2006 -- 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/bdd_geh'
|
9
|
+
require 'date'
|
10
|
+
require 'flexmock'
|
11
|
+
require 'mock'
|
12
|
+
|
13
|
+
module XmlConv
|
14
|
+
module Conversion
|
15
|
+
class TestBddGeh < Test::Unit::TestCase
|
16
|
+
def test_convert__delivery
|
17
|
+
bdd = FlexMock.new
|
18
|
+
bsr = FlexMock.new
|
19
|
+
delivery = FlexMock.new
|
20
|
+
delivery.mock_handle(:status_date) { }
|
21
|
+
delivery.mock_handle(:customer_id) { '12345' }
|
22
|
+
delivery.mock_handle(:reference_id) { '54321' }
|
23
|
+
delivery.mock_handle(:parties) { [] }
|
24
|
+
delivery.mock_handle(:items) { [] }
|
25
|
+
delivery.mock_handle(:prices) { [] }
|
26
|
+
delivery.mock_handle(:free_text) { }
|
27
|
+
delivery.mock_handle(:agreement) { }
|
28
|
+
delivery.mock_handle(:seller) { }
|
29
|
+
bsr.mock_handle(:timestamp) { }
|
30
|
+
bsr.mock_handle(:verb) { }
|
31
|
+
bsr.mock_handle(:noun) { }
|
32
|
+
bsr.mock_handle(:parties) { [] }
|
33
|
+
bdd.mock_handle(:bsr) { bsr }
|
34
|
+
bdd.mock_handle(:deliveries) { [delivery] }
|
35
|
+
bdd.mock_handle(:invoices) { [] }
|
36
|
+
xml_doc = BddGeh.convert(bdd).first
|
37
|
+
assert_instance_of(REXML::Document, xml_doc)
|
38
|
+
decl = "<?xml version='1.0' encoding='UTF-8'?>"
|
39
|
+
assert_equal(decl, xml_doc.xml_decl.to_s)
|
40
|
+
root = xml_doc.root
|
41
|
+
assert_instance_of(REXML::Element, root)
|
42
|
+
assert_equal('OrderResponse', root.name)
|
43
|
+
assert_equal(2, root.elements.size)
|
44
|
+
xml_header = root.elements[1]
|
45
|
+
assert_instance_of(REXML::Element, xml_header)
|
46
|
+
assert_equal('OrderResponseHeader', xml_header.name)
|
47
|
+
xml_delivery = root.elements[2]
|
48
|
+
assert_instance_of(REXML::Element, xml_delivery)
|
49
|
+
assert_equal('OrderResponseDetail', xml_delivery.name)
|
50
|
+
xml_responselist = xml_delivery.elements[1]
|
51
|
+
assert_equal('ListOfOrderResponseItemDetail', xml_responselist.name)
|
52
|
+
end
|
53
|
+
def test__xml_add_bdd_delivery
|
54
|
+
delivery = FlexMock.new
|
55
|
+
party = FlexMock.new
|
56
|
+
name = FlexMock.new
|
57
|
+
agreement = FlexMock.new
|
58
|
+
agreement.mock_handle(:terms_cond) { 'Terms and Conditions' }
|
59
|
+
name.mock_handle(:text) { 'NameText' }
|
60
|
+
name.mock_handle(:to_s) { 'NameString' }
|
61
|
+
party.mock_handle(:role) { 'Seller' }
|
62
|
+
party.mock_handle(:party_id) { '12345' }
|
63
|
+
party.mock_handle(:name) { name }
|
64
|
+
party.mock_handle(:address) { }
|
65
|
+
party.mock_handle(:employee) { }
|
66
|
+
delivery.mock_handle(:customer_id) { '0000405477' }
|
67
|
+
delivery.mock_handle(:status) { 'Confirmed' }
|
68
|
+
delivery.mock_handle(:status_date) { Time.local(2006, 5, 11, 2, 7, 19) }
|
69
|
+
delivery.mock_handle(:reference_id) { 'B-1299545' }
|
70
|
+
delivery.mock_handle(:parties) { [party] }
|
71
|
+
delivery.mock_handle(:items) { [] }
|
72
|
+
delivery.mock_handle(:prices) { [] }
|
73
|
+
delivery.mock_handle(:free_text) { }
|
74
|
+
delivery.mock_handle(:seller) { }
|
75
|
+
delivery.mock_handle(:agreement) { agreement }
|
76
|
+
response = REXML::Element.new('OrderResponse')
|
77
|
+
BddGeh._xml_add_bdd_delivery(response, delivery)
|
78
|
+
assert_equal(2, response.elements.size)
|
79
|
+
xml_header = response.elements[1]
|
80
|
+
assert_equal(4, xml_header.elements.size)
|
81
|
+
end
|
82
|
+
def test__xml_add_delivery_header
|
83
|
+
delivery = FlexMock.new
|
84
|
+
party1 = FlexMock.new
|
85
|
+
party2 = FlexMock.new
|
86
|
+
party3 = FlexMock.new
|
87
|
+
name = FlexMock.new
|
88
|
+
seller_id = nil
|
89
|
+
name.mock_handle(:text) { 'NameText' }
|
90
|
+
name.mock_handle(:to_s) { 'NameString' }
|
91
|
+
party1.mock_handle(:role) { 'Seller' }
|
92
|
+
party1.mock_handle(:party_id) { seller_id }
|
93
|
+
party1.mock_handle(:name) { name }
|
94
|
+
party1.mock_handle(:address) { }
|
95
|
+
party1.mock_handle(:employee) { }
|
96
|
+
party1.mock_handle(:parties) { [] }
|
97
|
+
party2.mock_handle(:role) { 'Customer' }
|
98
|
+
party2.mock_handle(:party_id) { '54321' }
|
99
|
+
party2.mock_handle(:name) { name }
|
100
|
+
party2.mock_handle(:address) { }
|
101
|
+
party2.mock_handle(:employee) { }
|
102
|
+
party3.mock_handle(:role) { 'BillTo' }
|
103
|
+
party3.mock_handle(:party_id) { '54321' }
|
104
|
+
party3.mock_handle(:name) { name }
|
105
|
+
party3.mock_handle(:address) { }
|
106
|
+
party3.mock_handle(:employee) { }
|
107
|
+
party3.mock_handle(:parties) { [] }
|
108
|
+
party2.mock_handle(:parties) { [party3] }
|
109
|
+
delivery.mock_handle(:customer_id) { '0000405477' }
|
110
|
+
delivery.mock_handle(:status) { 'Confirmed' }
|
111
|
+
delivery.mock_handle(:status_date) { Time.local(2006, 5, 11, 2, 7, 19) }
|
112
|
+
delivery.mock_handle(:reference_id) { 'B-1299545' }
|
113
|
+
delivery.mock_handle(:parties) { [party1, party2] }
|
114
|
+
delivery.mock_handle(:seller) { party1 }
|
115
|
+
party1.mock_handle(:add_id, 1) { |domain, id|
|
116
|
+
assert_equal('ACC', domain)
|
117
|
+
assert_equal(663, id)
|
118
|
+
seller_id = id
|
119
|
+
}
|
120
|
+
response = REXML::Element.new('OrderResponse')
|
121
|
+
BddGeh._xml_add_delivery_header(response, delivery)
|
122
|
+
assert_equal(1, response.elements.size)
|
123
|
+
xml_header = response.elements[1]
|
124
|
+
xml_response_id = xml_header.elements[1]
|
125
|
+
expected = '<OrderResponseNumber><BuyerOrderResponseNumber>B-1299545</BuyerOrderResponseNumber></OrderResponseNumber>'
|
126
|
+
assert_equal(expected, xml_response_id.to_s)
|
127
|
+
xml_reference_id = xml_header.elements[2]
|
128
|
+
expected = '<OrderReference><Reference><RefNum>0000405477</RefNum></Reference></OrderReference>'
|
129
|
+
assert_equal(expected, xml_reference_id.to_s)
|
130
|
+
xml_issue_date = xml_header.elements[3]
|
131
|
+
expected = '<OrderResponseIssueDate>20060511020719</OrderResponseIssueDate>'
|
132
|
+
assert_equal(expected, xml_issue_date.to_s)
|
133
|
+
xml_party1 = xml_header.elements[4]
|
134
|
+
assert_equal('SellerParty', xml_party1.name)
|
135
|
+
seller_id = xml_party1.elements[1]
|
136
|
+
expected = '<Party><PartyID><Identifier><Ident>663</Ident></Identifier></PartyID></Party>'
|
137
|
+
assert_equal(expected, seller_id.to_s)
|
138
|
+
xml_party2 = xml_header.elements[5]
|
139
|
+
assert_equal('BuyerParty', xml_party2.name)
|
140
|
+
assert_equal(5, xml_header.elements.size)
|
141
|
+
party1.mock_verify
|
142
|
+
end
|
143
|
+
def test__xml_add_bdd_party
|
144
|
+
party1 = FlexMock.new
|
145
|
+
party2 = FlexMock.new
|
146
|
+
xml = FlexMock.new
|
147
|
+
address = FlexMock.new
|
148
|
+
name = FlexMock.new
|
149
|
+
name.mock_handle(:first) { 'Grossauer Elektro-Handels AG' }
|
150
|
+
name.mock_handle(:last) { }
|
151
|
+
employee = FlexMock.new
|
152
|
+
employee.mock_handle(:role) { 'Employee' }
|
153
|
+
employee.mock_handle(:ids) { [] }
|
154
|
+
employee.mock_handle(:name) { 'Danilo Lanzafame' }
|
155
|
+
employee.mock_handle(:address) { }
|
156
|
+
employee.mock_handle(:parties) { [] }
|
157
|
+
address.mock_handle(:lines) { ['Grossauer Elektro-Handels AG',
|
158
|
+
'Address Line'] }
|
159
|
+
address.mock_handle(:city) { 'Heiden' }
|
160
|
+
address.mock_handle(:zip_code) { '9410' }
|
161
|
+
address.mock_handle(:country) { 'CH' }
|
162
|
+
party1.mock_handle(:role) { 'Customer' }
|
163
|
+
party1.mock_handle(:parties) { [party2] }
|
164
|
+
party1.mock_handle(:name) { 'Grossauer Elektro-Handels AG' }
|
165
|
+
party1.mock_handle(:employee) { employee }
|
166
|
+
party2.mock_handle(:role) { 'ShipTo' }
|
167
|
+
party2.mock_handle(:party_id) { 105446 }
|
168
|
+
party2.mock_handle(:address) { address }
|
169
|
+
xml.mock_handle(:add_element, 1) { |xml_party|
|
170
|
+
assert_instance_of(REXML::Element, xml_party)
|
171
|
+
expected = '<ShipToParty><Party><PartyID><Identifier><Ident>105446</Ident></Identifier></PartyID><NameAddress><Name1>Grossauer Elektro-Handels AG</Name1><Street>Address Line</Street><PostalCode>9410</PostalCode><City>Heiden</City></NameAddress><OrderContact><Contact><ContactName>Danilo Lanzafame</ContactName></Contact></OrderContact></Party></ShipToParty>'
|
172
|
+
assert_equal(expected, xml_party.to_s)
|
173
|
+
}
|
174
|
+
BddGeh._xml_add_bdd_party(xml, party1)
|
175
|
+
xml.mock_verify
|
176
|
+
end
|
177
|
+
def test__xml_add_bdd_party__seller
|
178
|
+
party1 = FlexMock.new
|
179
|
+
xml = FlexMock.new
|
180
|
+
address = FlexMock.new
|
181
|
+
name = FlexMock.new
|
182
|
+
name.mock_handle(:first) { }
|
183
|
+
name.mock_handle(:last) { }
|
184
|
+
address.mock_handle(:lines) { ['Test AG', 'TestName2',
|
185
|
+
'Brunnengasse 3'] }
|
186
|
+
address.mock_handle(:city) { 'Kloten' }
|
187
|
+
address.mock_handle(:zip_code) { '8302' }
|
188
|
+
address.mock_handle(:country) { 'CH' }
|
189
|
+
party1.mock_handle(:role) { 'Seller' }
|
190
|
+
party1.mock_handle(:parties) { [] }
|
191
|
+
party1.mock_handle(:name) { name }
|
192
|
+
party1.mock_handle(:employee) { }
|
193
|
+
party1.mock_handle(:address) { address }
|
194
|
+
party1.mock_handle(:party_id) { 667 }
|
195
|
+
xml.mock_handle(:add_element, 1) { |xml_party|
|
196
|
+
assert_instance_of(REXML::Element, xml_party)
|
197
|
+
expected = '<SellerParty><Party><PartyID><Identifier><Ident>667</Ident></Identifier></PartyID><NameAddress><Name1>Test AG</Name1><Name2>TestName2</Name2><Street>Brunnengasse 3</Street><PostalCode>8302</PostalCode><City>Kloten</City></NameAddress></Party></SellerParty>'
|
198
|
+
assert_equal(expected, xml_party.to_s)
|
199
|
+
}
|
200
|
+
BddGeh._xml_add_bdd_party(xml, party1)
|
201
|
+
xml.mock_verify
|
202
|
+
end
|
203
|
+
def test__xml_add_item
|
204
|
+
xml = FlexMock.new
|
205
|
+
item = FlexMock.new
|
206
|
+
part_info = FlexMock.new
|
207
|
+
price1 = FlexMock.new
|
208
|
+
price1.mock_handle(:amount) { '12.345' }
|
209
|
+
part_info.mock_handle(:dimension) { 'the Dimension' }
|
210
|
+
part_info.mock_handle(:value) { 'the Value' }
|
211
|
+
item.mock_handle(:line_no) { '10' }
|
212
|
+
item.mock_handle(:ids) { [
|
213
|
+
['EAN-Nummer', '123123123'],
|
214
|
+
['ET-Nummer', '123 890 390'],
|
215
|
+
] }
|
216
|
+
item.mock_handle(:part_infos) { [part_info] }
|
217
|
+
item.mock_handle(:qty) { 3 }
|
218
|
+
item.mock_handle(:get_price) { |purpose|
|
219
|
+
{
|
220
|
+
'BruttoPreisME' => price1,
|
221
|
+
}[purpose]
|
222
|
+
}
|
223
|
+
item.mock_handle(:free_text) { }
|
224
|
+
item.mock_handle(:delivery_date) { Date.new(2006,5,16) }
|
225
|
+
xml.mock_handle(:add_element) { |xml_item|
|
226
|
+
assert_instance_of(REXML::Element, xml_item)
|
227
|
+
assert_equal('OrderResponseItemDetail', xml_item.name)
|
228
|
+
assert_equal(3, xml_item.elements.size)
|
229
|
+
xml_base = xml_item.elements[1]
|
230
|
+
assert_equal('BaseItemDetail', xml_base.name)
|
231
|
+
xml_pricing = xml_item.elements[2]
|
232
|
+
assert_equal('PricingDetail', xml_pricing.name)
|
233
|
+
xml_delivery = xml_item.elements[3]
|
234
|
+
assert_equal('DeliveryDetail', xml_delivery.name)
|
235
|
+
}
|
236
|
+
BddGeh._xml_add_item(xml, item)
|
237
|
+
xml.mock_verify
|
238
|
+
end
|
239
|
+
def test__xml_add_base_item_detail
|
240
|
+
xml = FlexMock.new
|
241
|
+
item = FlexMock.new
|
242
|
+
price = FlexMock.new
|
243
|
+
item.mock_handle(:line_no) { '10' }
|
244
|
+
item.mock_handle(:ids) { [
|
245
|
+
['EAN-Nummer', '123123123'],
|
246
|
+
['ET-Nummer', '123 890 390'],
|
247
|
+
] }
|
248
|
+
item.mock_handle(:qty) { 3 }
|
249
|
+
xml.mock_handle(:add_element) { |xml_detail|
|
250
|
+
assert_instance_of(REXML::Element, xml_detail)
|
251
|
+
assert_equal('BaseItemDetail', xml_detail.name)
|
252
|
+
assert_equal(3, xml_detail.elements.size)
|
253
|
+
xml_line_num = xml_detail.elements[1]
|
254
|
+
expected = '<LineItemNum><BuyerLineItemNum>10</BuyerLineItemNum></LineItemNum>'
|
255
|
+
assert_equal(expected, xml_line_num.to_s)
|
256
|
+
xml_ids = xml_detail.elements[2]
|
257
|
+
expected = '<ItemIdentifiers><PartNumbers><SellerPartNumber><PartNum><PartID>123123123</PartID></PartNum></SellerPartNumber><BuyerPartNumber><PartNum><PartID>123 890 390</PartID></PartNum></BuyerPartNumber></PartNumbers></ItemIdentifiers>'
|
258
|
+
assert_equal(expected, xml_ids.to_s)
|
259
|
+
xml_qty = xml_detail.elements[3]
|
260
|
+
expected = '<TotalQuantity><Quantity><QuantityValue>3</QuantityValue><UnitOfMeasurement><UOMCoded>EA</UOMCoded></UnitOfMeasurement></Quantity></TotalQuantity>'
|
261
|
+
assert_equal(expected, xml_qty.to_s)
|
262
|
+
}
|
263
|
+
BddGeh._xml_add_base_item_detail(xml, item)
|
264
|
+
xml.mock_verify
|
265
|
+
end
|
266
|
+
def test__xml_add_pricing_detail
|
267
|
+
xml = FlexMock.new
|
268
|
+
item = FlexMock.new
|
269
|
+
part_info = FlexMock.new
|
270
|
+
price1 = FlexMock.new
|
271
|
+
price1.mock_handle(:amount) { '32.33' }
|
272
|
+
price2 = FlexMock.new
|
273
|
+
price2.mock_handle(:amount) { '96.99' }
|
274
|
+
item.mock_handle(:part_infos) { [part_info] }
|
275
|
+
item.mock_handle(:qty) { 3 }
|
276
|
+
item.mock_handle(:get_price) { |purpose|
|
277
|
+
{
|
278
|
+
'NettoPreis' => price1,
|
279
|
+
'NettoPreisME' => price2,
|
280
|
+
}[purpose]
|
281
|
+
}
|
282
|
+
item.mock_handle(:free_text) { }
|
283
|
+
xml.mock_handle(:add_element) { |xml_item|
|
284
|
+
assert_instance_of(REXML::Element, xml_item)
|
285
|
+
assert_equal('PricingDetail', xml_item.name)
|
286
|
+
assert_equal(2, xml_item.elements.size)
|
287
|
+
xml_list = xml_item.elements[1]
|
288
|
+
expected = '<ListOfPrice><Price><UnitPrice><Currency><CurrencyCoded>CHF</CurrencyCoded></Currency><UnitPriceValue>32.33</UnitPriceValue></UnitPrice></Price></ListOfPrice>'
|
289
|
+
assert_equal(expected, xml_list.to_s)
|
290
|
+
xml_value = xml_item.elements[2]
|
291
|
+
expected = '<TotalValue><MonetaryValue><MonetaryAmount>96.99</MonetaryAmount></MonetaryValue></TotalValue>'
|
292
|
+
assert_equal(expected, xml_value.to_s)
|
293
|
+
}
|
294
|
+
BddGeh._xml_add_pricing_detail(xml, item)
|
295
|
+
xml.mock_verify
|
296
|
+
end
|
297
|
+
def test__xml_add_delivery_detail
|
298
|
+
xml = FlexMock.new
|
299
|
+
item = FlexMock.new
|
300
|
+
part_info = FlexMock.new
|
301
|
+
item.mock_handle(:delivery_date) { Date.new(2006,5,16) }
|
302
|
+
xml.mock_handle(:add_element) { |xml_item|
|
303
|
+
assert_instance_of(REXML::Element, xml_item)
|
304
|
+
expected = '<DeliveryDetail><ListOfScheduleLine><ScheduleLine><RequestedDeliveryDate>20060516</RequestedDeliveryDate></ScheduleLine></ListOfScheduleLine></DeliveryDetail>'
|
305
|
+
assert_equal(expected, xml_item.to_s)
|
306
|
+
}
|
307
|
+
BddGeh._xml_add_delivery_detail(xml, item)
|
308
|
+
xml.mock_verify
|
309
|
+
end
|
310
|
+
def test_convert__invoice
|
311
|
+
bdd = FlexMock.new
|
312
|
+
bsr = FlexMock.new
|
313
|
+
invoice = FlexMock.new
|
314
|
+
invoice.mock_handle(:status_date) { }
|
315
|
+
invoice.mock_handle(:invoice_id) { ['Invoice', '12345'] }
|
316
|
+
invoice.mock_handle(:customer_id) { '54321' }
|
317
|
+
invoice.mock_handle(:seller) { }
|
318
|
+
invoice.mock_handle(:items) { [] }
|
319
|
+
invoice.mock_handle(:get_price) { }
|
320
|
+
invoice.mock_handle(:free_text) { }
|
321
|
+
invoice.mock_handle(:agreement) { }
|
322
|
+
bsr.mock_handle(:timestamp) { }
|
323
|
+
bsr.mock_handle(:verb) { }
|
324
|
+
bsr.mock_handle(:noun) { }
|
325
|
+
bsr.mock_handle(:parties) { [] }
|
326
|
+
bdd.mock_handle(:bsr) { bsr }
|
327
|
+
bdd.mock_handle(:deliveries) { [] }
|
328
|
+
bdd.mock_handle(:invoices) { [ invoice ] }
|
329
|
+
xml_doc = BddGeh.convert(bdd).first
|
330
|
+
assert_instance_of(REXML::Document, xml_doc)
|
331
|
+
decl = "<?xml version='1.0' encoding='UTF-8'?>"
|
332
|
+
assert_equal(decl, xml_doc.xml_decl.to_s)
|
333
|
+
root = xml_doc.root
|
334
|
+
assert_instance_of(REXML::Element, root)
|
335
|
+
assert_equal('Invoice', root.name)
|
336
|
+
xml_header = root.elements[1]
|
337
|
+
assert_instance_of(REXML::Element, xml_header)
|
338
|
+
assert_equal('InvoiceHeader', xml_header.name)
|
339
|
+
xml_delivery = root.elements[2]
|
340
|
+
assert_instance_of(REXML::Element, xml_delivery)
|
341
|
+
assert_equal('InvoiceDetail', xml_delivery.name)
|
342
|
+
xml_summary = root.elements[3]
|
343
|
+
assert_instance_of(REXML::Element, xml_summary)
|
344
|
+
assert_equal('InvoiceSummary', xml_summary.name)
|
345
|
+
assert_equal(3, root.elements.size)
|
346
|
+
end
|
347
|
+
def test__xml_add_bdd_invoice
|
348
|
+
delivery = FlexMock.new
|
349
|
+
party = FlexMock.new
|
350
|
+
name = FlexMock.new
|
351
|
+
agreement = FlexMock.new
|
352
|
+
agreement.mock_handle(:terms_cond) { 'Terms and Conditions' }
|
353
|
+
name.mock_handle(:text) { 'NameText' }
|
354
|
+
name.mock_handle(:to_s) { 'NameString' }
|
355
|
+
party.mock_handle(:role) { 'Seller' }
|
356
|
+
party.mock_handle(:party_id) { '12345' }
|
357
|
+
party.mock_handle(:name) { name }
|
358
|
+
party.mock_handle(:address) { }
|
359
|
+
party.mock_handle(:employee) { }
|
360
|
+
delivery.mock_handle(:invoice_id) { ['Invoice', '0000405477'] }
|
361
|
+
delivery.mock_handle(:status) { 'Confirmed' }
|
362
|
+
delivery.mock_handle(:status_date) { Time.local(2006, 5, 11, 2, 7, 19) }
|
363
|
+
delivery.mock_handle(:customer_id) { 'B-1299545' }
|
364
|
+
delivery.mock_handle(:seller) { party }
|
365
|
+
delivery.mock_handle(:items) { [] }
|
366
|
+
delivery.mock_handle(:get_price) { }
|
367
|
+
delivery.mock_handle(:free_text) { }
|
368
|
+
delivery.mock_handle(:agreement) { agreement }
|
369
|
+
invoice = REXML::Element.new('Invoice')
|
370
|
+
BddGeh._xml_add_bdd_invoice(invoice, delivery)
|
371
|
+
xml_header = invoice.elements[1]
|
372
|
+
assert_equal('InvoiceHeader', xml_header.name)
|
373
|
+
assert_equal(4, xml_header.elements.size)
|
374
|
+
xml_detail = invoice.elements[2]
|
375
|
+
assert_equal('InvoiceDetail', xml_detail.name)
|
376
|
+
assert_equal(1, xml_detail.elements.size)
|
377
|
+
xml_summary = invoice.elements[3]
|
378
|
+
assert_equal('InvoiceSummary', xml_summary.name)
|
379
|
+
assert_equal(2, xml_summary.elements.size)
|
380
|
+
assert_equal(3, invoice.elements.size)
|
381
|
+
end
|
382
|
+
def test__xml_add_invoice_header
|
383
|
+
invoice = FlexMock.new
|
384
|
+
party1 = FlexMock.new
|
385
|
+
party2 = FlexMock.new
|
386
|
+
name = FlexMock.new
|
387
|
+
name.mock_handle(:text) { 'NameText' }
|
388
|
+
name.mock_handle(:to_s) { 'Test AG' }
|
389
|
+
party1.mock_handle(:role) { 'Seller' }
|
390
|
+
party1.mock_handle(:party_id) { '100' }
|
391
|
+
party1.mock_handle(:name) { name }
|
392
|
+
party1.mock_handle(:address) { }
|
393
|
+
party1.mock_handle(:employee) { }
|
394
|
+
party2.mock_handle(:role) { 'Customer' }
|
395
|
+
party2.mock_handle(:party_id) { '54321' }
|
396
|
+
party2.mock_handle(:name) { name }
|
397
|
+
party2.mock_handle(:address) { }
|
398
|
+
party2.mock_handle(:employee) { }
|
399
|
+
invoice.mock_handle(:invoice_id) { ['Invoice', '0038379197'] }
|
400
|
+
invoice.mock_handle(:customer_id) { 'B-1298089' }
|
401
|
+
invoice.mock_handle(:status) { 'Confirmed' }
|
402
|
+
invoice.mock_handle(:status_date) { Time.local(2006, 5, 12, 7, 32, 48) }
|
403
|
+
invoice.mock_handle(:seller) { party1 }
|
404
|
+
xml_invoice = REXML::Element.new('Invoice')
|
405
|
+
BddGeh._xml_add_invoice_header(xml_invoice, invoice)
|
406
|
+
assert_equal(1, xml_invoice.elements.size)
|
407
|
+
xml_header = xml_invoice.elements[1]
|
408
|
+
xml_reference = xml_header.elements[1]
|
409
|
+
expected = '<InvoiceNumber><Reference><RefNum>0038379197</RefNum></Reference></InvoiceNumber>'
|
410
|
+
assert_equal(expected, xml_reference.to_s)
|
411
|
+
xml_date = xml_header.elements[2]
|
412
|
+
expected = '<InvoiceIssueDate>20060512073248</InvoiceIssueDate>'
|
413
|
+
assert_equal(expected, xml_date.to_s)
|
414
|
+
xml_refs = xml_header.elements[3]
|
415
|
+
assert_equal('InvoiceReferences', xml_refs.name)
|
416
|
+
xml_party = xml_header.elements[4]
|
417
|
+
expected = '<SellerParty><Party><PartyID><Identifier><Ident>100</Ident></Identifier></PartyID></Party></SellerParty>'
|
418
|
+
assert_equal(expected, xml_party.to_s)
|
419
|
+
assert_equal(4, xml_header.elements.size)
|
420
|
+
end
|
421
|
+
=begin
|
422
|
+
def test__xml_add_invoice_reference
|
423
|
+
xml = FlexMock.new
|
424
|
+
invoice = FlexMock.new
|
425
|
+
invoice.mock_handle(:delivery_id) { ['ACC', 'B-1298089'] }
|
426
|
+
xml.mock_handle(:add_element, 1) { |xml_refs|
|
427
|
+
assert_equal('InvoiceReferences', xml_refs.name)
|
428
|
+
xml_order_ref = xml_refs.elements[1]
|
429
|
+
expected = '<PurchaseOrderReference><PurchaseOrderNumber><Reference><RefNum>B-1298089</RefNum></Reference></PurchaseOrderNumber></PurchaseOrderReference>'
|
430
|
+
assert_equal(expected, xml_order_ref.to_s)
|
431
|
+
expected = '<AccountNumber><Reference><RefNum>01000131751001054463837919705010072808</RefNum></Reference></AccountNumber>'
|
432
|
+
xml_account = xml_refs.elements[2]
|
433
|
+
assert_equal(expected, xml_account.to_s)
|
434
|
+
assert_equal(2, xml_refs.elements.size)
|
435
|
+
}
|
436
|
+
BddGeh._xml_add_invoice_references(xml, invoice)
|
437
|
+
xml.mock_verify
|
438
|
+
end
|
439
|
+
=end
|
440
|
+
def test__xml_add_invoice_detail
|
441
|
+
xml = FlexMock.new
|
442
|
+
invoice = FlexMock.new
|
443
|
+
invoice.mock_handle(:items) { [] }
|
444
|
+
xml.mock_handle(:add_element, 1) { |xml_detail|
|
445
|
+
assert_equal('InvoiceDetail', xml_detail.name)
|
446
|
+
assert_equal(1, xml_detail.elements.size)
|
447
|
+
xml_detail_list = xml_detail.elements[1]
|
448
|
+
assert_equal('ListOfInvoiceItemDetail', xml_detail_list.name)
|
449
|
+
}
|
450
|
+
BddGeh._xml_add_invoice_detail(xml, invoice)
|
451
|
+
xml.mock_verify
|
452
|
+
end
|
453
|
+
def test__xml_add_invoice_item
|
454
|
+
xml = FlexMock.new
|
455
|
+
item = FlexMock.new
|
456
|
+
part_info = FlexMock.new
|
457
|
+
price1 = FlexMock.new
|
458
|
+
price1.mock_handle(:amount) { 12345 }
|
459
|
+
price2 = FlexMock.new
|
460
|
+
price2.mock_handle(:amount) { 54321 }
|
461
|
+
part_info.mock_handle(:dimension) { 'the Dimension' }
|
462
|
+
part_info.mock_handle(:value) { 'the Value' }
|
463
|
+
item.mock_handle(:line_no) { '10' }
|
464
|
+
item.mock_handle(:ids) { [
|
465
|
+
['EAN-Nummer', '123123123'],
|
466
|
+
['ET-Nummer', '123 890 390'],
|
467
|
+
] }
|
468
|
+
item.mock_handle(:part_infos) { [part_info] }
|
469
|
+
item.mock_handle(:qty) { 3 }
|
470
|
+
item.mock_handle(:get_price) { |purpose|
|
471
|
+
{
|
472
|
+
'NettoPreisME' => price1,
|
473
|
+
'NettoPreis' => price2,
|
474
|
+
}[purpose]
|
475
|
+
}
|
476
|
+
item.mock_handle(:free_text) { }
|
477
|
+
item.mock_handle(:delivery_date) { Date.new(2006,5,16) }
|
478
|
+
xml.mock_handle(:add_element) { |xml_item|
|
479
|
+
assert_instance_of(REXML::Element, xml_item)
|
480
|
+
assert_equal('InvoiceItemDetail', xml_item.name)
|
481
|
+
assert_equal(2, xml_item.elements.size)
|
482
|
+
xml_base = xml_item.elements[1]
|
483
|
+
assert_equal('InvoiceBaseItemDetail', xml_base.name)
|
484
|
+
xml_pricing = xml_item.elements[2]
|
485
|
+
assert_equal('InvoicePricingDetail', xml_pricing.name)
|
486
|
+
xml_total = xml_pricing.elements[2]
|
487
|
+
assert_equal('InvoiceCurrencyTotalValue', xml_total.name)
|
488
|
+
}
|
489
|
+
BddGeh._xml_add_invoice_item(xml, item)
|
490
|
+
xml.mock_verify
|
491
|
+
end
|
492
|
+
def test__xml_add_invoice_summary
|
493
|
+
xml = FlexMock.new
|
494
|
+
price_net = FlexMock.new
|
495
|
+
price_net.mock_handle(:amount) { '12623.25' }
|
496
|
+
price_tax = FlexMock.new
|
497
|
+
price_tax.mock_handle(:amount) { '959.37' }
|
498
|
+
price_total = FlexMock.new
|
499
|
+
price_total.mock_handle(:amount) { '13582.62' }
|
500
|
+
invoice = FlexMock.new
|
501
|
+
invoice.mock_handle(:items) { ['item1', 'item2'] }
|
502
|
+
invoice.mock_handle(:get_price) { |purpose|
|
503
|
+
{
|
504
|
+
'Endbetrag' => price_total,
|
505
|
+
'Mehrwertsteuer' => price_tax,
|
506
|
+
'SummePositionen' => price_net,
|
507
|
+
}[purpose]
|
508
|
+
}
|
509
|
+
xml.mock_handle(:add_element, 1) { |xml_summary|
|
510
|
+
assert_equal('InvoiceSummary', xml_summary.name)
|
511
|
+
xml_lines = xml_summary.elements[1]
|
512
|
+
expected = '<NumberOfLines>2</NumberOfLines>'
|
513
|
+
assert_equal(expected, xml_lines.to_s)
|
514
|
+
xml_totals = xml_summary.elements[2]
|
515
|
+
assert_equal('InvoiceTotals', xml_totals.name)
|
516
|
+
xml_net = xml_totals.elements[1]
|
517
|
+
expected = '<NetValue><MonetaryValue><MonetaryAmount>12623.25</MonetaryAmount></MonetaryValue></NetValue>'
|
518
|
+
assert_equal(expected, xml_net.to_s)
|
519
|
+
xml_tax = xml_totals.elements[2]
|
520
|
+
expected = '<TotalTax><MonetaryValue><MonetaryAmount>959.37</MonetaryAmount></MonetaryValue></TotalTax>'
|
521
|
+
assert_equal(expected, xml_tax.to_s)
|
522
|
+
xml_total = xml_totals.elements[3]
|
523
|
+
expected = '<TotalAmountPlusTax><MonetaryValue><MonetaryAmount>13582.62</MonetaryAmount></MonetaryValue></TotalAmountPlusTax>'
|
524
|
+
assert_equal(expected, xml_total.to_s)
|
525
|
+
assert_equal(3, xml_totals.elements.size)
|
526
|
+
assert_equal(2, xml_summary.elements.size)
|
527
|
+
}
|
528
|
+
BddGeh._xml_add_invoice_summary(xml, invoice)
|
529
|
+
xml.mock_verify
|
530
|
+
end
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|