gobl 0.9.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -13
  3. data/data/regimes/co.json +55 -1
  4. data/data/regimes/es.json +570 -64
  5. data/data/regimes/it.json +1182 -0
  6. data/lib/{gobl → generated/gobl}/bill/charge.rb +1 -1
  7. data/lib/{gobl → generated/gobl}/bill/delivery.rb +1 -1
  8. data/lib/{gobl → generated/gobl}/bill/discount.rb +1 -1
  9. data/lib/{gobl → generated/gobl}/bill/document_reference.rb +1 -1
  10. data/lib/{gobl → generated/gobl}/bill/invoice.rb +19 -8
  11. data/lib/{gobl → generated/gobl}/bill/line.rb +3 -3
  12. data/lib/{gobl → generated/gobl}/bill/line_charge.rb +1 -1
  13. data/lib/{gobl → generated/gobl}/bill/line_discount.rb +1 -1
  14. data/lib/{gobl → generated/gobl}/bill/ordering.rb +1 -1
  15. data/lib/{gobl → generated/gobl}/bill/outlay.rb +3 -3
  16. data/lib/{gobl → generated/gobl}/bill/payment.rb +1 -1
  17. data/lib/{gobl → generated/gobl}/bill/preceding.rb +23 -23
  18. data/lib/{gobl → generated/gobl}/bill/tax.rb +4 -4
  19. data/lib/{gobl → generated/gobl}/bill/totals.rb +5 -5
  20. data/lib/{gobl → generated/gobl}/cal/date.rb +2 -2
  21. data/lib/{gobl → generated/gobl}/cal/period.rb +3 -3
  22. data/lib/{gobl → generated/gobl}/cbc/code.rb +3 -3
  23. data/lib/{gobl → generated/gobl}/cbc/key.rb +2 -2
  24. data/lib/{gobl → generated/gobl}/cbc/meta.rb +1 -1
  25. data/lib/{gobl → generated/gobl}/cbc/note.rb +6 -6
  26. data/lib/{gobl → generated/gobl}/cbc/stamp.rb +3 -3
  27. data/lib/{gobl → generated/gobl}/currency/code.rb +7 -4
  28. data/lib/{gobl → generated/gobl}/currency/exchange_rate.rb +3 -3
  29. data/lib/generated/gobl/document.rb +16 -0
  30. data/lib/{gobl → generated/gobl}/dsig/digest.rb +3 -3
  31. data/lib/{gobl → generated/gobl}/dsig/signature.rb +2 -2
  32. data/lib/{gobl → generated/gobl}/envelope.rb +5 -5
  33. data/lib/{gobl → generated/gobl}/header.rb +4 -4
  34. data/lib/{gobl → generated/gobl}/i18n/string.rb +1 -1
  35. data/lib/{gobl → generated/gobl}/l10n/code.rb +2 -2
  36. data/lib/{gobl → generated/gobl}/l10n/country_code.rb +7 -4
  37. data/lib/{gobl → generated/gobl}/note/message.rb +4 -4
  38. data/lib/{gobl → generated/gobl}/org/address.rb +2 -2
  39. data/lib/{gobl → generated/gobl}/org/coordinates.rb +1 -1
  40. data/lib/{gobl → generated/gobl}/org/email.rb +2 -2
  41. data/lib/generated/gobl/org/identity.rb +38 -0
  42. data/lib/{gobl → generated/gobl}/org/image.rb +1 -1
  43. data/lib/{gobl → generated/gobl}/org/inbox.rb +3 -3
  44. data/lib/{gobl → generated/gobl}/org/item.rb +10 -10
  45. data/lib/{gobl → generated/gobl}/org/name.rb +3 -3
  46. data/lib/{gobl → generated/gobl}/org/party.rb +7 -7
  47. data/lib/{gobl → generated/gobl}/org/person.rb +2 -7
  48. data/lib/{gobl → generated/gobl}/org/registration.rb +1 -1
  49. data/lib/{gobl → generated/gobl}/org/telephone.rb +2 -2
  50. data/lib/{gobl → generated/gobl}/org/unit.rb +8 -3
  51. data/lib/{gobl → generated/gobl}/org/website.rb +2 -2
  52. data/lib/{gobl → generated/gobl}/pay/advance.rb +3 -3
  53. data/lib/{gobl → generated/gobl}/pay/card.rb +3 -3
  54. data/lib/{gobl → generated/gobl}/pay/credit_transfer.rb +1 -1
  55. data/lib/{gobl → generated/gobl}/pay/direct_debit.rb +1 -1
  56. data/lib/{gobl → generated/gobl}/pay/due_date.rb +3 -3
  57. data/lib/{gobl → generated/gobl}/pay/instructions.rb +19 -4
  58. data/lib/{gobl → generated/gobl}/pay/online.rb +2 -2
  59. data/lib/{gobl → generated/gobl}/pay/terms.rb +19 -4
  60. data/lib/{gobl → generated/gobl}/tax/category.rb +14 -4
  61. data/lib/{gobl → generated/gobl}/tax/category_total.rb +5 -5
  62. data/lib/{gobl → generated/gobl}/tax/combo.rb +7 -2
  63. data/lib/{gobl → generated/gobl}/tax/identity.rb +16 -6
  64. data/lib/generated/gobl/tax/key_definition.rb +38 -0
  65. data/lib/generated/gobl/tax/preceding_definitions.rb +27 -0
  66. data/lib/{gobl → generated/gobl}/tax/rate.rb +11 -4
  67. data/lib/{gobl → generated/gobl}/tax/rate_total.rb +4 -4
  68. data/lib/{gobl → generated/gobl}/tax/rate_total_surcharge.rb +3 -3
  69. data/lib/{gobl → generated/gobl}/tax/rate_value.rb +2 -2
  70. data/lib/{gobl → generated/gobl}/tax/regime.rb +19 -9
  71. data/lib/generated/gobl/tax/scenario.rb +37 -0
  72. data/lib/generated/gobl/tax/scenario_set.rb +29 -0
  73. data/lib/{gobl → generated/gobl}/tax/set.rb +1 -1
  74. data/lib/generated/gobl/tax/tag.rb +33 -0
  75. data/lib/{gobl → generated/gobl}/tax/total.rb +2 -2
  76. data/lib/{gobl → generated/gobl}/tax/zone.rb +2 -2
  77. data/lib/{gobl → generated/gobl}/uuid/uuid.rb +2 -2
  78. data/lib/gobl/enum.rb +8 -56
  79. data/lib/gobl/version.rb +1 -1
  80. data/lib/gobl.rb +1 -0
  81. metadata +75 -76
  82. data/lib/gobl/bill/invoice_type.rb +0 -30
  83. data/lib/gobl/cbc/note_key.rb +0 -48
  84. data/lib/gobl/document.rb +0 -13
  85. data/lib/gobl/org/item_code.rb +0 -28
  86. data/lib/gobl/pay/method_key.rb +0 -30
  87. data/lib/gobl/pay/term_key.rb +0 -33
  88. data/lib/gobl/tax/scheme.rb +0 -44
  89. data/lib/gobl/tax/source_key.rb +0 -28
  90. data/lib/gobl/value.rb +0 -77
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -16,12 +16,12 @@ module GOBL
16
16
  # @!attribute [r] code
