facturx 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -3
- data/README.md +40 -8
- data/lib/facturx/builders/association.rb +8 -0
- data/lib/facturx/builders/base.rb +129 -0
- data/lib/facturx/builders/schema.rb +112 -0
- data/lib/facturx/builders.rb +25 -0
- data/lib/facturx/conformance.rb +163 -0
- data/lib/facturx/error.rb +3 -0
- data/lib/facturx/format.rb +85 -0
- data/lib/facturx/generate.rb +21 -0
- data/lib/facturx/profile_resolver.rb +40 -0
- data/lib/facturx/reader/semantic_mapper/line_mapping.rb +1 -1
- data/lib/facturx/reader/semantic_mapper/line_references.rb +19 -0
- data/lib/facturx/reader/semantic_mapper/payment_mapping.rb +48 -11
- data/lib/facturx/reader/semantic_mapper.rb +9 -0
- data/lib/facturx/reader/term_reader.rb +12 -4
- data/lib/facturx/reader.rb +3 -7
- data/lib/facturx/version.rb +1 -1
- data/lib/facturx/writer/context.rb +53 -0
- data/lib/facturx/writer/stage.rb +47 -0
- data/lib/facturx/writer/stage_support/contact_details.rb +57 -0
- data/lib/facturx/writer/stage_support/emission.rb +78 -0
- data/lib/facturx/writer/stage_support/identifiers.rb +129 -0
- data/lib/facturx/writer/stage_support/structure.rb +88 -0
- data/lib/facturx/writer/stages/document_context.rb +31 -0
- data/lib/facturx/writer/stages/exchanged_document.rb +32 -0
- data/lib/facturx/writer/stages/trade_agreement/parties.rb +105 -0
- data/lib/facturx/writer/stages/trade_agreement/references.rb +92 -0
- data/lib/facturx/writer/stages/trade_agreement.rb +45 -0
- data/lib/facturx/writer/stages/trade_delivery.rb +77 -0
- data/lib/facturx/writer/stages/trade_lines/agreement.rb +92 -0
- data/lib/facturx/writer/stages/trade_lines/product.rb +78 -0
- data/lib/facturx/writer/stages/trade_lines/quantity.rb +17 -0
- data/lib/facturx/writer/stages/trade_lines/settlement.rb +89 -0
- data/lib/facturx/writer/stages/trade_lines.rb +67 -0
- data/lib/facturx/writer/stages/trade_settlement/parties.rb +33 -0
- data/lib/facturx/writer/stages/trade_settlement/payment.rb +97 -0
- data/lib/facturx/writer/stages/trade_settlement/summary.rb +88 -0
- data/lib/facturx/writer/stages/trade_settlement/taxes.rb +121 -0
- data/lib/facturx/writer/stages/trade_settlement.rb +70 -0
- data/lib/facturx/writer.rb +68 -0
- data/lib/facturx/xml/namespaces.rb +19 -0
- data/lib/facturx/xml/profile_detector.rb +2 -4
- data/lib/facturx.rb +28 -0
- data/rbi/facturx.rbi +1090 -0
- metadata +38 -4
data/lib/facturx.rb
CHANGED
|
@@ -5,13 +5,18 @@ require 'facturx/error'
|
|
|
5
5
|
require 'facturx/embedding'
|
|
6
6
|
require 'facturx/profile'
|
|
7
7
|
require 'facturx/profiles'
|
|
8
|
+
require 'facturx/profile_resolver'
|
|
8
9
|
require 'facturx/term'
|
|
9
10
|
require 'facturx/group'
|
|
10
11
|
require 'facturx/terms'
|
|
11
12
|
require 'facturx/model'
|
|
13
|
+
require 'facturx/document'
|
|
14
|
+
require 'facturx/builders'
|
|
12
15
|
require 'facturx/diagnostic'
|
|
13
16
|
require 'facturx/reading'
|
|
14
17
|
require 'facturx/coerce'
|
|
18
|
+
require 'facturx/format'
|
|
19
|
+
require 'facturx/conformance'
|
|
15
20
|
require 'facturx/xml/verifier'
|
|
16
21
|
require 'facturx/pdf/document'
|
|
17
22
|
require 'facturx/pdf/inspector'
|
|
@@ -20,12 +25,21 @@ require 'facturx/pdf/verifier'
|
|
|
20
25
|
require 'facturx/composers/ghostscript'
|
|
21
26
|
require 'facturx/attach'
|
|
22
27
|
require 'facturx/reader'
|
|
28
|
+
require 'facturx/writer'
|
|
29
|
+
require 'facturx/generate'
|
|
23
30
|
|
|
24
31
|
module Facturx
|
|
25
32
|
DEFAULT_ATTACHER = Attach.new
|
|
26
33
|
DEFAULT_READER = Reader.new
|
|
34
|
+
DEFAULT_PROFILE_RESOLVER = ProfileResolver.new
|
|
35
|
+
DEFAULT_WRITER = Writer.new
|
|
36
|
+
DEFAULT_GENERATOR = Generate.new(writer: DEFAULT_WRITER, attacher: DEFAULT_ATTACHER,
|
|
37
|
+
profile_resolver: DEFAULT_PROFILE_RESOLVER)
|
|
27
38
|
private_constant :DEFAULT_ATTACHER
|
|
28
39
|
private_constant :DEFAULT_READER
|
|
40
|
+
private_constant :DEFAULT_PROFILE_RESOLVER
|
|
41
|
+
private_constant :DEFAULT_WRITER
|
|
42
|
+
private_constant :DEFAULT_GENERATOR
|
|
29
43
|
|
|
30
44
|
class << self
|
|
31
45
|
def verify_xml(xml:)
|
|
@@ -44,5 +58,19 @@ module Facturx
|
|
|
44
58
|
def read(source, on_unknown_profile: :fallback)
|
|
45
59
|
DEFAULT_READER.call(source, on_unknown_profile:)
|
|
46
60
|
end
|
|
61
|
+
|
|
62
|
+
def validate_document(document:, profile:)
|
|
63
|
+
canonical_profile = DEFAULT_PROFILE_RESOLVER.call(profile)
|
|
64
|
+
DEFAULT_WRITER.validate(document:, profile: canonical_profile)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def build_xml(document:, profile:)
|
|
68
|
+
canonical_profile = DEFAULT_PROFILE_RESOLVER.call(profile)
|
|
69
|
+
DEFAULT_WRITER.call(document:, profile: canonical_profile)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def generate(pdf:, document:, profile:)
|
|
73
|
+
DEFAULT_GENERATOR.call(pdf:, document:, profile:)
|
|
74
|
+
end
|
|
47
75
|
end
|
|
48
76
|
end
|