acts_as_isdoc 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,5 +19,4 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency "htmlentities"
20
20
  gem.add_dependency "activesupport"
21
21
  gem.add_dependency "activerecord"
22
- gem.add_dependency "htmlentities"
23
22
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsIsdoc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -34,6 +34,8 @@ class ISDOCOutputBuilder
34
34
  invoice.encoded_tag! :CurrRate, 1
35
35
  invoice.encoded_tag! :RefCurrRate, 1
36
36
 
37
+ build_dispatches(invoice)
38
+
37
39
  invoice.encoded_tag! :AccountingSupplierParty do |supplier|
38
40
  build_party supplier, seller_details
39
41
  end
@@ -209,6 +211,26 @@ class ISDOCOutputBuilder
209
211
  end
210
212
  end
211
213
 
214
+ def build_dispatches(xml)
215
+ if ledger_item.respond_to?(:dispatches) && dispatches
216
+ xml.tag! :Extensions do |extensions|
217
+ extensions.tag! :Dispatches, :xmlns => "http://czreg.cz/isdoc/namespace/dispatch-1.0" do |disps|
218
+ dispatches.each_key do |dispatch|
219
+ disps.encoded_tag! "Dispatch" do |disp|
220
+ if dispatch == :emails
221
+ Array(dispatches[dispatch]).each do |email|
222
+ disp.encoded_tag! "Email", email
223
+ end
224
+ else
225
+ disp.encoded_tag! dispatch.to_s.capitalize, dispatches[dispatch]
226
+ end
227
+ end
228
+ end
229
+ end
230
+ end
231
+ end
232
+ end
233
+
212
234
  def method_missing(method_id, *args, &block)
213
235
  # method renaming if requested in options
214
236
  if options.has_key?(method_id.to_sym)
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <!--
4
+ This schema does not define anything, it just imports other schemas
5
+ and makes the usage of ISDOC schemas more convenient.
6
+ -->
7
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
8
+ targetNamespace="http://www.czreg.cz/xml/isdoc/all-1.0"
9
+ xmlns:all="http://www.czreg.cz/xml/isdoc/all-1.0"
10
+ elementFormDefault="qualified"
11
+ version="1.0">
12
+
13
+ <!--
14
+ Import all schemas related to ISDOC protocol.
15
+ Anytime the version of any imported schema is raised, the version of
16
+ 'all' schema must be raised too.
17
+ -->
18
+
19
+ <xs:import namespace="http://isdoc.cz/namespace/invoice"
20
+ schemaLocation="isdoc-invoice-dsig-5.2.xsd"/>
21
+ <!-- ISDOC extensions -->
22
+ <xs:import namespace="http://czreg.cz/isdoc/namespace/domain-1.0"
23
+ schemaLocation="czreg-domain-1.0.xsd"/>
24
+ <xs:import namespace="http://czreg.cz/isdoc/namespace/dispatch-1.0"
25
+ schemaLocation="czreg-domain-1.0.xsd"/>
26
+
27
+ <xs:annotation>
28
+ <xs:documentation>
29
+ ISDOC (Information System Document) v5.2
30
+ with domain schema and dispatch grouped together
31
+ </xs:documentation>
32
+ </xs:annotation>
33
+
34
+ </xs:schema>
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
+ targetNamespace="http://czreg.cz/isdoc/namespace/dispatch-1.0"
5
+ xmlns:domain="http://czreg.cz/isdoc/namespace/dispatch-1.0"
6
+ xmlns:invoice="http://isdoc.cz/namespace/invoice"
7
+ elementFormDefault="qualified"
8
+ version="1.0">
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ Extension for distributing invoice to parties. It includes type of dispatch
13
+ and optionall email address for EmailDelivery type.
14
+ </xs:documentation>
15
+ </xs:annotation>
16
+
17
+ <!--
18
+ Object identifier type.
19
+ -->
20
+ <xs:element name="Dispatches">
21
+ <xs:annotation>
22
+ <xs:documentation xml:lang="cs">Kolekce způsobů doručení</xs:documentation>
23
+ <xs:documentation xml:lang="en">Collection of dispatch methods</xs:documentation>
24
+ </xs:annotation>
25
+ <xs:complexType>
26
+ <xs:sequence>
27
+ <xs:element name="Dispatch" type="DispatchType" minOccurs="1" maxOccurs="unbounded" />
28
+ </xs:sequence>
29
+ </xs:complexType>
30
+ </xs:element>
31
+
32
+ <xs:complexType name="DispatchType">
33
+ <xs:sequence>
34
+ <!-- normal, recorder delivery, proof of delivery -->
35
+ <xs:element name="Postage" minOccurs="0" maxOccurs="1" />
36
+ <xs:element name="Email" minOccurs="0" maxOccurs="1" />
37
+ </xs:sequence>
38
+ </xs:complexType>
39
+
40
+ </xs:schema>
41
+
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
4
+ targetNamespace="http://czreg.cz/isdoc/namespace/domain-1.0"
5
+ xmlns:domain="http://czreg.cz/isdoc/namespace/domain-1.0"
6
+ xmlns:invoice="http://isdoc.cz/namespace/invoice"
7
+ elementFormDefault="qualified"
8
+ version="1.0">
9
+
10
+ <xs:annotation>
11
+ <xs:documentation>
12
+ Extension for domains to ISDOC. There is Domains sequence in Extension element.
13
+ Sequence is made of Domain elements, each of them having required name and optional
14
+ Since and Till elements.
15
+ </xs:documentation>
16
+ </xs:annotation>
17
+
18
+ <!--
19
+ Object identifier type.
20
+ -->
21
+ <xs:element name="Domains">
22
+ <xs:annotation>
23
+ <xs:documentation xml:lang="cs">Jména domén s délkou jejich platností</xs:documentation>
24
+ <xs:documentation xml:lang="en">Domains with name and its validity </xs:documentation>
25
+ </xs:annotation>
26
+ <xs:complexType>
27
+ <xs:sequence>
28
+ <xs:element name="Domain" type="domain:domainType" minOccurs="1" maxOccurs="unbounded" />
29
+ </xs:sequence>
30
+ </xs:complexType>
31
+ </xs:element>
32
+
33
+ <xs:complexType name="domainType">
34
+ <xs:sequence>
35
+ <xs:element name="Name" minOccurs="1" maxOccurs="1" />
36
+ <xs:element name="Since" minOccurs="0" maxOccurs="1" />
37
+ <xs:element name="Till" minOccurs="0" maxOccurs="1" />
38
+ </xs:sequence>
39
+ </xs:complexType>
40
+
41
+ </xs:schema>
42
+
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/test_helper.rb'
3
3
  require File.dirname(__FILE__) + '/fixtures/sample_invoice.rb'