17
17
  # @return [GOBL::CBC::Code]
18
18
  property :code, GOBL::CBC::Code
19
- validates :code, presence: true
19
+ validates_presence_of :code
20
20
 
21
21
  # @!attribute [r] name
22
22
  # @return [GOBL::I18n::String]
23
23
  property :name, GOBL::I18n::String
24
- validates :name, presence: true
24
+ validates_presence_of :name
25
25
 
26
26
  # @!attribute [r] desc
27
27
  # @return [GOBL::I18n::String]
@@ -36,7 +36,17 @@ module GOBL
36
36
  # Specific tax definitions inside this category.
37
37
  # @return [Array<Rate>]
38
38
  property :rates, [Rate]
39
- validates :rates, presence: true
39
+ validates_presence_of :rates
40
+
41
+ # @!attribute [r] tags
42
+ # Tags contains a set of tag definitions that can be applied for this tax category.
43
+ # @return [Array<Tag>]
44
+ property :tags, [Tag]
45
+
46
+ # @!attribute [r] meta
47
+ # Meta contains additional information about the category that is relevant for local frequently used formats.
48
+ # @return [GOBL::CBC::Meta]
49
+ property :meta, GOBL::CBC::Meta
40
50
  end
41
51
  end
42
52
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -16,7 +16,7 @@ module GOBL
16
16
  # @!attribute [r] code
17
17
  # @return [GOBL::CBC::Code]
18
18
  property :code, GOBL::CBC::Code
19
- validates :code, presence: true
19
+ validates_presence_of :code
20
20
 
21
21
  # @!attribute [r] retained
