secretariat 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3574ab368be0c92f96a25ad98e00f9c17a96da895d1ce3046a1c387eecf43d75
4
- data.tar.gz: 90630718af00d0a76af1d75173d58f6c94f7eaf2485dafd9a75a773c2e2f7a97
3
+ metadata.gz: e6d3c5177f9a94e1341b1b533cfe34b91f9babe7eafa5d483cbf4b5f489509c0
4
+ data.tar.gz: d51e684d34ac4fc61007cd6243c26cc8cfd31df95799b39079841d6e23b352f8
5
5
  SHA512:
6
- metadata.gz: c3d9e62d62321d142b502e32b01198256cb22e65b4f0502c071a525a96ae4dff5200d54ca2313a985bad0571c923ebb8c044f5b12b4fd3b1260a4799d2a743cc
7
- data.tar.gz: 39ea3264258a3e058b24276caf8232d53db7516b1d10aa2cee66807ee25d601bb68413d61f18125021fcd0bad6bbced1aad14f4b7126392991984f5b8f6dc5db
6
+ metadata.gz: a1c7ea742126169c1b97b0ce347d8d7f6830f5eabb5542b814ae9313c9a0c4d904076124fccd18a182e217ce1a4e87008bc6e5350f7f53b562fee8795855486e
7
+ data.tar.gz: f228bac7b78241d5437b61fb1d9505c0ebb2ed2608f7489cf5145da34a662b5efd50a87090cf3b9ca27af9e2af6708865e3cf7039e0c466fc48711f3347017cb
data/README.md CHANGED
@@ -1,22 +1,20 @@
1
1
  # A ZUGFeRD xml generator and validator
2
2
 
3
- More info coming soon. See tests for examples.
3
+ See tests for examples.
4
4
 
5
5
  # Some words of caution
6
6
 
7
7
  1. This is an opinionated library optimised for my very specific usecase
8
8
  2. While I did start to add some validations to make sure you can't input absolute garbage into this, I cannot guarantee factual (as in taxation law) correctness of the resulting XML.
9
- 3. This does not contain any code to attach the XML to a PDF file, mainly because I have yet to find a ruby library to do that.
9
+ 1. The library, for ZUGFeRD 2.x, currently only supports the EN16931 variant. This is probably what you want as well. PRs welcome.
10
+ 3. This does not contain any code to attach the XML to a PDF file, mainly because I have yet to find a ruby library to do that. For software that does this, take a look at [this python library](https://github.com/akretion/factur-x).
10
11
 
11
12
  # LICENSE
12
13
 
13
14
  See [LICENSE](LICENSE).
14
15
 
15
- Additionally, this project contains material, such as the schema files, which,
16
- according to the ZUGFeRD documentation, are also licensed under the Apache
17
- License.
16
+ Additionally, this project contains material, such as the schema files, which, according to the ZUGFeRD documentation, are also licensed under the Apache License.
18
17
 
19
- Additionally, this project uses nokogiri and schematron-nokogiri, both
20
- licensed unter the MIT license.
18
+ Additionally, this project uses nokogiri and [SchXslt](https://github.com/schxslt/schxslt), both licensed unter the MIT license.
21
19
 
22
20
 
Binary file
@@ -15,25 +15,24 @@ limitations under the License.
15
15
  =end
16
16
 
17
17
  require 'nokogiri'
18
- require 'schematron-nokogiri'
19
- require 'open-uri'
20
18
 
21
19
  module Secretariat
22
20
  class Validator
23
21
  SCHEMATRON = [
24
22
  '../../schemas/zugferd_1/ZUGFeRD1p0.sch',
25
- '../../schemas/zugferd_2/zf_en16931.sch'
23
+ '../../schemas/factur-x_1.0.0.7/Factur-X_1.0.07_EN16931.sch'
26
24
  ]
27
25
 
28
26
  SCHEMA = [
29
27
  '../../schemas/zugferd_1/ZUGFeRD1p0.xsd',
30
- '../../schemas/zugferd_2/zf_en16931.xsd'
28
+ '../../schemas/factur-x_1.0.0.7/Factur-X_1.0.07_EN16931.xsd'
31
29
  ]
32
30
 
33
31
  SCHEMA_DIR = [
34
32
  '../../schemas/zugferd_1',
35
- '../../schemas/zugferd_2'
33
+ '../../schemas/factur-x_1.0.0.7/'
36
34
  ]
35
+
37
36
  attr_accessor :doc, :version
38
37
  def initialize(io_or_str, version: 1)
39
38
  @doc = Nokogiri.XML(io_or_str)
@@ -44,10 +43,8 @@ module Secretariat
44
43
  Nokogiri::XML.Schema open(File.join(__dir__, SCHEMA[version - 1]))
45
44
  end
46
45
 
47
- def schematron
48
- SchematronNokogiri::Schema.new(
49
- Nokogiri::XML(open(File.join(__dir__, SCHEMATRON[version - 1])))
50
- )
46
+ def schematron_path
47
+ File.join(__dir__, SCHEMATRON[version - 1])
51
48
  end
52
49
 
53
50
  def validate_against_schema
@@ -55,11 +52,13 @@ module Secretariat
55
52
  end
56
53
 
57
54
  def validate_against_schematron
58
- result = []
59
- Dir.chdir File.join(__dir__, SCHEMA_DIR[version - 1]) do
60
- result = schematron.validate(doc)
55
+ Dir.mktmpdir do |dir|
56
+ docpath = File.join(dir, 'doc.xml')
57
+ File.write(docpath, doc, mode: 'wb')
58
+ out = `java -jar bin/schxslt-cli.jar -v -d #{docpath} -s #{schematron_path}`
59
+ return [] if out.match("[valid]")
60
+ out.lines
61
61
  end
62
- result
63
62
  end
64
63
  end
65
64
  end
@@ -15,5 +15,5 @@ limitations under the License.
15
15
  =end
16
16
 
17
17
  module Secretariat
18
- VERSION = '2.0.0'
18
+ VERSION = '3.0.0'
19
19
  end