sandozxmlconv 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env ruby
2
+ # TestPharmaciePlusBdd -- xmlconv2 -- 18.08.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/pharmacieplus_bdd'
9
+
10
+
11
+ module XmlConv
12
+ module Conversion
13
+ class TestGehBdd < Test::Unit::TestCase
14
+ def setup
15
+ @src = <<-XML
16
+ <?xml version="1.0" encoding="ISO-8859-1"?>
17
+ <commande id="1861" date="2006-08-16T09:32:35.303+02:00" xmlns="http://www.ofac.ch/XEDO">
18
+ <groupe>
19
+ <last-name>pharmacieplus Directe</last-name>
20
+ <first-name> </first-name>
21
+ <other-name>Messieurs Eric Bussat + Christian Rouvinez</other-name>
22
+ <address>
23
+ <street>les courbes 5</street>
24
+ <zip>1121</zip>
25
+ <city>Bremblens</city>
26
+ </address>
27
+ <telecom>
28
+ <phone number="021 811 48 88"/>
29
+ <fax number="021 811 48 89"/>
30
+ </telecom>
31
+ <online>
32
+ <email>secretariat@pharmacieplus.ch</email>
33
+ </online>
34
+ </groupe>
35
+ <fournisseur ean="7601001000681">
36
+ <last-name>GLOBOPHARM AG</last-name>
37
+ <first-name> </first-name>
38
+ <address>
39
+ <street>Seestrasse 200</street>
40
+ <zip>8700</zip>
41
+ <city>KUESNACHT</city>
42
+ <country>CH</country>
43
+ </address>
44
+ </fournisseur>
45
+ <com-global>
46
+ <article ean="7680543802083" pharmacode="2054106" qte-livraison="12" qte-facture="10">
47
+ <desc>ANTRA MUPS 10 Tabl 10 mg 100 Stk</desc>
48
+ <cond-com>
49
+ <bonus facture="10" livre="12"/>
50
+ </cond-com>
51
+ </article>
52
+ <article ean="7680543800386" pharmacode="2054081" qte-livraison="12" qte-facture="10">
53
+ <desc>ANTRA MUPS 10 Tabl 10 mg 28 Stk</desc>
54
+ <cond-com>
55
+ <bonus facture="10" livre="12"/>
56
+ </cond-com>
57
+ </article>
58
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="30" qte-facture="20">
59
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
60
+ <cond-com>
61
+ <bonus facture="10" livre="15"/>
62
+ </cond-com>
63
+ </article>
64
+ <article ean="7680543802403" pharmacode="2054158" qte-livraison="15" qte-facture="10">
65
+ <desc>ANTRA MUPS 20 Tabl 20 mg 100 Stk</desc>
66
+ <cond-com>
67
+ <bonus facture="10" livre="15"/>
68
+ </cond-com>
69
+ </article>
70
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="13" qte-facture="13">
71
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
72
+ <cond-com rabais="10.0"/>
73
+ </article>
74
+ <article ean="7680543800973" pharmacode="2054135" qte-livraison="28" qte-facture="20">
75
+ <desc>ANTRA MUPS 20 Tabl 20 mg 28 Stk</desc>
76
+ <cond-com>
77
+ <bonus facture="10" livre="14"/>
78
+ </cond-com>
79
+ </article>
80
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="17" qte-facture="17">
81
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
82
+ <cond-com rabais="15.0"/>
83
+ </article>
84
+ <article ean="7680543800706" pharmacode="2054112" qte-livraison="28" qte-facture="20">
85
+ <desc>ANTRA MUPS 20 Tabl 20 mg 7 Stk</desc>
86
+ <cond-com>
87
+ <bonus facture="10" livre="14"/>
88
+ </cond-com>
89
+ </article>
90
+ <article ean="7680548750532" pharmacode="2204899" qte-livraison="11" qte-facture="11">
91
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 28 Stk</desc>
92
+ <cond-com rabais="5.0"/>
93
+ </article>
94
+ <article ean="7680548750617" pharmacode="2204907" qte-livraison="30" qte-facture="20">
95
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 98 Stk</desc>
96
+ <cond-com>
97
+ <bonus facture="10" livre="15"/>
98
+ </cond-com>
99
+ </article>
100
+ </com-global>
101
+ <com-pharma ean="7601001368095">
102
+ <livraison>
103
+ <last-name>Pharmacie du Mandement</last-name>
104
+ <first-name> </first-name>
105
+ <other-name> Madame Fran�oise Recipient </other-name>
106
+ <address>
107
+ <street>3e adresse e-mail</street>
108
+ <zip>1242</zip>
109
+ <city>Satigny</city>
110
+ </address>
111
+ </livraison>
112
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="15" qte-facture="10">
113
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
114
+ </article>
115
+ <article ean="7680543802403" pharmacode="2054158" qte-livraison="15" qte-facture="10">
116
+ <desc>ANTRA MUPS 20 Tabl 20 mg 100 Stk</desc>
117
+ </article>
118
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="6" qte-facture="6">
119
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
120
+ </article>
121
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="9" qte-facture="9">
122
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
123
+ </article>
124
+ <article ean="7680543800706" pharmacode="2054112" qte-livraison="28" qte-facture="20">
125
+ <desc>ANTRA MUPS 20 Tabl 20 mg 7 Stk</desc>
126
+ </article>
127
+ <article ean="7680548750532" pharmacode="2204899" qte-livraison="11" qte-facture="11">
128
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 28 Stk</desc>
129
+ </article>
130
+ <article ean="7680548750617" pharmacode="2204907" qte-livraison="30" qte-facture="20">
131
+ <desc>ATACAND PLUS Tabl 16/12.5 mg 98 Stk</desc>
132
+ </article>
133
+ </com-pharma>
134
+ <com-pharma ean="7601001368491">
135
+ <livraison>
136
+ <last-name>Pharm. Ecole-de-M�decine</last-name>
137
+ <first-name> </first-name>
138
+ <other-name> Monsieur Fr�d�ric Recipient </other-name>
139
+ <address>
140
+ <street>3e adresse e-mail</street>
141
+ <zip>1205</zip>
142
+ <city>Gen�ve</city>
143
+ </address>
144
+ </livraison>
145
+ <article ean="7680543802083" pharmacode="2054106" qte-livraison="12" qte-facture="10">
146
+ <desc>ANTRA MUPS 10 Tabl 10 mg 100 Stk</desc>
147
+ </article>
148
+ <article ean="7680543800386" pharmacode="2054081" qte-livraison="12" qte-facture="10">
149
+ <desc>ANTRA MUPS 10 Tabl 10 mg 28 Stk</desc>
150
+ </article>
151
+ <article ean="7680543801949" pharmacode="2054098" qte-livraison="15" qte-facture="10">
152
+ <desc>ANTRA MUPS 10 Tabl 10 mg 56 Stk</desc>
153
+ </article>
154
+ <article ean="7680543800898" pharmacode="2054129" qte-livraison="7" qte-facture="7">
155
+ <desc>ANTRA MUPS 20 Tabl 20 mg 14 Stk</desc>
156
+ </article>
157
+ <article ean="7680543800973" pharmacode="2054135" qte-livraison="28" qte-facture="20">
158
+ <desc>ANTRA MUPS 20 Tabl 20 mg 28 Stk</desc>
159
+ </article>
160
+ <article ean="7680543802328" pharmacode="2054141" qte-livraison="8" qte-facture="8">
161
+ <desc>ANTRA MUPS 20 Tabl 20 mg 56 Stk</desc>
162
+ </article>
163
+ </com-pharma>
164
+ </commande>
165
+ XML
166
+ @xml_doc = REXML::Document.new(@src)
167
+ end
168
+ def test_parse
169
+ document = PharmaciePlusBdd.parse(@src)
170
+ assert_instance_of(REXML::Document, document)
171
+ end
172
+ def test_convert
173
+ bdd = PharmaciePlusBdd.convert(@xml_doc)
174
+ assert_instance_of(Model::Bdd, bdd)
175
+ assert_equal(2, bdd.deliveries.size)
176
+ delivery = bdd.deliveries.first
177
+ assert_instance_of(Model::Delivery, delivery)
178
+ assert_equal('1861', delivery.customer_id)
179
+ bsr = delivery.bsr
180
+ assert_instance_of(Model::Bsr, bsr)
181
+ assert_equal('7601001368095', delivery.bsr_id)
182
+ customer = delivery.customer
183
+ assert_instance_of(Model::Party, customer)
184
+ shipto = customer.ship_to
185
+ assert_instance_of(Model::Party, shipto)
186
+ name = shipto.name
187
+ assert_instance_of(Model::Name, name)
188
+ expected = "Madame Fran�oise Recipient"
189
+ assert_equal(expected, name.to_s)
190
+ address = shipto.address
191
+ assert_instance_of(Model::Address, address)
192
+ assert_equal(["Pharmacie du Mandement", "3e adresse e-mail"],
193
+ address.lines)
194
+ assert_equal("1242", address.zip_code)
195
+ assert_equal("Satigny", address.city)
196
+ assert_equal(7, delivery.items.size)
197
+
198
+ item = delivery.items.first
199
+ assert_instance_of(Model::DeliveryItem, item)
200
+ assert_equal('1', item.line_no)
201
+ assert_equal('7680543801949', item.et_nummer_id)
202
+ assert_equal('2054098', item.pharmacode_id)
203
+ assert_equal('10', item.qty)
204
+
205
+ #bsr = delivery.bsr
206
+ #assert_instance_of(Model::Bsr, bsr)
207
+
208
+ ## second delivery:
209
+ delivery = bdd.deliveries.last
210
+ assert_instance_of(Model::Delivery, delivery)
211
+ assert_equal('1861', delivery.customer_id)
212
+ assert_equal('7601001368491', delivery.bsr_id)
213
+ customer = delivery.customer
214
+ assert_instance_of(Model::Party, customer)
215
+ name = customer.name
216
+ assert_instance_of(Model::Name, name)
217
+ expected = "Monsieur Fr�d�ric Recipient"
218
+ assert_equal(expected, name.to_s)
219
+ expected = "Pharm. Ecole-de-M�decine"
220
+ assert_equal(expected, customer.ship_to.address.lines.first)
221
+ end
222
+ end
223
+ end
224
+ end
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+ # Conversion::TestProPharmaBdd -- xmlconv2 -- 14.09.2007 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('..', File.dirname(__FILE__))
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/propharma_bdd'
9
+ require 'flexmock'
10
+
11
+ module XmlConv
12
+ module Conversion
13
+ class TestWbmbBdd < Test::Unit::TestCase
14
+ def setup
15
+ @src = <<-EOS
16
+ [KUNDE]
17
+ idt=123456
18
+ nam=Linden APOTHEKE
19
+ ort=5430 Wettingen
20
+ [BSTELL]
21
+ ref=100446
22
+ dat=A70626
23
+ tim=2131
24
+ [ARTIK]
25
+ typ=P
26
+ phc=02201228
27
+ art=AVEENO ADULTS CREAM 100 ML
28
+ mge=1
29
+ [ARTIK]
30
+ typ=P
31
+ phc=00931796
32
+ art=MEPHAMESON 8 INJ LOES 8 MG 50 AMP 2 ML
33
+ mge=4
34
+ [ARTIK]
35
+ typ=P
36
+ phc=01995226
37
+ art=3M INDAIR TAPE HEISSLUFT 19MMX50M 12 STK
38
+ mge=19
39
+ [ARTIK]
40
+ typ=P
41
+ phc=02584519
42
+ art=ABRI NET NETZHOSE 130-190CM XXL ORANGE BTL 50 STK
43
+ mge=4
44
+ [ARTIK]
45
+ typ=P
46
+ phc=01901722
47
+ art=ASPIRIN CARDIO 300 TABL 300 MG 90 STK
48
+ mge=10
49
+ [ARTIK]
50
+ typ=P
51
+ phc=10001318
52
+ art=BLUTDRUCKMESSEN
53
+ mge=1
54
+ [ARTIK]
55
+ typ=P
56
+ phc=00829336
57
+ art=PONSTAN FILMTABS 500 MG 120 STK
58
+ mge=2
59
+ [ARTIK]
60
+ typ=P
61
+ phc=00703285
62
+ art=PONSTAN FILMTABS 500 MG 36 STK
63
+ mge=11
64
+ [ARTIK]
65
+ typ=P
66
+ phc=10001446
67
+ art=REZEPTEROEFFNUNG
68
+ mge=2
69
+ EOS
70
+ end
71
+ def test_parse
72
+ ast = ProPharmaBdd.parse(@src)
73
+ assert_instance_of(SyntaxTree, ast)
74
+ end
75
+ def test_convert
76
+ bdd = ProPharmaBdd.convert(ProPharmaBdd.parse(@src))
77
+ assert_instance_of(Model::Bdd, bdd)
78
+ assert_equal(1, bdd.deliveries.size)
79
+ delivery = bdd.deliveries.first
80
+ customer = delivery.customer
81
+ assert_instance_of(Model::Party, customer)
82
+ assert_equal("Linden APOTHEKE", customer.name.to_s)
83
+ # customer_id is in reality the delivery_id assigned by the
84
+ # customer - the slight confusion is due to automatic naming
85
+ assert_equal('100446', delivery.customer_id)
86
+ assert_equal('123456', delivery.bsr_id)
87
+ customer = delivery.customer
88
+ assert_equal('123456', customer.ids['customer'])
89
+ seller = delivery.seller
90
+ assert_equal('7601001000681', seller.acc_id)
91
+ assert_equal(9, delivery.items.size)
92
+ item = delivery.items.first
93
+ assert_equal('02201228', item.pharmacode_id)
94
+ assert_equal('1', item.qty)
95
+ item = delivery.items.last
96
+ assert_equal('10001446', item.pharmacode_id)
97
+ assert_equal('2', item.qty)
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env ruby
2
+ # TestSunStoreBdd -- xmlconv2 -- 18.08.2006 -- hwyss@ywesee.com
3
+
4
+ $: << File.dirname(__FILE__)
5
+ $: << File.expand_path('../../lib', File.dirname(__FILE__))
6
+
7
+ require 'test/unit'
8
+ require 'conversion/sunstore_bdd'
9
+ require 'xmlconv/util/transaction'
10
+
11
+ module XmlConv
12
+ module Conversion
13
+ class TestGehBdd < Test::Unit::TestCase
14
+ def setup
15
+ @src = <<-XML
16
+ <?xml version="1.0" encoding="ISO-8859-1"?>
17
+ <customerOrder xmlns="http://www.e-galexis.com/schemas/"
18
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19
+ xsi:schemaLocation="http://www.e-galexis.com/schemas/ http://www.e-galexis.com/schemas/POS/customerOrder/customerOrder.xsd"
20
+ backLogDesired="true" compressionDesired="false" language="de"
21
+ productDescriptionDesired="false" roundUpForCondition="true"
22
+ version="1.0">
23
+ <client number="7601000755872" password="test" />
24
+ <orderHeader deliveryDate="2002-08-25"
25
+ referenceNumber="123ABCDE9012345" mannerOfTransport="tour"
26
+ urgent="false">
27
+ <deliveryAddress line1="Superkunde" line4="Linkestrasse 99"
28
+ line5PostalCode="3322" line5City="Sch&#246;nb&#252;hl">
29
+ <addressLine2And3Text line2="Dorfladen" line3="Frau Muster" />
30
+ </deliveryAddress>
31
+ </orderHeader>
32
+ <orderLines>
33
+ <productOrderLine orderQuantity="10" roundUpForCondition="true"
34
+ backLogDesired="false">
35
+ <pharmaCode id="1336630" />
36
+ </productOrderLine>
37
+ <productLabelOrderLine defaultOrderQuantity="5">
38
+ <EAN id="7680123456789" />
39
+ <supplierProductNumber EANsupplierId="54321678091432"
40
+ id="123.234-2" />
41
+ </productLabelOrderLine>
42
+ </orderLines>
43
+ </customerOrder>
44
+ XML
45
+ @xml_doc = REXML::Document.new(@src)
46
+ end
47
+ def test_parse
48
+ document = SunStoreBdd.parse(@src)
49
+ assert_instance_of(REXML::Document, document)
50
+ end
51
+ def test_convert
52
+ bdd = SunStoreBdd.convert(@xml_doc)
53
+ assert_instance_of(Model::Bdd, bdd)
54
+ assert_equal(1, bdd.deliveries.size)
55
+ delivery = bdd.deliveries.first
56
+ assert_instance_of(Model::Delivery, delivery)
57
+ assert_equal('123ABCDE9012345', delivery.customer_id)
58
+ bsr = delivery.bsr
59
+ assert_instance_of(Model::Bsr, bsr)
60
+ assert_equal('7601000755872', delivery.bsr_id)
61
+ customer = delivery.customer
62
+ assert_instance_of(Model::Party, customer)
63
+ assert_equal('7601000755872', customer.acc_id)
64
+ shipto = customer.ship_to
65
+ assert_instance_of(Model::Party, shipto)
66
+ name = shipto.name
67
+ assert_instance_of(Model::Name, name)
68
+ expected = "Superkunde"
69
+ assert_equal(expected, name.to_s)
70
+ address = shipto.address
71
+ assert_instance_of(Model::Address, address)
72
+ assert_equal([ "Dorfladen", "Frau Muster",
73
+ "Linkestrasse 99" ],
74
+ address.lines)
75
+ assert_equal("3322", address.zip_code)
76
+ assert_equal("Sch\366nb\374hl", address.city)
77
+ assert_equal(2, delivery.items.size)
78
+
79
+ item = delivery.items.first
80
+ assert_instance_of(Model::DeliveryItem, item)
81
+ assert_equal('1', item.line_no)
82
+ assert_equal(nil, item.et_nummer_id)
83
+ assert_equal('1336630', item.pharmacode_id)
84
+ assert_equal('10', item.qty)
85
+
86
+ item = delivery.items.last
87
+ assert_instance_of(Model::DeliveryItem, item)
88
+ assert_equal('2', item.line_no)
89
+ assert_equal('7680123456789', item.et_nummer_id)
90
+ assert_equal(nil, item.pharmacode_id)
91
+ assert_equal('5', item.qty)
92
+ end
93
+ def test_respond
94
+ transaction = Util::Transaction.new
95
+ transaction.instance_variable_set('@model', SunStoreBdd.convert(@xml_doc))
96
+ response = SunStoreBdd.respond transaction, []
97
+ assert_instance_of REXML::Document, response
98
+ output = ''
99
+ REXML::Formatters::Pretty.new.write response, output
100
+ assert_equal <<-EOS.strip, output
101
+ <?xml version='1.0' encoding='UTF-8'?>
102
+ <customerOrderResponse backLogDesired='false' language='de' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.e-galexis.com/schemas/ http://www.e-galexis.com/schemas/POS/customerOrder/customerOrderResponse.xsd' version='1.0' productDescriptionDesired='false' roundUpForCondition='false' xmlns='http://www.e-galexis.com/schemas/'>
103
+ <clientErrorResponse/>
104
+ </customerOrderResponse>
105
+ EOS
106
+
107
+ response = SunStoreBdd.respond transaction, [ :order_id => '12345-1',
108
+ :products => [] ]
109
+ output = ''
110
+ REXML::Formatters::Pretty.new.write response, output
111
+ assert_equal <<-EOS.strip, output
112
+ <?xml version='1.0' encoding='UTF-8'?>
113
+ <customerOrderResponse backLogDesired='false' language='de' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.e-galexis.com/schemas/ http://www.e-galexis.com/schemas/POS/customerOrder/customerOrderResponse.xsd' version='1.0' productDescriptionDesired='false' roundUpForCondition='false' xmlns='http://www.e-galexis.com/schemas/'>
114
+ <clientResponse number='12345-1'/>
115
+ <orderHeaderErrorResponse/>
116
+ </customerOrderResponse>
117
+ EOS
118
+
119
+ products = [
120
+ { :description => 'Product & 1',
121
+ :article_number => '1' },
122
+ { :description => 'Product & 2',
123
+ :article_number => '2' }
124
+ ]
125
+ response = SunStoreBdd.respond transaction, [ :order_id => '12345-1',
126
+ :products => products ]
127
+ output = ''
128
+ REXML::Formatters::Pretty.new.write response, output
129
+ assert_equal <<-EOS.strip, output
130
+ <?xml version='1.0' encoding='UTF-8'?>
131
+ <customerOrderResponse backLogDesired='false' language='de' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.e-galexis.com/schemas/ http://www.e-galexis.com/schemas/POS/customerOrder/customerOrderResponse.xsd' version='1.0' productDescriptionDesired='false' roundUpForCondition='false' xmlns='http://www.e-galexis.com/schemas/'>
132
+ <clientResponse number='12345-1'/>
133
+ <orderHeaderResponse referenceNumber='123ABCDE9012345'>
134
+ <deliveryAddress line1='Superkunde' line5City='Schönbühl' line5PostalCode='3322' line4='Linkestrasse 99'>
135
+ <addressLine2And3Text line2='Dorfladen' line3='Frau Muster'/>
136
+ </deliveryAddress>
137
+ </orderHeaderResponse>
138
+ <orderLinesResponse>
139
+ <productOrderLineResponse lineAccepted='true' roundUpForConditionDone='false' productReplaced='false' backLogLine='false'>
140
+ <productOrderLine orderQuantity='10'>
141
+ <pharmaCode id='1336630'/>
142
+ </productOrderLine>
143
+ <productResponse description='Product &amp; 1' wholesalerProductCode='1'/>
144
+ <availability status='yes'/>
145
+ </productOrderLineResponse>
146
+ <productOrderLineResponse lineAccepted='true' roundUpForConditionDone='false' productReplaced='false' backLogLine='false'>
147
+ <productOrderLine orderQuantity='5'>
148
+ <EAN id='7680123456789'/>
149
+ </productOrderLine>
150
+ <productResponse description='Product &amp; 2' wholesalerProductCode='2'/>
151
+ <availability status='yes'/>
152
+ </productOrderLineResponse>
153
+ </orderLinesResponse>
154
+ </customerOrderResponse>
155
+ EOS
156
+ end
157
+ end
158
+ end
159
+ end