22
22
  # @return [Boolean]
@@ -25,17 +25,17 @@ module GOBL
25
25
  # @!attribute [r] rates
26
26
  # @return [Array<RateTotal>]
27
27
  property :rates, [RateTotal]
28
- validates :rates, presence: true
28
+ validates_presence_of :rates
29
29
 
30
30
  # @!attribute [r] base
31
31
  # @return [GOBL::Num::Amount]
32
32
  property :base, GOBL::Num::Amount
33
- validates :base, presence: true
33
+ validates_presence_of :base
34
34
 
35
35
  # @!attribute [r] amount
36
36
  # @return [GOBL::Num::Amount]
37
37
  property :amount, GOBL::Num::Amount
38
- validates :amount, presence: true
38
+ validates_presence_of :amount
39
39
 
40
40
  # @!attribute [r] surcharge
41
41
  # @return [GOBL::Num::Amount]
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -17,7 +17,7 @@ module GOBL
17
17
  # Tax category code from those available inside a region.
18
18
  # @return [GOBL::CBC::Code]
19
19
  property :cat, GOBL::CBC::Code
20
- validates :cat, presence: true
20
+ validates_presence_of :cat
21
21
 
22
22
  # @!attribute [r] rate
23
23
  # Rate within a category to apply.
@@ -33,6 +33,11 @@ module GOBL
33
33
  # Some countries require an additional surcharge (calculated if rate present).
34
34
  # @return [GOBL::Num::Percentage]
35
35
  property :surcharge, GOBL::Num::Percentage
36
+
37
+ # @!attribute [r] tags
38
+ # Additional data may be required in some regimes, the tags property helps reference them.
39
+ # @return [Array<GOBL::CBC::Key>]
40
+ property :tags, [GOBL::CBC::Key]
36
41
  end
37
42
  end
38
43
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -22,22 +22,32 @@ module GOBL
22
22
  # ISO country code for Where the tax identity was issued.
23
23
  # @return [GOBL::L10n::CountryCode]
24
24
  property :country, GOBL::L10n::CountryCode
25
- validates :country, presence: true
25
+ validates_presence_of :country
26
26
 
27
27
  # @!attribute [r] zone
28
28
  # Where inside the country the tax identity holder is based for tax purposes like a village, town, district, city, county, state or province. For some areas, this could be a regular post or zip code. See the regime packages for specific validation rules.
29
29
  # @return [GOBL::L10n::Code]
30
30
  property :zone, GOBL::L10n::Code
31
31
 
32
+ # Enumeration of possible values for {#source} with their corresponding descriptions
33
+ SOURCE_ENUM = {
34
+ 'tax-agency' => 'Sourced directly from a tax agency',
35
+ 'passport' => 'A passport document',
36
+ 'national' => 'National ID Card or similar',
37
+ 'permit' => 'Residential or similar permit',
38
+ 'other' => 'An other type of source not listed'
39
+ }.freeze
40
+
32
41
  # @!attribute [r] source
33
42
  # What is the source document of the tax identity.
34
- # @return [SourceKey]
35
- property :source, SourceKey
43
+ # @return [GOBL::CBC::Key]
44
+ property :source, GOBL::CBC::Key
45
+ validates_inclusion_of :source, in: SOURCE_ENUM.keys, allow_blank: true
36
46
 
37
47
  # @!attribute [r] code
38
48
  # Normalized code shown on the original identity document.
39
- # @return [String]
40
- property :code, String
49
+ # @return [GOBL::CBC::Code]
50
+ property :code, GOBL::CBC::Code
41
51
 
42
52
  # @!attribute [r] meta