4
4
  require File.dirname(__FILE__) + '/fixtures/basic_invoice.rb'
5
5
  require File.dirname(__FILE__) + '/fixtures/extended_invoice.rb'
6
+ require File.dirname(__FILE__) + '/fixtures/dispatched_invoice.rb'
6
7
 
7
8
  class ActsAsIsdocTest < ActiveSupport::TestCase
8
9
 
@@ -42,4 +43,14 @@ class ActsAsIsdocTest < ActiveSupport::TestCase
42
43
  assert_file_equals(isdoc_file, fixture_file)
43
44
  end
44
45
 
46
+ test "returned dispatched isdoc is valid" do
47
+ assert valid_isdoc?(DispatchedInvoice.new.render_isdoc)
48
+ end
49
+
50
+ test "returned dispatched isdoc is correct" do
51
+ isdoc_file = create_tmp_file("isdoc", DispatchedInvoice.new.render_isdoc)
52
+ fixture_file = File.join(File.dirname(__FILE__), "..", "test", "fixtures", "dispatched_invoice.isdoc")
53
+ assert_file_equals(isdoc_file, fixture_file)
54
+ end
55
+
45
56
  end
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <Invoice xmlns="http://isdoc.cz/namespace/invoice" version="5.2">
2
+ <Invoice version="5.2" xmlns="http://isdoc.cz/namespace/invoice">
3
3
  <DocumentType>1</DocumentType>
4
4
  <ID>1234</ID>
5
5
  <UUID>2D6D6400-D922-4DF5-8A76-EB68350B02AF</UUID>
