gobl 0.16.0 → 0.17.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: 14bd34289a0ba3fff84bdefe4fd1fedb84fcf914f446c1c6f2911aa322909154
4
- data.tar.gz: fff37f189098fa49e3f01cb526cf1985321c068e99bd424fd1d21642daac299e
3
+ metadata.gz: a6c8e7f19ff84fd4088b793969af198ee03411e09265071ff3f9b7ec75ff78fc
4
+ data.tar.gz: 8154a6f7ffd4e2c94dfa5a8ff856fe21abb37b20f3ef651830bd53e8455f7b67
5
5
  SHA512:
6
- metadata.gz: c48f0af106b03682ccabd1191db9ee2c00205719c8dfa809e4fb1437c9bc3b8340ca76e0989ac4743b25e14479995feeb6cce6ac3394cbe147d8ef958a9a17ec
7
- data.tar.gz: 0a4a47d068d70aa46717be6a34a50f3a694a1bc2de618e46c6005be1059a9ab1a696e10116ce59bdd6335d097d418ad936b973bfcc7d4880c5d7691fbe1c56d7
6
+ metadata.gz: 32c5009e9bc9e6bc6aae5f36e3c5f15147d634fad2b2bcbb8d22a4543b2f3cc9f8ef982ae4a48fb8188aa2cc4e509be5d64a32673cd36a4039605b438f77be9e
7
+ data.tar.gz: a6c1a18a2d275ee6fdfe0aa5677f0f7691271a03af51bdd63b0b397ae71013a2daad978babd1c1a6137aa6ebb69afbee283bc2e38ec2dc3daa354c452f0081df
data/README.md CHANGED
@@ -81,12 +81,12 @@ GOBL is a JSON format. So, you'll probably need to read or produce valid GOBL JS
81
81
 
82
82
  ```ruby
83
83
  json = '{"$schema":"https://gobl.org/draft-0/note/message", "content":"Hello World!"}'
84
- document = GOBL::Document.from_json!(json) #=> #<GOBL::Document _value={"$schema"=>"https://gobl.org/draft-0/note/message", "content"=>"Hello World!"}>
84
+ document = GOBL::Schema::Object.from_json!(json) #=> #<GOBL::Schema::Object _value={"$schema"=>"https://gobl.org/draft-0/note/message", "content"=>"Hello World!"}>
85
85
  message = document.extract #=> #<GOBL::Note::Message title=nil content="Hello World!" meta=nil>
86
86
  message.content #=> "Hello World!"
87
87
  ```
88
88
 