43
53
  # Additional details that may be required.
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.38.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # KeyDefinition defines properties of a key that is specific for a regime.
12
+ class KeyDefinition < GOBL::Object
13
+ # The Schema ID of the GOBL KeyDefinition structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/KeyDefinition'
15
+
16
+ # @!attribute [r] key
17
+ # Actual key value.
18
+ # @return [GOBL::CBC::Key]
19
+ property :key, GOBL::CBC::Key
20
+ validates_presence_of :key
21
+
22
+ # @!attribute [r] name
23
+ # Short name for the key, if relevant.
24
+ # @return [GOBL::I18n::String]
25
+ property :name, GOBL::I18n::String
26
+
27
+ # @!attribute [r] desc
28
+ # Description offering more details about when the key should be used.
29
+ # @return [GOBL::I18n::String]
30
+ property :desc, GOBL::I18n::String
31
+
32
+ # @!attribute [r] meta
33
+ # Any additional data that might be relevant in some regimes?
34
+ # @return [GOBL::CBC::Meta]
35
+ property :meta, GOBL::CBC::Meta
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.38.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # PrecedingDefinitions contains details about what can be defined in Invoice preceding document data.
12
+ class PrecedingDefinitions < GOBL::Object
13
+ # The Schema ID of the GOBL PrecedingDefinitions structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/PrecedingDefinitions'
15
+
16
+ # @!attribute [r] corrections
17
+ # Corrections contains a list of all the keys that can be used to identify a correction.
18
+ # @return [Array<KeyDefinition>]
19
+ property :corrections, [KeyDefinition]
20
+
21
+ # @!attribute [r] correction_methods
22
+ # CorrectionMethods describe the methods used to correct an invoice.
23
+ # @return [Array<KeyDefinition>]
24
+ property :correction_methods, [KeyDefinition]
25
+ end
26
+ end
27
+ end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -17,14 +17,16 @@ module GOBL
17
17
  # Key identifies this rate within the system
18
18
  # @return [GOBL::CBC::Key]
19
19
  property :key, GOBL::CBC::Key
20
- validates :key, presence: true
20
+ validates_presence_of :key
21
21
 
22
22
  # @!attribute [r] name
23
+ # Human name of the rate
23
24
  # @return [GOBL::I18n::String]
24
25
  property :name, GOBL::I18n::String
25
- validates :name, presence: true
26
+ validates_presence_of :name
26
27
 
27
28
  # @!attribute [r] desc
29
+ # Useful description of the rate.
28
30
  # @return [GOBL::I18n::String]
29
31
  property :desc, GOBL::I18n::String
30
32
 
@@ -32,7 +34,12 @@ module GOBL
32
34
  # Values contains a list of Value objects that contain the current and historical percentage values for the rate and additional filters. Order is important, newer values should come before older values.
33
35
  # @return [Array<RateValue>]
34
36
  property :values, [RateValue]
35
- validates :values, presence: true
37
+ validates_presence_of :values
38
+
39
+ # @!attribute [r] meta
40
+ # Meta contains additional information about the rate that is relevant for local frequently used implementations.
41
+ # @return [GOBL::CBC::Meta]
42
+ property :meta, GOBL::CBC::Meta
36
43
  end
37
44
  end
38
45
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -20,18 +20,18 @@ module GOBL
20
20
  # @!attribute [r] base
21
21
  # @return [GOBL::Num::Amount]
22
22
  property :base, GOBL::Num::Amount
23
- validates :base, presence: true
23
+ validates_presence_of :base
24
24
 
25
25
  # @!attribute [r] percent
26
26
  # @return [GOBL::Num::Percentage]
27
27
  property :percent, GOBL::Num::Percentage
28
- validates :percent, presence: true
28
+ validates_presence_of :percent
29
29
 
30
30
  # @!attribute [r] amount
31
31
  # Total amount of rate, excluding surcharges
32
32
  # @return [GOBL::Num::Amount]
33
33
  property :amount, GOBL::Num::Amount
34
- validates :amount, presence: true
34
+ validates_presence_of :amount
35
35
 
36
36
  # @!attribute [r] surcharge
37
37
  # @return [RateTotalSurcharge]
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -16,12 +16,12 @@ module GOBL
16
16
  # @!attribute [r] percent
17
17
  # @return [GOBL::Num::Percentage]
18
18
  property :percent, GOBL::Num::Percentage
19
- validates :percent, presence: true
19
+ validates_presence_of :percent
20
20
 
21
21
  # @!attribute [r] amount
22
22
  # @return [GOBL::Num::Amount]
23
23
  property :amount, GOBL::Num::Amount
24
- validates :amount, presence: true
24
+ validates_presence_of :amount
25
25
  end
26
26
  end
27
27
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -27,7 +27,7 @@ module GOBL
27
27
  # Percent rate that should be applied
28
28
  # @return [GOBL::Num::Percentage]
29
29
  property :percent, GOBL::Num::Percentage
30
- validates :percent, presence: true
30
+ validates_presence_of :percent
31
31
 
32
32
  # @!attribute [r] surcharge
33
33
  # An additional surcharge to apply.
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -17,13 +17,13 @@ module GOBL
17
17
  # Name of the country
18
18
  # @return [GOBL::I18n::String]
19
19
  property :name, GOBL::I18n::String