@@ -0,0 +1,115 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Invoice version="5.2" xmlns="http://isdoc.cz/namespace/invoice">
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
+ <Extensions>
18
+ <Dispatches xmlns="http://czreg.cz/isdoc/namespace/dispatch-1.0">
19
+ <Dispatch>
20
+ <Email>joska@koska.cz</Email>
21
+ <Email>koska@koska.cz</Email>
22
+ </Dispatch>
23
+ <Dispatch>
24
+ <Postage>common</Postage>
25
+ </Dispatch>
26
+ </Dispatches>
27
+ </Extensions>
28
+ <AccountingSupplierParty>
29
+ <Party>
30
+ <PartyIdentification>
31
+ <ID></ID>
32
+ </PartyIdentification>
33
+ <PartyName>
34
+ <Name>Pepicek</Name>
35
+ </PartyName>
36
+ <PostalAddress>
37
+ <StreetName>Ulicni</StreetName>
38
+ <BuildingNumber>230/9</BuildingNumber>
39
+ <CityName>Praha</CityName>
40
+ <PostalZone>17000</PostalZone>
41
+ <Country>
42
+ <IdentificationCode>cz</IdentificationCode>
43
+ <Name>Czech Republic</Name>
44
+ </Country>
45
+ </PostalAddress>
46
+ <PartyTaxScheme>
47
+ <CompanyID>CZ12345678</CompanyID>
48
+ <TaxScheme>VAT</TaxScheme>
49
+ </PartyTaxScheme>
50
+ </Party>
51
+ </AccountingSupplierParty>
52
+ <AccountingCustomerParty>
53
+ <Party>
54
+ <PartyIdentification>
55
+ <ID></ID>
56
+ </PartyIdentification>
57
+ <PartyName>
58
+ <Name>Frantisek</Name>
59
+ </PartyName>
60
+ <PostalAddress>
61
+ <StreetName></StreetName>
62
+ <BuildingNumber></BuildingNumber>
63
+ <CityName></CityName>
64
+ <PostalZone></PostalZone>
65
+ <Country>
66
+ <IdentificationCode></IdentificationCode>
67
+ <Name></Name>
68
+ </Country>
69
+ </PostalAddress>
70
+ </Party>
71
+ </AccountingCustomerParty>
72
+ <InvoiceLines>
73
+ <InvoiceLine>
74
+ <ID>1</ID>
75
+ <LineExtensionAmount>0</LineExtensionAmount>
76
+ <LineExtensionAmountTaxInclusive>0</LineExtensionAmountTaxInclusive>
77
+ <LineExtensionTaxAmount>0</LineExtensionTaxAmount>
78
+ <UnitPrice>0</UnitPrice>
79
+ <UnitPriceTaxInclusive>0</UnitPriceTaxInclusive>
80
+ <ClassifiedTaxCategory>
81
+ <Percent>0</Percent>
82
+ <VATCalculationMethod>0</VATCalculationMethod>
83
+ </ClassifiedTaxCategory>
84
+ <Item>
85
+ </Item>
86
+ </InvoiceLine>
87
+ </InvoiceLines>
88
+ <TaxTotal>
89
+ <TaxSubTotal>
90
+ <TaxableAmount>0</TaxableAmount>
91
+ <TaxInclusiveAmount>0</TaxInclusiveAmount>
92
+ <TaxAmount>0</TaxAmount>
93
+ <AlreadyClaimedTaxableAmount>0</AlreadyClaimedTaxableAmount>
94
+ <AlreadyClaimedTaxAmount>0</AlreadyClaimedTaxAmount>
95
+ <AlreadyClaimedTaxInclusiveAmount>0</AlreadyClaimedTaxInclusiveAmount>
96
+ <DifferenceTaxableAmount>0</DifferenceTaxableAmount>
97
+ <DifferenceTaxAmount>0</DifferenceTaxAmount>
98
+ <DifferenceTaxInclusiveAmount>0</DifferenceTaxInclusiveAmount>
99
+ <TaxCategory>
100
+ <Percent>0</Percent>
101
+ </TaxCategory>
102
+ </TaxSubTotal>
103
+ <TaxAmount>0</TaxAmount>
104
+ </TaxTotal>
105
+ <LegalMonetaryTotal>
106
+ <TaxExclusiveAmount>0</TaxExclusiveAmount>
107
+ <TaxInclusiveAmount>0</TaxInclusiveAmount>
108
+ <AlreadyClaimedTaxExclusiveAmount>0</AlreadyClaimedTaxExclusiveAmount>
109
+ <AlreadyClaimedTaxInclusiveAmount>0</AlreadyClaimedTaxInclusiveAmount>
110
+ <DifferenceTaxExclusiveAmount>0</DifferenceTaxExclusiveAmount>
111
+ <DifferenceTaxInclusiveAmount>0</DifferenceTaxInclusiveAmount>
112
+ <PaidDepositsAmount>300</PaidDepositsAmount>
113
+ <PayableAmount>0</PayableAmount>
114
+ </LegalMonetaryTotal>
115
+ </Invoice>
@@ -0,0 +1,7 @@
1
+ # -*- encoding : utf-8 -*-
2
+ class DispatchedInvoice < BasicInvoice
3
+ def dispatches
4
+ {:emails => ["joska@koska.cz", "koska@koska.cz"],
5
+ :postage => "common"}
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <Invoice xmlns="http://isdoc.cz/namespace/invoice" version="5.2">
2
+ <Invoice version="5.2" xmlns="http://isdoc.cz/namespace/invoice">
3
3
  <DocumentType>1</DocumentType>
