acts_as_isdoc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+
4
+ Schéma pro fakturu ISDOC + validace struktury digitálního podpisu
5
+
6
+ (c) 2009 Sdružení pro informační společnost, http://www.spis.cz/
7
+
8
+ $Id: isdoc-invoice-dsig-5.2.xsd,v 1.1 2009/03/21 15:45:59 jkj Exp $
9
+
10
+ -->
11
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
12
+ targetNamespace="http://isdoc.cz/namespace/invoice" xmlns="http://isdoc.cz/namespace/invoice"
13
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#" elementFormDefault="qualified">
14
+
15
+ <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd"/>
16
+
17
+ <xs:redefine schemaLocation="isdoc-invoice-5.2.xsd">
18
+ <xs:group name="Signature">
19
+ <xs:sequence>
20
+ <xs:element ref="ds:Signature"/>
21
+ </xs:sequence>
22
+ </xs:group>
23
+ </xs:redefine>
24
+
25
+ </xs:schema>
@@ -0,0 +1,299 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><!-- Schema for XML Signatures
2
+ http://www.w3.org/2000/09/xmldsig#
3
+ $Revision: 1.3 $ on $Date: 2009/03/10 21:06:41 $ by $Author: jkj $
4
+
5
+ Copyright 2001 The Internet Society and W3C (Massachusetts Institute
6
+ of Technology, Institut National de Recherche en Informatique et en
7
+ Automatique, Keio University). All Rights Reserved.
8
+ http://www.w3.org/Consortium/Legal/
9
+
10
+ This document is governed by the W3C Software License [1] as described
11
+ in the FAQ [2].
12
+
13
+ [1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
14
+ [2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
15
+ --><schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" targetNamespace="http://www.w3.org/2000/09/xmldsig#" version="0.1" elementFormDefault="qualified" finalDefault="" blockDefault="" attributeFormDefault="unqualified">
16
+
17
+ <!-- Basic Types Defined for Signatures -->
18
+
19
+ <simpleType name="CryptoBinary">
20
+ <restriction base="base64Binary">
21
+ </restriction>
22
+ </simpleType>
23
+
24
+ <!-- Start Signature -->
25
+
26
+ <element name="Signature" type="ds:SignatureType"/>
27
+ <complexType name="SignatureType" mixed="false">
28
+ <sequence>
29
+ <element ref="ds:SignedInfo"/>
30
+ <element ref="ds:SignatureValue"/>
31
+ <element ref="ds:KeyInfo" minOccurs="0"/>
32
+ <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
33
+ </sequence>
34
+ <attribute name="Id" type="ID" use="optional"/>
35
+ </complexType>
36
+
37
+ <element name="SignatureValue" type="ds:SignatureValueType"/>
38
+ <complexType name="SignatureValueType" mixed="false">
39
+ <simpleContent>
40
+ <extension base="base64Binary">
41
+ <attribute name="Id" type="ID" use="optional"/>
42
+ </extension>
43
+ </simpleContent>
44
+ </complexType>
45
+
46
+ <!-- Start SignedInfo -->
47
+
48
+ <element name="SignedInfo" type="ds:SignedInfoType"/>
49
+ <complexType name="SignedInfoType" mixed="false">
50
+ <sequence>
51
+ <element ref="ds:CanonicalizationMethod"/>
52
+ <element ref="ds:SignatureMethod"/>
53
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
54
+ </sequence>
55
+ <attribute name="Id" type="ID" use="optional"/>
56
+ </complexType>
57
+
58
+ <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
59
+ <complexType name="CanonicalizationMethodType" mixed="true">
60
+ <sequence>
61
+ <any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="strict"/>
62
+ <!-- (0,unbounded) elements from (1,1) namespace -->
63
+ </sequence>
64
+ <attribute name="Algorithm" type="anyURI" use="required"/>
65
+ </complexType>
66
+
67
+ <element name="SignatureMethod" type="ds:SignatureMethodType"/>
68
+ <complexType name="SignatureMethodType" mixed="true">
69
+ <sequence>
70
+ <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
71
+ <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="strict"/>
72
+ <!-- (0,unbounded) elements from (1,1) external namespace -->
73
+ </sequence>
74
+ <attribute name="Algorithm" type="anyURI" use="required"/>
75
+ </complexType>
76
+
77
+ <!-- Start Reference -->
78
+
79
+ <element name="Reference" type="ds:ReferenceType"/>
80
+ <complexType name="ReferenceType" mixed="false">
81
+ <sequence>
82
+ <element ref="ds:Transforms" minOccurs="0"/>
83
+ <element ref="ds:DigestMethod"/>
84
+ <element ref="ds:DigestValue"/>
85
+ </sequence>
86
+ <attribute name="Id" type="ID" use="optional"/>
87
+ <attribute name="URI" type="anyURI" use="optional"/>
88
+ <attribute name="Type" type="anyURI" use="optional"/>
89
+ </complexType>
90
+
91
+ <element name="Transforms" type="ds:TransformsType"/>
92
+ <complexType name="TransformsType" mixed="false">
93
+ <sequence>
94
+ <element ref="ds:Transform" maxOccurs="unbounded"/>
95
+ </sequence>
96
+ </complexType>
97
+
98
+ <element name="Transform" type="ds:TransformType"/>
99
+ <complexType name="TransformType" mixed="true">
100
+ <choice minOccurs="0" maxOccurs="unbounded">
101
+ <any namespace="##other" processContents="lax" minOccurs="1" maxOccurs="1"/>
102
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
103
+ <element name="XPath" type="string"/>
104
+ </choice>
105
+ <attribute name="Algorithm" type="anyURI" use="required"/>
106
+ </complexType>
107
+
108
+ <!-- End Reference -->
109
+
110
+ <element name="DigestMethod" type="ds:DigestMethodType"/>
111
+ <complexType name="DigestMethodType" mixed="true">
112
+ <sequence>
113
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
114
+ </sequence>
115
+ <attribute name="Algorithm" type="anyURI" use="required"/>
116
+ </complexType>
117
+
118
+ <element name="DigestValue" type="ds:DigestValueType"/>
119
+ <simpleType name="DigestValueType">
120
+ <restriction base="base64Binary"/>
121
+ </simpleType>
122
+
123
+ <!-- End SignedInfo -->
124
+
125
+ <!-- Start KeyInfo -->
126
+
127
+ <element name="KeyInfo" type="ds:KeyInfoType"/>
128
+ <complexType name="KeyInfoType" mixed="true">
129
+ <choice maxOccurs="unbounded">
130
+ <element ref="ds:KeyName"/>
131
+ <element ref="ds:KeyValue"/>
132
+ <element ref="ds:RetrievalMethod"/>
133
+ <element ref="ds:X509Data"/>
134
+ <element ref="ds:PGPData"/>
135
+ <element ref="ds:SPKIData"/>
136
+ <element ref="ds:MgmtData"/>
137
+ <any processContents="lax" namespace="##other" minOccurs="1" maxOccurs="1"/>
138
+ <!-- (1,1) elements from (0,unbounded) namespaces -->
139
+ </choice>
140
+ <attribute name="Id" type="ID" use="optional"/>
141
+ </complexType>
142
+
143
+ <element name="KeyName" type="string"/>
144
+ <element name="MgmtData" type="string"/>
145
+
146
+ <element name="KeyValue" type="ds:KeyValueType"/>
147
+ <complexType name="KeyValueType" mixed="true">
148
+ <choice>
149
+ <element ref="ds:DSAKeyValue"/>
150
+ <element ref="ds:RSAKeyValue"/>
151
+ <any namespace="##other" processContents="lax" minOccurs="1" maxOccurs="1"/>
152
+ </choice>
153
+ </complexType>
154
+
155
+ <element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
156
+ <complexType name="RetrievalMethodType" mixed="false">
157
+ <sequence>
158
+ <element ref="ds:Transforms" minOccurs="0"/>
159
+ </sequence>
160
+ <attribute name="URI" type="anyURI"/>
161
+ <attribute name="Type" type="anyURI" use="optional"/>
162
+ </complexType>
163
+
164
+ <!-- Start X509Data -->
165
+
166
+ <element name="X509Data" type="ds:X509DataType"/>
167
+ <complexType name="X509DataType" mixed="false">
168
+ <sequence maxOccurs="unbounded">
169
+ <choice>
170
+ <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
171
+ <element name="X509SKI" type="base64Binary"/>
172
+ <element name="X509SubjectName" type="string"/>
173
+ <element name="X509Certificate" type="base64Binary"/>
174
+ <element name="X509CRL" type="base64Binary"/>
175
+ <any namespace="##other" processContents="lax" minOccurs="1" maxOccurs="1"/>
176
+ </choice>
177
+ </sequence>
178
+ </complexType>
179
+
180
+ <complexType name="X509IssuerSerialType" mixed="false">
181
+ <sequence>
182
+ <element name="X509IssuerName" type="string"/>
183
+ <element name="X509SerialNumber" type="integer"/>
184
+ </sequence>
185
+ </complexType>
186
+
187
+ <!-- End X509Data -->
188
+
189
+ <!-- Begin PGPData -->
190
+
191
+ <element name="PGPData" type="ds:PGPDataType"/>
192
+ <complexType name="PGPDataType" mixed="false">
193
+ <choice>
194
+ <sequence>
195
+ <element name="PGPKeyID" type="base64Binary"/>
196
+ <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
197
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
198
+ </sequence>
199
+ <sequence>
200
+ <element name="PGPKeyPacket" type="base64Binary"/>
201
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
202
+ </sequence>
203
+ </choice>
204
+ </complexType>
205
+
206
+ <!-- End PGPData -->
207
+
208
+ <!-- Begin SPKIData -->
209
+
210
+ <element name="SPKIData" type="ds:SPKIDataType"/>
211
+ <complexType name="SPKIDataType" mixed="false">
212
+ <sequence maxOccurs="unbounded">
213
+ <element name="SPKISexp" type="base64Binary"/>
214
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="1"/>
215
+ </sequence>
216
+ </complexType>
217
+
218
+ <!-- End SPKIData -->
219
+
220
+ <!-- End KeyInfo -->
221
+
222
+ <!-- Start Object (Manifest, SignatureProperty) -->
223
+
224
+ <element name="Object" type="ds:ObjectType"/>
225
+ <complexType name="ObjectType" mixed="true">
226
+ <sequence minOccurs="0" maxOccurs="unbounded">
227
+ <any namespace="##any" processContents="lax" minOccurs="1" maxOccurs="1"/>
228
+ </sequence>
229
+ <attribute name="Id" type="ID" use="optional"/>
230
+ <attribute name="MimeType" type="string" use="optional"/> <!-- add a grep facet -->
231
+ <attribute name="Encoding" type="anyURI" use="optional"/>
232
+ </complexType>
233
+
234
+ <element name="Manifest" type="ds:ManifestType"/>
235
+ <complexType name="ManifestType" mixed="false">
236
+ <sequence>
237
+ <element ref="ds:Reference" maxOccurs="unbounded"/>
238
+ </sequence>
239
+ <attribute name="Id" type="ID" use="optional"/>
240
+ </complexType>
241
+
242
+ <element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
243
+ <complexType name="SignaturePropertiesType" mixed="false">
244
+ <sequence>
245
+ <element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
246
+ </sequence>
247
+ <attribute name="Id" type="ID" use="optional"/>
248
+ </complexType>
249
+
250
+ <element name="SignatureProperty" type="ds:SignaturePropertyType"/>
251
+ <complexType name="SignaturePropertyType" mixed="true">
252
+ <choice maxOccurs="unbounded">
253
+ <any namespace="##other" processContents="lax" minOccurs="1" maxOccurs="1"/>
254
+ <!-- (1,1) elements from (1,unbounded) namespaces -->
255
+ </choice>
256
+ <attribute name="Target" type="anyURI" use="required"/>
257
+ <attribute name="Id" type="ID" use="optional"/>
258
+ </complexType>
259
+
260
+ <!-- End Object (Manifest, SignatureProperty) -->
261
+
262
+ <!-- Start Algorithm Parameters -->
263
+
264
+ <simpleType name="HMACOutputLengthType">
265
+ <restriction base="integer"/>
266
+ </simpleType>
267
+
268
+ <!-- Start KeyValue Element-types -->
269
+
270
+ <element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
271
+ <complexType name="DSAKeyValueType" mixed="false">
272
+ <sequence>
273
+ <sequence minOccurs="0">
274
+ <element name="P" type="ds:CryptoBinary"/>
275
+ <element name="Q" type="ds:CryptoBinary"/>
276
+ </sequence>
277
+ <element name="G" type="ds:CryptoBinary" minOccurs="0"/>
278
+ <element name="Y" type="ds:CryptoBinary"/>
279
+ <element name="J" type="ds:CryptoBinary" minOccurs="0"/>
280
+ <sequence minOccurs="0">
281
+ <element name="Seed" type="ds:CryptoBinary"/>
282
+ <element name="PgenCounter" type="ds:CryptoBinary"/>
283
+ </sequence>
284
+ </sequence>
285
+ </complexType>
286
+
287
+ <element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
288
+ <complexType name="RSAKeyValueType" mixed="false">
289
+ <sequence>
290
+ <element name="Modulus" type="ds:CryptoBinary"/>
291
+ <element name="Exponent" type="ds:CryptoBinary"/>
292
+ </sequence>
293
+ </complexType>
294
+
295
+ <!-- End KeyValue Element-types -->
296
+
297
+ <!-- End Signature -->
298
+
299
+ </schema>
@@ -0,0 +1,45 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require File.dirname(__FILE__) + '/test_helper.rb'
3
+ require File.dirname(__FILE__) + '/fixtures/sample_invoice.rb'
4
+ require File.dirname(__FILE__) + '/fixtures/basic_invoice.rb'
5
+ require File.dirname(__FILE__) + '/fixtures/extended_invoice.rb'
6
+
7
+ class ActsAsIsdocTest < ActiveSupport::TestCase
8
+
9
+ load_schema
10
+
11
+ test "responds_to render_isdoc" do
12
+ assert BasicInvoice.new.respond_to?(:render_isdoc)
13
+ end
14
+
15
+ test "returned basic isdoc is valid" do
16
+ assert valid_isdoc?(BasicInvoice.new.render_isdoc)
17
+ end
18
+
19
+ test "returned basic isdoc is correct" do
20
+ isdoc_file = create_tmp_file("isdoc", BasicInvoice.new.render_isdoc)
21
+ fixture_file = File.join(File.dirname(__FILE__), "..", "test", "fixtures", "basic_invoice.isdoc")
22
+ assert_file_equals(isdoc_file, fixture_file)
23
+ end
24
+
25
+ test "returned sample isdoc is valid" do
26
+ assert valid_isdoc?(SampleInvoice.new.render_isdoc)
27
+ end
28
+
29
+ test "returned sample isdoc is correct" do
30
+ isdoc_file = create_tmp_file("isdoc", SampleInvoice.new.render_isdoc)
31
+ fixture_file = File.join(File.dirname(__FILE__), "..", "test", "fixtures", "sample_invoice.isdoc")
32
+ assert_file_equals(isdoc_file, fixture_file)
33
+ end
34
+
35
+ test "returned extended isdoc is valid" do
36
+ assert valid_isdoc?(ExtendedInvoice.new.render_isdoc)
37
+ end
38
+
39
+ test "returned extended isdoc is correct" do
40
+ isdoc_file = create_tmp_file("isdoc", ExtendedInvoice.new.render_isdoc)
41
+ fixture_file = File.join(File.dirname(__FILE__), "..", "test", "fixtures", "extended_invoice.isdoc")
42
+ assert_file_equals(isdoc_file, fixture_file)
43
+ end
44
+
45
+ end
data/test/database.yml ADDED
@@ -0,0 +1,21 @@
1
+ sqlite:
2
+ :adapter: sqlite
3
+ :dbfile: test/acts_as_isdoc.sqlite.db
4
+
5
+ sqlite3:
6
+ :adapter: sqlite3
7
+ :database: test/acts_as_isdoc.sqlite3.db
8
+
9
+ postgresql:
10
+ :adapter: postgresql
11
+ :username: postgres
12
+ :password: postgres
13
+ :database: acts_as_isdoc_test
14
+ :min_messages: ERROR
15
+
16
+ mysql:
17
+ :adapter: mysql
18
+ :host: localhost
19
+ :username: root
20
+ :password: password
21
+ :database: acts_as_isdoc_test
@@ -0,0 +1,104 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Invoice xmlns="http://isdoc.cz/namespace/invoice" version="5.2">
3
+ <DocumentType>1</DocumentType>
4
+ <ID>1234</ID>
5
+ <UUID>2D6D6400-D922-4DF5-8A76-EB68350B02AF</UUID>
6
+ <IssueDate>2009-07-01</IssueDate>
7
+ <OrderReferences>
8
+ <OrderReference>
9
+ <SalesOrderID/>
10
+ <ExternalOrderID>ABC1234</ExternalOrderID>
11
+ <IssueDate>2009-07-01</IssueDate>
12
+ </OrderReference>
13
+ </OrderReferences>
14
+ <LocalCurrencyCode>CZK</LocalCurrencyCode>
15
+ <CurrRate>1</CurrRate>
16
+ <RefCurrRate>1</RefCurrRate>
17
+ <AccountingSupplierParty>
18
+ <Party>
19
+ <PartyIdentification>
20
+ <ID></ID>
21
+ </PartyIdentification>
22
+ <PartyName>
23
+ <Name>Pepicek</Name>
24
+ </PartyName>
25
+ <PostalAddress>
26
+ <StreetName>Ulicni</StreetName>
27
+ <BuildingNumber>230/9</BuildingNumber>
28
+ <CityName>Praha</CityName>
29
+ <PostalZone>17000</PostalZone>
30
+ <Country>
31
+ <IdentificationCode>cz</IdentificationCode>
32
+ <Name>Czech Republic</Name>
33
+ </Country>
34
+ </PostalAddress>
35
+ <PartyTaxScheme>
36
+ <CompanyID>CZ12345678</CompanyID>
37
+ <TaxScheme>VAT</TaxScheme>
38
+ </PartyTaxScheme>
39
+ </Party>
40
+ </AccountingSupplierParty>
41
+ <AccountingCustomerParty>
42
+ <Party>
43
+ <PartyIdentification>
44
+ <ID></ID>
45
+ </PartyIdentification>
46
+ <PartyName>
47
+ <Name>Frantisek</Name>
48
+ </PartyName>
49
+ <PostalAddress>
50
+ <StreetName></StreetName>
51
+ <BuildingNumber></BuildingNumber>
52
+ <CityName></CityName>
53
+ <PostalZone></PostalZone>
54
+ <Country>
55
+ <IdentificationCode></IdentificationCode>
56
+ <Name></Name>
57
+ </Country>
58
+ </PostalAddress>
59
+ </Party>
60
+ </AccountingCustomerParty>
61
+ <InvoiceLines>
62
+ <InvoiceLine>
63
+ <ID>1</ID>
64
+ <LineExtensionAmount>0</LineExtensionAmount>
65
+ <LineExtensionAmountTaxInclusive>0</LineExtensionAmountTaxInclusive>
66
+ <LineExtensionTaxAmount>0</LineExtensionTaxAmount>
67
+ <UnitPrice>0</UnitPrice>
68
+ <UnitPriceTaxInclusive>0</UnitPriceTaxInclusive>
69
+ <ClassifiedTaxCategory>
70
+ <Percent>0</Percent>
71
+ <VATCalculationMethod>0</VATCalculationMethod>
72
+ </ClassifiedTaxCategory>
73
+ <Item>
74
+ </Item>
75
+ </InvoiceLine>
76
+ </InvoiceLines>
77
+ <TaxTotal>
78
+ <TaxSubTotal>
79
+ <TaxableAmount>0</TaxableAmount>
80
+ <TaxInclusiveAmount>0</TaxInclusiveAmount>
81
+ <TaxAmount>0</TaxAmount>
82
+ <AlreadyClaimedTaxableAmount>0</AlreadyClaimedTaxableAmount>
83
+ <AlreadyClaimedTaxAmount>0</AlreadyClaimedTaxAmount>
84
+ <AlreadyClaimedTaxInclusiveAmount>0</AlreadyClaimedTaxInclusiveAmount>
85
+ <DifferenceTaxableAmount>0</DifferenceTaxableAmount>
86
+ <DifferenceTaxAmount>0</DifferenceTaxAmount>
87
+ <DifferenceTaxInclusiveAmount>0</DifferenceTaxInclusiveAmount>
88
+ <TaxCategory>
89
+ <Percent>0</Percent>
90
+ </TaxCategory>
91
+ </TaxSubTotal>
92
+ <TaxAmount>0</TaxAmount>
93
+ </TaxTotal>
94
+ <LegalMonetaryTotal>
95
+ <TaxExclusiveAmount>0</TaxExclusiveAmount>
96
+ <TaxInclusiveAmount>0</TaxInclusiveAmount>
97
+ <AlreadyClaimedTaxExclusiveAmount>0</AlreadyClaimedTaxExclusiveAmount>
98
+ <AlreadyClaimedTaxInclusiveAmount>0</AlreadyClaimedTaxInclusiveAmount>
99
+ <DifferenceTaxExclusiveAmount>0</DifferenceTaxExclusiveAmount>
100
+ <DifferenceTaxInclusiveAmount>0</DifferenceTaxInclusiveAmount>
101
+ <PaidDepositsAmount>300</PaidDepositsAmount>
102
+ <PayableAmount>0</PayableAmount>
103
+ </LegalMonetaryTotal>
104
+ </Invoice>