20
- validates :name, presence: true
20
+ validates_presence_of :name
21
21
 
22
22
  # @!attribute [r] country
23
23
  # Country code for the region
24
24
  # @return [GOBL::L10n::CountryCode]
25
25
  property :country, GOBL::L10n::CountryCode
26
- validates :country, presence: true
26
+ validates_presence_of :country
27
27
 
28
28
  # @!attribute [r] zone
29
29
  # Specific Locality, region, city, province, county, or similar code inside the country, if needed.
@@ -39,18 +39,28 @@ module GOBL
39
39
  # Currency used by the country.
40
40
  # @return [GOBL::Currency::Code]
41
41
  property :currency, GOBL::Currency::Code
42
- validates :currency, presence: true
42
+ validates_presence_of :currency
43
43
 
44
- # @!attribute [r] schemes
45
- # Set of specific scheme definitions inside the region.
46
- # @return [Array<Scheme>]
47
- property :schemes, [Scheme]
44
+ # @!attribute [r] tags
45
+ # Tags that can be applied at the document level to identify additional considerations.
46
+ # @return [Array<Tag>]
47
+ property :tags, [Tag]
48
+
49
+ # @!attribute [r] scenarios
50
+ # Sets of scenario definitions for the regime.
51
+ # @return [Array<ScenarioSet>]
52
+ property :scenarios, [ScenarioSet]
53
+
54
+ # @!attribute [r] preceding
55
+ # Configuration details for preceding options.
56
+ # @return [PrecedingDefinitions]
57
+ property :preceding, PrecedingDefinitions
48
58
 
49
59
  # @!attribute [r] categories
50
60
  # List of tax categories.
51
61
  # @return [Array<Category>]
52
62
  property :categories, [Category]
53
- validates :categories, presence: true
63
+ validates_presence_of :categories
54
64
  end
55
65
  end
56
66
  end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.38.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # Scenario is used to describe a tax scenario of a document based on the combination of document type and tag used.
12
+ class Scenario < GOBL::Object
13
+ # The Schema ID of the GOBL Scenario structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Scenario'
15
+
16
+ # @!attribute [r] type
17
+ # Type of document, if present.
18
+ # @return [Array<GOBL::CBC::Key>]
19
+ property :type, [GOBL::CBC::Key]
20
+
21
+ # @!attribute [r] tags
22
+ # Tag that was applied to the document
23
+ # @return [Array<GOBL::CBC::Key>]
24
+ property :tags, [GOBL::CBC::Key]
25
+
26
+ # @!attribute [r] note
27
+ # A note to be added to the document if the scenario is applied.
28
+ # @return [GOBL::CBC::Note]
29
+ property :note, GOBL::CBC::Note
30
+
31
+ # @!attribute [r] meta
32
+ # Any additional local meta data that may be useful in integrations.
33
+ # @return [GOBL::CBC::Meta]
34
+ property :meta, GOBL::CBC::Meta
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.38.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # ScenarioSet is a collection of tax scenarios for a given schema that can be used to determine special codes or notes that need to be included in the final document.
12
+ class ScenarioSet < GOBL::Object
13
+ # The Schema ID of the GOBL ScenarioSet structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/ScenarioSet'
15
+
16
+ # @!attribute [r] schema
17
+ # Partial or complete schema URL for the document type
18
+ # @return [String]
19
+ property :schema, String
20
+ validates_presence_of :schema
21
+
22
+ # @!attribute [r] list
23
+ # List of scenarios for the schema
24
+ # @return [Array<Scenario>]
25
+ property :list, [Scenario]
26
+ validates_presence_of :list
27
+ end
28
+ end
29
+ end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.38.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # Tag describes a tax tag that can be used to identify additional requirements in an electronic invoice.
12
+ class Tag < GOBL::Object
13
+ # The Schema ID of the GOBL Tag structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Tag'
15
+
16
+ # @!attribute [r] key
17
+ # Key used to identify the tag
18
+ # @return [GOBL::CBC::Key]
19
+ property :key, GOBL::CBC::Key
20
+ validates_presence_of :key
21
+
22
+ # @!attribute [r] name
23
+ # Name of this tag.
24
+ # @return [GOBL::I18n::String]
25
+ property :name, GOBL::I18n::String
26
+
27
+ # @!attribute [r] meta
28
+ # Additional local
29
+ # @return [GOBL::CBC::Meta]
30
+ property :meta, GOBL::CBC::Meta
31
+ end
32
+ end
33
+ end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -22,7 +22,7 @@ module GOBL
22
22
  # Total value of all the taxes applied.