4
4
  <ID>1234</ID>
5
5
  <UUID>2D6D6400-D922-4DF5-8A76-EB68350B02AF</UUID>
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <Invoice xmlns="http://isdoc.cz/namespace/invoice" version="5.2">
2
+ <Invoice version="5.2" xmlns="http://isdoc.cz/namespace/invoice">
3
3
  <DocumentType>1</DocumentType>
4
4
  <ID>123</ID>
5
5
  <UUID>2D6D6400-D922-4DF5-8A76-EB68350B02AF</UUID>
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  # validation code taken from http://htmltest.googlecode.com/svn/trunk/html_test/lib/validator.rb
42
42
  def valid_isdoc?(body)
43
- schema = File.join(File.dirname(__FILE__), "..", "schema", "isdoc-invoice-5.2.xsd")
43
+ schema = File.join(File.dirname(__FILE__), "..", "schema", "czreg-all-1.0.xsd")
44
44
  error_file = create_tmp_file("xmllint_error")
45
45
  doc_file = command = nil
46
46
  doc_file = create_tmp_file("xmllint", body)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_isdoc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jiri Kubicek
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-21 00:00:00 Z
18
+ date: 2013-06-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: builder
@@ -73,20 +73,6 @@ dependencies:
73
73
  version: "0"
74
74
  type: :runtime
75
75
  version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: htmlentities
78
- prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
88
- type: :runtime
89
- version_requirements: *id005
90
76
  description: Rendering business objects in ISDOC format
91
77
  email:
92
78
  - jiri.kubicek@kraxnet.cz
@@ -109,6 +95,9 @@ files:
109
95
  - lib/acts_as_isdoc/version.rb
110
96
  - lib/isdoc_output_builder.rb
111
97
  - lib/tasks/acts_as_isdoc_tasks.rake
98
+ - schema/czreg-all-1.0.xsd
99
+ - schema/czreg-dispatch-1.0.xsd
100
+ - schema/czreg-domain-1.0.xsd
112
101
  - schema/isdoc-invoice-5.2.xsd
113
102
  - schema/isdoc-invoice-dsig-5.2.xsd
114
103
  - schema/xmldsig-core-schema.xsd
@@ -116,6 +105,8 @@ files:
116
105
  - test/database.yml
117
106
  - test/fixtures/basic_invoice.isdoc
118
107
  - test/fixtures/basic_invoice.rb
108
+ - test/fixtures/dispatched_invoice.isdoc
109
+ - test/fixtures/dispatched_invoice.rb
119
110
  - test/fixtures/extended_invoice.isdoc
120
111
  - test/fixtures/extended_invoice.rb
121
112
  - test/fixtures/sample_invoice.isdoc
@@ -161,6 +152,8 @@ test_files:
161
152
  - test/database.yml
162
153
  - test/fixtures/basic_invoice.isdoc
163
154
  - test/fixtures/basic_invoice.rb
155
+ - test/fixtures/dispatched_invoice.isdoc
156
+ - test/fixtures/dispatched_invoice.rb
164
157
  - test/fixtures/extended_invoice.isdoc
165
158
  - test/fixtures/extended_invoice.rb
166
159
  - test/fixtures/sample_invoice.isdoc