89
- Note that, in the previous example, we parsed the JSON fragment as a document. A [document](https://docs.gobl.org/core/documents) is one of the fundamental entities of GOBL, and it represents a business document in an abstract way. To get the specific document type instantiated –a message, in the example above–, we needed to call the [`#extract`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FDocumentHelper:extract) method of the document object.
89
+ Note that, in the previous example, we parsed the JSON fragment as a document. A [document](https://docs.gobl.org/core/documents) is one of the fundamental entities of GOBL, and it represents a business document in an abstract way. To get the specific document type instantiated –a message, in the example above–, we needed to call the [`#extract`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FSchema%2FObjectHelper:extract) method of the document object.
90
90
 
91
91
  The previous instantiation method is useful if you don't know the document type in advance. If you do, you could also instantiate the object in this more direct way:
92
92
 
@@ -103,15 +103,15 @@ message = GOBL::Note::Message.new(content: 'Hello World!')
103
103
  message.to_json #=> "{\"content\":\"Hello World!\"}"
104
104
  ```
105
105
 
106
- Note that, in the previous example, the generated JSON doesn't include a `$schema` attribute. This is because the GOBL schema doesn't require that attribute in a standalone message structure. If you want to use that structure as a document, you will need a `$schema` to be present. You can get that from your Ruby code by simply [_embedding_](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FDocumentHelper%2FClassMethods:embed) the struct in a document:
106
+ Note that, in the previous example, the generated JSON doesn't include a `$schema` attribute. This is because the GOBL schema doesn't require that attribute in a standalone message structure. If you want to use that structure as a document, you will need a `$schema` to be present. You can get that from your Ruby code by simply [_embedding_](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FSchema%2FObjectHelper%2FClassMethods:embed) the struct in a document:
107
107
 
108
108
  ```ruby
109
109
  message = GOBL::Note::Message.new(content: 'Hello World!')
110
- document = GOBL::Document.embed(message)
110
+ document = GOBL::Schema::Object.embed(message)
111
111
  document.to_json #=> "{\"content\":\"Hello World!\",\"$schema\":\"https://gobl.org/draft-0/note/message\"}"
112
112
  ```
113
113
 
114
- _See also [`GOBL::Struct.from_json!`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FStruct%2Efrom_json!), [`GOBL::Struct#to_json`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FStruct:to_json), [`GOBL::Document#embed`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FDocumentHelper%2FClassMethods:embed), [`GOBL::Document.extract`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FDocumentHelper:extract)_
114
+ _See also [`GOBL::Struct.from_json!`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FStruct%2Efrom_json!), [`GOBL::Struct#to_json`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FStruct:to_json), [`GOBL::Schema::Object#embed`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FSchema%2FObjectHelper%2FClassMethods:embed), [`GOBL::Schema::Object.extract`](https://rubydoc.info/github/invopop/gobl.ruby/GOBL%2FExtensions%2FSchema%2FObjectHelper:extract)_
115
115
 
116
116
  ### Handling value objects and enumerations
117
117
 
@@ -179,7 +179,7 @@ invoice = GOBL::Bill::Invoice.new(
179
179
  taxes: [ { cat: 'VAT', rate: :standard } ]
180
180
  }]
181
181
  )
182
- document = GOBL::Document.embed(invoice)
182
+ document = GOBL::Schema::Object.embed(invoice)
183
183
  calculated_document = GOBL.build(document)
184
184
  calculated_invoice = calculated_document.extract
185
185
  calculated_invoice.totals.total_with_tax #=> "2178.00"
@@ -213,6 +213,8 @@ You can avoid mage and the docker container if you prefer so. Take a look at the
213
213
 
214
214
  The command `mage setup` fetches and installs all the required dependencies to use the gem.
215
215
 
216
+ If you run into any problems with dependencies, don't forget this is a library, so the Gemfile.lock is not included. Delete any local versions you may already have and re-run.
217
+
216
218
  #### Code generation
217
219
 
218
220
  Ensure all the GOBL JSON Schema and Regime files are available by manually copying the [base GOBL project](https://github.com/invopop/gobl)'s `build/` path to the `data/` path in this repository. For example, assuming you have GOBL at `../gobl/`, you can run this:
@@ -20,8 +20,8 @@ module GOBL
20
20
 
21
21
  # @!attribute [r] stamps
22
22
  # Stamps of the previous document to include in the preceding data.
23
- # @return [Array<GOBL::CBC::Stamp>]
24
- property :stamps, [GOBL::CBC::Stamp]
23
+ # @return [Array<GOBL::Head::Stamp>]
24
+ property :stamps, [GOBL::Head::Stamp]
25
25
 
26
26
  # @!attribute [r] credit
27
27
  # Credit when true indicates that the corrective document should cancel the previous document.
@@ -135,6 +135,11 @@ module GOBL
135
135
  # @return [Array<GOBL::CBC::Note>]
136
136
  property :notes, [GOBL::CBC::Note]
137
137
 
138
+ # @!attribute [r] complements
139
+ # Additional complementary objects that add relevant information to the invoice.
140
+ # @return [Array<GOBL::Schema::Object>]
141
+ property :complements, [GOBL::Schema::Object]
142
+
138
143
  # @!attribute [r] meta
139
144
  # Additional semi-structured data that doesn't fit into the body of the invoice.
140
145
  # @return [GOBL::CBC::Meta]
@@ -41,8 +41,8 @@ module GOBL
41
41
 
42
42
  # @!attribute [r] stamps
43
43
  # Seals of approval from other organisations that may need to be listed.
44
- # @return [Array<GOBL::CBC::Stamp>]
45
- property :stamps, [GOBL::CBC::Stamp]
44
+ # @return [Array<GOBL::Head::Stamp>]
45
+ property :stamps, [GOBL::Head::Stamp]
46
46
 
47
47
  # @!attribute [r] corrections
48
48
  # Tax regime specific keys reflecting why the preceding invoice is being replaced.
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.55.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Cal
11
+ # Civil date time in simplified ISO format with no time zone
12
+ # information, for example: 2021-05-26T13:45:00
13
+ class DateTime < String
14
+ # The Schema ID of the GOBL DateTime structure
15
+ SCHEMA_ID = 'https://gobl.org/draft-0/cal/date-time'
16
+ end
17
+ end
18
+ end
@@ -20,14 +20,14 @@ module GOBL
20
20
 
21
21
  # @!attribute [r] head
22
22
  # Details on what the contents are
23
- # @return [Header]
24
- property :head, Header
23
+ # @return [GOBL::Head::Header]
24
+ property :head, GOBL::Head::Header
25
25
  validates_presence_of :head
26
26
 
27
27
  # @!attribute [r] doc
28
28
  # The data inside the envelope
29
- # @return [Document]
30
- property :doc, Document
29
+ # @return [GOBL::Schema::Object]
30
+ property :doc, GOBL::Schema::Object
31
31
  validates_presence_of :doc
32
32
 
33
33
  # @!attribute [r] sigs
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.55.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Head
11
+ # Header defines the metadata of the body.
12
+ class Header < GOBL::Object
13
+ # The Schema ID of the GOBL Header structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/head/header'
15
+
16
+ # @!attribute [r] uuid
17
+ # Unique UUIDv1 identifier for the envelope.
18
+ # @return [GOBL::UUID::UUID]
19
+ property :uuid, GOBL::UUID::UUID
20
+ validates_presence_of :uuid
21
+
22
+ # @!attribute [r] dig
23
+ # Digest of the canonical JSON body.
24
+ # @return [GOBL::DSig::Digest]
25
+ property :dig, GOBL::DSig::Digest
26
+ validates_presence_of :dig
27
+
28
+ # @!attribute [r] stamps
29
+ # Seals of approval from other organisations that can only be added to non-draft envelopes.
30
+ # @return [Array<GOBL::Head::Stamp>]
31
+ property :stamps, [GOBL::Head::Stamp]
32
+
33
+ # @!attribute [r] tags
34
+ # Set of labels that describe but have no influence on the data.
35
+ # @return [Array<String>]
36
+ property :tags, [String]
37
+
38
+ # @!attribute [r] meta
39
+ # Additional semi-structured information about this envelope.
40
+ # @return [GOBL::CBC::Meta]
41
+ property :meta, GOBL::CBC::Meta
42
+
43
+ # @!attribute [r] notes
44
+ # Any information that may be relevant to other humans about this envelope
45
+ # @return [String]
46
+ property :notes, String
47
+
48
+ # @!attribute [r] draft
49
+ # When true, implies that this document should not be considered final. Digital signatures are optional.
50
+ # @return [Boolean]
51
+ property :draft, Boolean
52
+ end
53
+ end
54
+ end
@@ -7,11 +7,11 @@
7
7
  ##
8
8
 
9
9
  module GOBL
10
- module CBC
10
+ module Head
11
11
  # Stamp defines an official seal of approval from a third party like a governmental agency or intermediary and should thus be included in any official envelopes.
12
12
  class Stamp < GOBL::Object
13
13
  # The Schema ID of the GOBL Stamp structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/cbc/stamp'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/head/stamp'
15
15
 
16
16
  # @!attribute [r] prv
17
17
  # Identity of the agency used to create the stamp usually defined by each region.
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.55.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Schema
11
+ # Data object whose type is determined from the <code>$schema</code> property.
12
+ class Object < GOBL::Map
13
+ end
14
+ end
15
+ end
@@ -52,6 +52,11 @@ module GOBL
52
52
  # @return [GOBL::CBC::CodeMap]
53
53
  property :map, GOBL::CBC::CodeMap
54
54
 
55
+ # @!attribute [r] sources
56
+ # List of sources for the information contained in this category.
57
+ # @return [Array<Source>]
58
+ property :sources, [Source]
59
+
55
60
  # @!attribute [r] meta
56
61
  # Meta contains additional information about the category that is relevant for local frequently used formats.
57
62
  # @return [GOBL::CBC::Meta]
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.55.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # Source describes where the information for the taxes comes from.
12
+ class Source < GOBL::Object
13
+ # The Schema ID of the GOBL Source structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Source'
15
+
16
+ # @!attribute [r] title
17
+ # Title of the linked source to help distinguish between this and other links.
18
+ # @return [GOBL::I18n::String]
19
+ property :title, GOBL::I18n::String
20
+
21
+ # @!attribute [r] url
22
+ # URL for the website.
23
+ # @return [String]
24
+ property :url, String
25
+ validates_presence_of :url
26
+ end
27
+ end
28
+ end
@@ -11,7 +11,7 @@ module GOBL
11
11
 
12
12
  # Extracts the GOBL struct embedded in the envelope's document
13
13
  #
14
- # @see GOBL::Extensions::DocumentHelper#extract
14
+ # @see GOBL::Extensions::Schema::ObjectHelper#extract
15
15
  #
16
16
  # @return [GOBL::Struct] the GOBL struct embedded in the envelope's document
17
17
  def extract
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GOBL
4
+ module Extensions
5
+ module Schema
6
+ # Additional methods for the generated {GOBL::Schema::Object} class
7
+ module ObjectHelper
8
+ # Returns the Schema ID of the current document
9
+ #
10
+ # @return [GOBL::ID] the Schema ID
11
+ def schema
12
+ @schema ||= GOBL::ID.new(_map['$schema'])
13
+ end
14
+
15
+ # Extracts the GOBL struct embedded in the document. It determines the type of document
16
+ # currently embedded by reading the schema and attemps to instantiate the detected
17
+ # class.
18
+ #
19
+ # @return [GOBL::Struct] the GOBL struct embedded in the document
20
+ def extract
21
+ raise 'unknown schema' unless schema.gobl?
22
+
23
+ typs = ['GOBL']
24
+ schema.modules.each do |mod|
25
+ typs << mod.underscore.camelize
26
+ end
27
+ typs << schema.name.underscore.camelize
28
+ klass = typs.join('::').constantize
29
+
30
+ # Sanity check
31
+ raise "#{klass.name}::SCHEMA_ID expected to be '#{schema}'" unless schema == klass::SCHEMA_ID
32
+
33
+ klass.new _map.except('$schema')
34
+ end
35
+
36
+ module ClassMethods
37
+ # Embeds the given GOBL struct in a new object injecting the proper Schema ID.
38
+ #
39
+ # @return [Object] the object embedding the given struct
40
+ def embed(struct)
41
+ new struct.as_json.merge(
42
+ '$schema' => struct.class::SCHEMA_ID
43
+ )
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -10,7 +10,7 @@ module GOBL
10
10
  # GOBL.config.service_host = 'localhost'
11
11
  # GOBL.config.service_port = 8080
12
12
  #
13
- # doc = GOBL::Document.new(
13
+ # doc = GOBL::Schema::Object.new(
14
14
  # '$schema' => 'https://gobl.org/draft-0/bill/invoice',
15
15
  # 'code' => 'SAMPLE-001',
16
16
  # 'currency' => 'EUR',
@@ -27,31 +27,31 @@ module GOBL
27
27
  module Operations
28
28
  # @api private
29
29
  VALIDATABLE_TYPES = SIGNABLE_TYPES = BUILDABLE_TYPES = [
30
- GOBL::Document,
31
- GOBL::Envelope
30
+ GOBL::Envelope,
31
+ GOBL::Schema::Object
32
32
  ].freeze
33
33
 
34
34
  # Calculates and validates an envelope or document, wrapping it in an envelope if
35
35
  # requested.
36
36
  #
37
- # @param struct [GOBL::Document, GOBL::Envelope] the document or envelope to build.
37
+ # @param struct [GOBL::Schema::Object, GOBL::Envelope] the document or envelope to build.
38
38
  # @param envelop [Boolean] whether the operation should envelop the document.
39
39
  # @param draft [Boolean] whether the envelope should be flagged as a draft.
40
40
  #
41
- # @return [GOBL::Envelope, GOBL::Document] a built envelope or document.
41
+ # @return [GOBL::Envelope, GOBL::Schema::Object] a built envelope or document.
42
42
  #
43
43
  # @raise [GOBL::Operations::ServiceError] if the service returns any errors.
44
44
  #
45
45
  # @example Build a document without enveloping it.
46
- # invoice = GOBL::Document.from_json!(File.read('invoice.json'))
47
- # GOBL.build(invoice) #=> A new, calculated `GOBL::Document`
46
+ # invoice = GOBL::Schema::Object.from_json!(File.read('invoice.json'))
47
+ # GOBL.build(invoice) #=> A new, calculated `GOBL::Schema::Object`
48
48
  #
49
49
  # @example Build a document and wrap in a draft envelope.
50
- # invoice = GOBL::Document.from_json!(File.read('invoice.json'))
50
+ # invoice = GOBL::Schema::Object.from_json!(File.read('invoice.json'))
51
51
  # GOBL.build(invoice, envelop: true) #=> A calculated, draft `GOBL::Envelope`
52
52
  #
53
53
  # @example Build a document and wrap in a non-draft envelope.
54
- # invoice = GOBL::Document.from_json!(File.read('invoice.json'))
54
+ # invoice = GOBL::Schema::Object.from_json!(File.read('invoice.json'))
55
55
  # GOBL.build(invoice, envelop: true, draft: false) #=> A calculated, non-draft `GOBL::Envelope`
56
56
  #
57
57
  # @example Build an envelope.
@@ -75,13 +75,13 @@ module GOBL
75
75
  # Checks whether or not a document or envelope is valid according to the GOBL schema
76
76
  # and rules.
77
77
  #
78
- # @param struct [GOBL::Document, GOBL::Envelope] the document or the envelope to
78
+ # @param struct [GOBL::Schema::Object, GOBL::Envelope] the document or the envelope to
79
79
  # validate.
80
80
  #
81
81
  # @return [GOBL::ValidationResult] the result of the validations.
82
82
  #
83
83
  # @example Validate an invalid document.
84
- # document = GOBL::Document.from_json!(File.read('invalid_invoice.json'))
84
+ # document = GOBL::Schema::Object.from_json!(File.read('invalid_invoice.json'))
85
85
  # result = GOBL.validate(document)
86
86
  # result.valid? #=> false
87
87
  # result.errors #=> ['code: cannot be blank', 'totals: cannot be blank']
@@ -108,7 +108,7 @@ module GOBL
108
108
  # Signs a document or envelope, calculating, enveloping and validating it first if
109
109
  # needed. The signing key will be the one configured in the server.
110
110
  #
111
- # @param struct [GOBL::Document, GOBL::Envelope] the envelop or document to sign.
111
+ # @param struct [GOBL::Schema::Object, GOBL::Envelope] the envelop or document to sign.
112
112
  #
113
113
  # @return [GOBL::Envelope] a signed envelope.
114
114
  #
data/lib/gobl/struct.rb CHANGED
@@ -20,7 +20,7 @@ module GOBL
20
20
  if schema.name == 'envelope'
21
21
  GOBL::Envelope.new data
22
22
  else
23
- GOBL::Document.new data
23
+ GOBL::Schema::Object.new data
24
24
  end
25
25
  end
26
26
 
data/lib/gobl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GOBL
4
- VERSION = '0.16.0'
4
+ VERSION = '0.17.0'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -46,8 +46,8 @@ end
46
46
  # to get YARD parsing them properly.
47
47
 
48
48
  GOBL::I18n::String.include GOBL::Extensions::I18n::ValueKeysHelper
49
- GOBL::Document.include GOBL::Extensions::DocumentHelper
50
- GOBL::Document.extend GOBL::Extensions::DocumentHelper::ClassMethods
49
+ GOBL::Schema::Object.include GOBL::Extensions::Schema::ObjectHelper
50
+ GOBL::Schema::Object.extend GOBL::Extensions::Schema::ObjectHelper::ClassMethods
51
51
  GOBL::Envelope.include GOBL::Extensions::EnvelopeHelper
52
52
  GOBL::Tax::Regime.extend GOBL::Extensions::Tax::RegimeHelper::ClassMethods
53
53
  GOBL::Bill::Invoice.include GOBL::Extensions::Bill::InvoiceHelper
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luismi Cavalle
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-08-29 00:00:00.000000000 Z
14
+ date: 2023-10-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -87,21 +87,20 @@ files:
87
87
  - lib/generated/gobl/bill/tax.rb
88
88
  - lib/generated/gobl/bill/totals.rb
89
89
  - lib/generated/gobl/cal/date.rb
90
+ - lib/generated/gobl/cal/date_time.rb
90
91
  - lib/generated/gobl/cal/period.rb
91
92
  - lib/generated/gobl/cbc/code.rb
92
93
  - lib/generated/gobl/cbc/code_map.rb
93
- - lib/generated/gobl/cbc/code_set.rb
94
94
  - lib/generated/gobl/cbc/key.rb
95
95
  - lib/generated/gobl/cbc/meta.rb
96
96
  - lib/generated/gobl/cbc/note.rb
97
- - lib/generated/gobl/cbc/stamp.rb
98
97
  - lib/generated/gobl/currency/code.rb
99
98
  - lib/generated/gobl/currency/exchange_rate.rb
100
- - lib/generated/gobl/document.rb
101
99
  - lib/generated/gobl/dsig/digest.rb
102
100
  - lib/generated/gobl/dsig/signature.rb
103
101
  - lib/generated/gobl/envelope.rb
104
- - lib/generated/gobl/header.rb
102
+ - lib/generated/gobl/head/header.rb
103
+ - lib/generated/gobl/head/stamp.rb
105
104
  - lib/generated/gobl/i18n/string.rb
106
105
  - lib/generated/gobl/l10n/code.rb
107
106
  - lib/generated/gobl/l10n/country_code.rb
@@ -128,6 +127,7 @@ files:
128
127
  - lib/generated/gobl/pay/instructions.rb
129
128
  - lib/generated/gobl/pay/online.rb
130
129
  - lib/generated/gobl/pay/terms.rb
130
+ - lib/generated/gobl/schema/object.rb
131
131
  - lib/generated/gobl/tax/category.rb
132
132
  - lib/generated/gobl/tax/category_total.rb
133
133
  - lib/generated/gobl/tax/code_definition.rb
@@ -143,6 +143,7 @@ files:
143
143
  - lib/generated/gobl/tax/scenario.rb
144
144
  - lib/generated/gobl/tax/scenario_set.rb
145
145
  - lib/generated/gobl/tax/set.rb
146
+ - lib/generated/gobl/tax/source.rb
146
147
  - lib/generated/gobl/tax/total.rb
147
148
  - lib/generated/gobl/tax/zone.rb
148
149
  - lib/generated/gobl/uuid/uuid.rb
@@ -151,9 +152,9 @@ files:
151
152
  - lib/gobl/enum.rb
152
153
  - lib/gobl/extensions/bill/invoice_helper.rb
153
154
  - lib/gobl/extensions/bill/scenario_summary.rb
154
- - lib/gobl/extensions/document_helper.rb
155
155
  - lib/gobl/extensions/envelope_helper.rb
156
156
  - lib/gobl/extensions/i18n/value_keys_helper.rb
157
+ - lib/gobl/extensions/schema/object_helper.rb
157
158
  - lib/gobl/extensions/tax/regime_helper.rb
158
159
  - lib/gobl/id.rb
159
160
  - lib/gobl/map.rb
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## DO NOT EDIT - This file was generated automatically.
5
- ##
6
- ## Generated with GOBL v0.50.5
7
- ##
8
-
9
- module GOBL
10
- module CBC
11
- # CodeSet is a map of keys to specific codes, useful to determine regime specific codes from their key counterparts.
12
- class CodeSet < GOBL::Map
13
- end
14
- end
15
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## DO NOT EDIT - This file was generated automatically.
5
- ##
6
- ## Generated with GOBL v0.55.0
7
- ##
8
-
9
- module GOBL
10
- # Contains the document payload to be included inside an Envelope.
11
- #
12
- # The document must contain a `$schema` property that identifies
13
- # the data's structure otherwise it will be rejected.
14
- class Document < GOBL::Map
15
- end
16
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- ## DO NOT EDIT - This file was generated automatically.
5
- ##
6
- ## Generated with GOBL v0.55.0
7
- ##
8
-
9
- module GOBL
10
- # Header defines the metadata of the body.
11
- class Header < GOBL::Object
12
- # The Schema ID of the GOBL Header structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/envelope#/$defs/Header'
14
-
15
- # @!attribute [r] uuid
16
- # Unique UUIDv1 identifier for the envelope.
17
- # @return [GOBL::UUID::UUID]
18
- property :uuid, GOBL::UUID::UUID
19
- validates_presence_of :uuid
20
-
21
- # @!attribute [r] dig
22
- # Digest of the canonical JSON body.
23
- # @return [GOBL::DSig::Digest]
24
- property :dig, GOBL::DSig::Digest
25
- validates_presence_of :dig
26
-
27
- # @!attribute [r] stamps
28
- # Seals of approval from other organisations that can only be added to non-draft envelopes.
29
- # @return [Array<GOBL::CBC::Stamp>]
30
- property :stamps, [GOBL::CBC::Stamp]
31
-
32
- # @!attribute [r] tags
33
- # Set of labels that describe but have no influence on the data.
34
- # @return [Array<String>]
35
- property :tags, [String]
36
-
37
- # @!attribute [r] meta
38
- # Additional semi-structured information about this envelope.
39
- # @return [GOBL::CBC::Meta]
40
- property :meta, GOBL::CBC::Meta
41
-
42
- # @!attribute [r] notes
43
- # Any information that may be relevant to other humans about this envelope
44
- # @return [String]
45
- property :notes, String
46
-
47
- # @!attribute [r] draft
48
- # When true, implies that this document should not be considered final. Digital signatures are optional.
49
- # @return [Boolean]
50
- property :draft, Boolean
51
- end
52
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module GOBL
4
- module Extensions
5
- # Additional methods for the generated {GOBL::Document} class
6
- module DocumentHelper
7
- # Returns the Schema ID of the current document
8
- #
9
- # @return [GOBL::ID] the Schema ID
10
- def schema
11
- @schema ||= GOBL::ID.new(_map['$schema'])
12
- end
13
-
14
- # Extracts the GOBL struct embedded in the document. It determines the type of document
15
- # currently embedded by reading the schema and attemps to instantiate the detected
16
- # class.
17
- #
18
- # @return [GOBL::Struct] the GOBL struct embedded in the document
19
- def extract
20
- raise 'unknown schema' unless schema.gobl?
21
-
22
- typs = ['GOBL']
23
- schema.modules.each do |mod|
24
- typs << mod.underscore.camelize
25
- end
26
- typs << schema.name.underscore.camelize
27
- klass = typs.join('::').constantize
28
-
29
- # Sanity check
30
- raise "#{klass.name}::SCHEMA_ID expected to be '#{schema}'" unless schema == klass::SCHEMA_ID
31
-
32
- klass.new _map.except('$schema')
33
- end
34
-
35
- module ClassMethods
36
- # Embeds the given GOBL struct in a new document injecting the proper Schema ID.
37
- #
38
- # @return [Document] the document embedding the given struct
39
- def embed(struct)
40
- new struct.as_json.merge(
41
- '$schema' => struct.class::SCHEMA_ID
42
- )
43
- end
44
- end
45
- end
46
- end
47
- end