23
23
  # @return [GOBL::Num::Amount]
24
24
  property :sum, GOBL::Num::Amount
25
- validates :sum, presence: true
25
+ validates_presence_of :sum
26
26
  end
27
27
  end
28
28
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -17,7 +17,7 @@ module GOBL
17
17
  # Unique zone code.
18
18
  # @return [GOBL::L10n::Code]
19
19
  property :code, GOBL::L10n::Code
20
- validates :code, presence: true
20
+ validates_presence_of :code
21
21
 
22
22
  # @!attribute [r] name
23
23
  # Name of the zone to be use if a locality or region is not applicable.
@@ -3,13 +3,13 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.36.0
6
+ ## Generated with GOBL v0.38.0
7
7
  ##
8
8
 
9
9
  module GOBL
10
10
  module UUID
11
11
  # Universally Unique Identifier. We only recommend using versions 1 and 4 within GOBL.
12
- class UUID < GOBL::Value
12
+ class UUID < String
13
13
  # The Schema ID of the GOBL UUID structure
14
14
  SCHEMA_ID = 'https://gobl.org/draft-0/uuid/uuid'
15
15
  end
data/lib/gobl/enum.rb CHANGED
@@ -3,69 +3,21 @@
3
3
  module GOBL
4
4
  # Base class for single value structures in the GOBL schema that have a controlled set
5
5
  # of values associated to them (i.e., an enumeration) that may constrain them
6
- class Enum < Value
7
- include ActiveModel::Validations
6
+ module Enum
7
+ def self.included(base)
8
+ base.include ActiveModel::Validations
8
9
 
9
- # Returns an enum value object that corresponds to a given value. The value can be a
10
- # `Symbol`, a `String` or anything coercible into one (via `#to_s`)
11
- #
12
- # @param value [Symbol, String, #to_s] the value of the object
13
- #
14
- # @return [Enum] the enum value instance corresponding to the given value
15
- def initialize(value)
16
- if value.is_a? Symbol
17
- self._value = value_from_sym(value) || value.to_s
18
- else
19
- super
10
+ base.class_eval do
11
+ validate :valid_enum_value, if: :strict_enum?
20
12
  end
21
13
  end
22
14
 
23
- # Returns the description of the current enum value
24
- #
25
- # @return [String] the description of the current enum value
26
15
  def description
27
- self.class::ENUM.fetch(_value, _value)
16
+ self.class::ENUM.fetch(self, self)
28
17
  end
29
18
 
30
- # Enables dynamic value inquirers for each of the declared enum values. Each inquirer
31
- # returns a `Boolean` denoting whether the value equals the enquired value (`true`) or
32
- # not (`false`)
33
- def method_missing(method_name, *args, &block)
34
- if (value = self.class.find_by_inquirer(method_name))
35
- self == value
36
- else
37
- super
38
- end
39
- end
40
-
41
- # @api private
42
- def respond_to_missing?(method_name, include_private = false)
43
- self.class.find_by_inquirer(method_name) || super
44
- end
45
-
46
- class << self
47
- # Returns an array with all the enumerated objects of this type
48
- #
49
- # @return [Array<#{name}>] the array of enumerated objects
50
- def all
51
- self::ENUM.keys.map { |key| new(key) }
52
- end
53
-
54
- # @api private
55
- def find_by_sym(sym)
56
- all.find { |object| object.to_sym == sym }
57
- end
58
-
59
- # @api private
60
- def find_by_inquirer(method_name)
61
- method_name =~ /(.+)\?$/ && find_by_sym(Regexp.last_match(1).to_sym)
62
- end
63
- end
64
-
65
- private
66
-
67
- def value_from_sym(sym)
68
- self.class.find_by_sym(sym)&.to_s
19
+ def valid_enum_value
20
+ errors.add(:base, "Value \"#{self}\" is not within the allowed values of the enumeration") unless self.class::ENUM.key?(self)
69
21
  end
70
22
  end
71
23
  end
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.9.0'
4
+ VERSION = '0.10.1'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -9,6 +9,7 @@ require 'base64'
9
9
  require 'hashme'
10
10
 
11
11
  loader = Zeitwerk::Loader.for_gem
12
+ loader.push_dir("#{__dir__}/generated")
12
13
  loader.inflector.inflect(
13
14
  'gobl' => 'GOBL',
14
15
  'uuid' => 'UUID',