gobl 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/data/regimes/at.json +55 -50
  3. data/data/regimes/be.json +55 -50
  4. data/data/regimes/ca.json +1 -1
  5. data/data/regimes/ch.json +55 -50
  6. data/data/regimes/co.json +113 -61
  7. data/data/regimes/de.json +61 -47
  8. data/data/regimes/el.json +204 -0
  9. data/data/regimes/es.json +66 -548
  10. data/data/regimes/fr.json +55 -50
  11. data/data/regimes/gb.json +59 -50
  12. data/data/regimes/it.json +60 -1311
  13. data/data/regimes/mx.json +38 -639
  14. data/data/regimes/nl.json +55 -50
  15. data/data/regimes/pl.json +103 -100
  16. data/data/regimes/pt.json +17 -349
  17. data/data/regimes/us.json +55 -50
  18. data/lib/generated/gobl/bill/correction_options.rb +2 -2
  19. data/lib/generated/gobl/bill/invoice.rb +49 -9
  20. data/lib/generated/gobl/bill/ordering.rb +34 -34
  21. data/lib/generated/gobl/bill/tax.rb +0 -5
  22. data/lib/generated/gobl/cbc/key_definition.rb +4 -9
  23. data/lib/generated/gobl/cbc/value_definition.rb +37 -0
  24. data/lib/generated/gobl/head/header.rb +5 -5
  25. data/lib/generated/gobl/head/link.rb +43 -0
  26. data/lib/generated/gobl/l10n/{country_code.rb → iso_country_code.rb} +3 -3
  27. data/lib/generated/gobl/l10n/tax_country_code.rb +277 -0
  28. data/lib/generated/gobl/org/address.rb +2 -3
  29. data/lib/generated/gobl/org/document_ref.rb +87 -0
  30. data/lib/generated/gobl/org/identity.rb +5 -0
  31. data/lib/generated/gobl/org/item.rb +2 -2
  32. data/lib/generated/gobl/org/name.rb +0 -2
  33. data/lib/generated/gobl/org/party.rb +5 -6
  34. data/lib/generated/gobl/org/person.rb +5 -0
  35. data/lib/generated/gobl/org/registration.rb +4 -0
  36. data/lib/generated/gobl/pay/advance.rb +5 -0
  37. data/lib/generated/gobl/pay/instructions.rb +5 -0
  38. data/lib/generated/gobl/tax/addon_def.rb +61 -0
  39. data/lib/generated/gobl/tax/{category.rb → category_def.rb} +11 -11
  40. data/lib/generated/gobl/tax/combo.rb +5 -0
  41. data/lib/generated/gobl/tax/correction_definition.rb +1 -1
  42. data/lib/generated/gobl/tax/correction_set.rb +13 -0
  43. data/lib/generated/gobl/tax/identity.rb +3 -3
  44. data/lib/generated/gobl/tax/{rate.rb → rate_def.rb} +11 -16
  45. data/lib/generated/gobl/tax/rate_total.rb +5 -0
  46. data/lib/generated/gobl/tax/{rate_value.rb → rate_value_def.rb} +4 -4
  47. data/lib/generated/gobl/tax/{regime.rb → regime_def.rb} +23 -13
  48. data/lib/generated/gobl/tax/scenario.rb +20 -10
  49. data/lib/generated/gobl/tax/scenario_set.rb +1 -1
  50. data/lib/generated/gobl/tax/source.rb +1 -1
  51. data/lib/generated/gobl/tax/tag_set.rb +28 -0
  52. data/lib/gobl/extensions/bill/invoice_helper.rb +6 -36
  53. data/lib/gobl/extensions/envelope_helper.rb +4 -0
  54. data/lib/gobl/version.rb +1 -1
  55. data/lib/gobl.rb +3 -2
  56. metadata +15 -11
  57. data/lib/generated/gobl/bill/document_reference.rb +0 -36
  58. data/lib/generated/gobl/bill/preceding.rb +0 -78
  59. data/lib/generated/gobl/cbc/code_definition.rb +0 -37
  60. data/lib/gobl/extensions/bill/scenario_summary.rb +0 -25
@@ -17,22 +17,21 @@ module GOBL
17
17
  # @return [String]
18
18
  property :uuid, String
19
19
 
20
+ # @!attribute [r] label
21
+ # Label can be used to provide a custom label for the party in a given context in a single language, for example "Supplier", "Host", or similar.
22
+ # @return [String]
23
+ property :label, String
24
+
20
25
  # @!attribute [r] name
21
26
  # Legal name or representation of the organization.
22
27
  # @return [String]
23
28
  property :name, String
24
- validates_presence_of :name
25
29
 
26
30
  # @!attribute [r] alias
27
31
  # Alternate short name.
28
32
  # @return [String]
29
33
  property :alias, String
30
34
 
31
- # @!attribute [r] label
32
- # Label can be used to provide a custom label for the party in a given context in a single language, for example "Supplier", "Host", or similar.
33
- # @return [String]
34
- property :label, String
35
-
36
35
  # @!attribute [r] tax_id
37
36
  # The entity's legal ID code used for tax purposes. They may have other numbers, but we're only interested in those valid for tax purposes.
38
37
  # @return [GOBL::Tax::Identity]
@@ -17,6 +17,11 @@ module GOBL
17
17
  # @return [String]
18
18
  property :uuid, String
19
19
 
20
+ # @!attribute [r] label
21
+ # Label can be used to identify the person in a given context in a single language, for example "Attn", "Contact", "Responsible", etc.
22
+ # @return [String]
23
+ property :label, String
24
+
20
25
  # @!attribute [r] name
21
26
  # Complete details on the name of the person
22
27
  # @return [GOBL::Org::Name]
@@ -17,6 +17,10 @@ module GOBL
17
17
  # @return [String]
18
18
  property :uuid, String
19
19
 
20
+ # @!attribute [r] label
21
+ # @return [String]
22
+ property :label, String
23
+
20
24
  # @!attribute [r] capital
21
25
  # @return [GOBL::Num::Amount]
22
26
  property :capital, GOBL::Num::Amount
@@ -85,6 +85,11 @@ module GOBL
85
85
  # @return [CreditTransfer]
86
86
  property :credit_transfer, CreditTransfer
87
87
 
88
+ # @!attribute [r] ext
89
+ # Tax extensions required by tax regimes or addons.
90
+ # @return [GOBL::Tax::Extensions]
91
+ property :ext, GOBL::Tax::Extensions
92
+
88
93
  # @!attribute [r] meta
89
94
  # Additional details useful for the parties involved.
90
95
  # @return [GOBL::CBC::Meta]
@@ -69,6 +69,11 @@ module GOBL
69
69
  # @return [String]
70
70
  property :notes, String
71
71
 
72
+ # @!attribute [r] ext
73
+ # Extension key-pairs values defined by a tax regime.
74
+ # @return [GOBL::Tax::Extensions]
75
+ property :ext, GOBL::Tax::Extensions
76
+
72
77
  # @!attribute [r] meta
73
78
  # Non-structured additional data that may be useful.
74
79
  # @return [GOBL::CBC::Meta]
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ##
7
+
8
+ module GOBL
9
+ module Tax
10
+ # AddonDef is an interface that defines the methods that a tax add-on must implement.
11
+ class AddonDef < GOBL::Object
12
+ # The Schema ID of the GOBL AddonDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/addon-def'
14
+
15
+ # @!attribute [r] key
16
+ # Key that defines how to uniquely idenitfy the add-on.
17
+ # @return [GOBL::CBC::Key]
18
+ property :key, GOBL::CBC::Key
19
+ validates_presence_of :key
20
+
21
+ # @!attribute [r] name
22
+ # Name of the add-on
23
+ # @return [GOBL::I18n::String]
24
+ property :name, GOBL::I18n::String
25
+ validates_presence_of :name
26
+
27
+ # @!attribute [r] description
28
+ # Description of the add-on
29
+ # @return [GOBL::I18n::String]
30
+ property :description, GOBL::I18n::String
31
+
32
+ # @!attribute [r] extensions
33
+ # Extensions defines the list of extensions that are associated with an add-on.
34
+ # @return [Array<GOBL::CBC::KeyDefinition>]
35
+ property :extensions, [GOBL::CBC::KeyDefinition]
36
+ validates_presence_of :extensions
37
+
38
+ # @!attribute [r] tags
39
+ # Tags is slice of tag sets that define what can be assigned to each document schema.
40
+ # @return [Array<TagSet>]
41
+ property :tags, [TagSet]
42
+
43
+ # @!attribute [r] scenarios
44
+ # Scenarios are applied to documents after normalization and before validation to ensure that form specific extensions have been added to the document.
45
+ # @return [Array<ScenarioSet>]
46
+ property :scenarios, [ScenarioSet]
47
+ validates_presence_of :scenarios
48
+
49
+ # @!attribute [r] inboxes
50
+ # Inboxes is a list of keys that are used to identify where copies of documents can be sent.
51
+ # @return [Array<GOBL::CBC::KeyDefinition>]
52
+ property :inboxes, [GOBL::CBC::KeyDefinition]
53
+
54
+ # @!attribute [r] corrections
55
+ # Corrections is used to provide a map of correction definitions that are supported by the add-on.
56
+ # @return [CorrectionSet]
57
+ property :corrections, CorrectionSet
58
+ validates_presence_of :corrections
59
+ end
60
+ end
61
+ end
@@ -7,10 +7,10 @@
7
7
 
8
8
  module GOBL
9
9
  module Tax
10
- # Category contains the definition of a general type of tax inside a region.
11
- class Category < GOBL::Object
12
- # The Schema ID of the GOBL Category structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Category'
10
+ # CategoryDef contains the definition of a general type of tax inside a region.
11
+ class CategoryDef < GOBL::Object
12
+ # The Schema ID of the GOBL CategoryDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/CategoryDef'
14
14
 
15
15
  # @!attribute [r] code
16
16
  # Code to be used in documents
@@ -39,15 +39,10 @@ module GOBL
39
39
  # @return [Boolean]
40
40
  property :retained, Boolean
41
41
 
42
- # @!attribute [r] rate_required
43
- # RateRequired when true implies that when a tax combo is defined using this category that one of the rate's keys must be defined. This is normally needed for regimes that categorize taxes in local document formats as opposed to grouping by percentage values. Try to avoid using this. It is better for rates to be determined by the percentage and conditions, not the rate key.
44
- # @return [Boolean]
45
- property :rate_required, Boolean
46
-
47
42
  # @!attribute [r] rates
48
43
  # Specific tax definitions inside this category.
49
- # @return [Array<Rate>]
50
- property :rates, [Rate]
44
+ # @return [Array<RateDef>]
45
+ property :rates, [RateDef]
51
46
 
52
47
  # @!attribute [r] extensions
53
48
  # Extensions defines a list of extension keys that may be used or required as an alternative or alongside choosing a rate for the tax category. Every key must be defined in the Regime's extensions table.
@@ -64,6 +59,11 @@ module GOBL
64
59
  # @return [Array<Source>]
65
60
  property :sources, [Source]
66
61
 
62
+ # @!attribute [r] ext
63
+ # Extensions key-value pairs that will be copied to the tax combo if this category is used.
64
+ # @return [GOBL::Tax::Extensions]
65
+ property :ext, GOBL::Tax::Extensions
66
+
67
67
  # @!attribute [r] meta
68
68
  # Meta contains additional information about the category that is relevant for local frequently used formats.
69
69
  # @return [GOBL::CBC::Meta]
@@ -18,6 +18,11 @@ module GOBL
18
18
  property :cat, GOBL::CBC::Code
19
19
  validates_presence_of :cat
20
20
 
21
+ # @!attribute [r] country
22
+ # Country code override when issuing with taxes applied from different countries.
23
+ # @return [GOBL::L10n::TaxCountryCode]
24
+ property :country, GOBL::L10n::TaxCountryCode
25
+
21
26
  # @!attribute [r] rate
22
27
  # Rate within a category to apply.
23
28
  # @return [GOBL::CBC::Key]
@@ -10,7 +10,7 @@ module GOBL
10
10
  # CorrectionDefinition contains details about what can be defined in .
11
11
  class CorrectionDefinition < GOBL::Object
12
12
  # The Schema ID of the GOBL CorrectionDefinition structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/CorrectionDefinition'
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/CorrectionDefinition'
14
14
 
15
15
  # @!attribute [r] schema
16
16
  # Partial or complete schema URL for the document type supported by correction.
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ##
7
+
8
+ module GOBL
9
+ module Tax
10
+ # CorrectionSet defines a set of correction definitions for a selection of schemas.
11
+ CorrectionSet = [CorrectionDefinition] # rubocop:disable Naming/ConstantName, Style/MutableConstant
12
+ end
13
+ end
@@ -13,9 +13,9 @@ module GOBL
13
13
  SCHEMA_ID = 'https://gobl.org/draft-0/tax/identity'
14
14
 
15
15
  # @!attribute [r] country
16
- # ISO country code for Where the tax identity was issued.
17
- # @return [GOBL::L10n::CountryCode]
18
- property :country, GOBL::L10n::CountryCode
16
+ # Tax country code for Where the tax identity was issued.
17
+ # @return [GOBL::L10n::TaxCountryCode]
18
+ property :country, GOBL::L10n::TaxCountryCode
19
19
  validates_presence_of :country
20
20
 
21
21
  # @!attribute [r] code
@@ -7,10 +7,10 @@
7
7
 
8
8
  module GOBL
9
9
  module Tax
10
- # Rate defines a single rate inside a category
11
- class Rate < GOBL::Object
12
- # The Schema ID of the GOBL Rate structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Rate'
10
+ # RateDef defines a single rate inside a category
11
+ class RateDef < GOBL::Object
12
+ # The Schema ID of the GOBL RateDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/RateDef'
14
14
 
15
15
  # @!attribute [r] key
16
16
  # Key identifies this rate within the system
@@ -36,18 +36,13 @@ module GOBL
36
36
 
37
37
  # @!attribute [r] values
38
38
  # 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.
39
- # @return [Array<RateValue>]
40
- property :values, [RateValue]
41
-
42
- # @!attribute [r] extensions
43
- # Extensions defines a list of keys for codes that can or must be associated with the tax rate for it to be validated. Every key must be defined in the Regime's extensions.
44
- # @return [Array<GOBL::CBC::Key>]
45
- property :extensions, [GOBL::CBC::Key]
46
-
47
- # @!attribute [r] map
48
- # Map is used to associate specific codes with the chosen rate.
49
- # @return [GOBL::CBC::CodeMap]
50
- property :map, GOBL::CBC::CodeMap
39
+ # @return [Array<RateValueDef>]
40
+ property :values, [RateValueDef]
41
+
42
+ # @!attribute [r] ext
43
+ # Extensions key-value pair that will be copied to the tax combo if this rate is used.
44
+ # @return [GOBL::Tax::Extensions]
45
+ property :ext, GOBL::Tax::Extensions
51
46
 
52
47
  # @!attribute [r] meta
53
48
  # Meta contains additional information about the rate that is relevant for local frequently used implementations.
@@ -17,6 +17,11 @@ module GOBL
17
17
  # @return [GOBL::CBC::Key]
18
18
  property :key, GOBL::CBC::Key
19
19
 
20
+ # @!attribute [r] country
21
+ # Country code override when issuing with taxes applied from different countries, it'd be very strange to mix rates from different countries, but in theory this would be possible.
22
+ # @return [GOBL::L10n::TaxCountryCode]
23
+ property :country, GOBL::L10n::TaxCountryCode
24
+
20
25
  # @!attribute [r] ext
21
26
  # If the rate is defined with extensions, they'll be used to group by also.
22
27
  # @return [GOBL::Tax::Extensions]
@@ -7,10 +7,10 @@
7
7
 
8
8
  module GOBL
9
9
  module Tax
10
- # RateValue contains a percentage rate or fixed amount for a given date range.
11
- class RateValue < GOBL::Object
12
- # The Schema ID of the GOBL RateValue structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/RateValue'
10
+ # RateValueDef contains a percentage rate or fixed amount for a given date range.
11
+ class RateValueDef < GOBL::Object
12
+ # The Schema ID of the GOBL RateValueDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/RateValueDef'
14
14
 
15
15
  # @!attribute [r] tags
16
16
  # Only apply this rate if one of the tags is present in the invoice.
@@ -7,13 +7,13 @@
7
7
 
8
8
  module GOBL
9
9
  module Tax
10
- # Regime defines the holding structure for the definitions of taxes inside a country or territory.
11
- class Regime < GOBL::Object
12
- # The Schema ID of the GOBL Regime structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime'
10
+ # RegimeDef defines the holding structure for the definitions of taxes inside a country or territory.
11
+ class RegimeDef < GOBL::Object
12
+ # The Schema ID of the GOBL RegimeDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def'
14
14
 
15
15
  # @!attribute [r] name
16
- # Name of the country
16
+ # Name of the tax regime.
17
17
  # @return [GOBL::I18n::String]
18
18
  property :name, GOBL::I18n::String
19
19
  validates_presence_of :name
@@ -31,10 +31,15 @@ module GOBL
31
31
 
32
32
  # @!attribute [r] country
33
33
  # Country code for the region
34
- # @return [GOBL::L10n::CountryCode]
35
- property :country, GOBL::L10n::CountryCode
34
+ # @return [GOBL::L10n::TaxCountryCode]
35
+ property :country, GOBL::L10n::TaxCountryCode
36
36
  validates_presence_of :country
37
37
 
38
+ # @!attribute [r] alt_country_codes
39
+ # Alternative localization codes that may be used to identify the tax regime in specific circumstances.
40
+ # @return [Array<GOBL::L10n::Code>]
41
+ property :alt_country_codes, [GOBL::L10n::Code]
42
+
38
43
  # @!attribute [r] zone
39
44
  # Specific Locality, region, city, province, county, or similar code inside the country, if needed.
40
45
  # @return [GOBL::L10n::Code]
@@ -46,10 +51,15 @@ module GOBL
46
51
  property :currency, GOBL::Currency::Code
47
52
  validates_presence_of :currency
48
53
 
54
+ # @!attribute [r] calculator_rounding_rule
55
+ # Rounding rule to use when calculating the tax totals, default is always `sum-then-round`.
56
+ # @return [String]
57
+ property :calculator_rounding_rule, String
58
+
49
59
  # @!attribute [r] tags
50
60
  # Tags that can be applied at the document level to identify additional considerations.
51
- # @return [Array<GOBL::CBC::KeyDefinition>]
52
- property :tags, [GOBL::CBC::KeyDefinition]
61
+ # @return [Array<TagSet>]
62
+ property :tags, [TagSet]
53
63
 
54
64
  # @!attribute [r] extensions
55
65
  # Extensions defines the keys that can be used for extended or extra data inside the regime that is specific to the regime and cannot be easily determined from other GOBL structures. Typically these are used to define local codes for suppliers, customers, products, or tax rates.
@@ -87,13 +97,13 @@ module GOBL
87
97
 
88
98
  # @!attribute [r] corrections
89
99
  # Configuration details for corrections to be used with correction options.
90
- # @return [Array<CorrectionDefinition>]
91
- property :corrections, [CorrectionDefinition]
100
+ # @return [CorrectionSet]
101
+ property :corrections, CorrectionSet
92
102
 
93
103
  # @!attribute [r] categories
94
104
  # List of tax categories.
95
- # @return [Array<Category>]
96
- property :categories, [Category]
105
+ # @return [Array<CategoryDef>]
106
+ property :categories, [CategoryDef]
97
107
  validates_presence_of :categories
98
108
  end
99
109
  end
@@ -10,7 +10,12 @@ module GOBL
10
10
  # Scenario is used to describe a tax scenario of a document based on the combination of document type and tag used.
11
11
  class Scenario < GOBL::Object
12
12
  # The Schema ID of the GOBL Scenario structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Scenario'
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/Scenario'
14
+
15
+ # @!attribute [r] name
16
+ # Name of the scenario for further information.
17
+ # @return [GOBL::I18n::String]
18
+ property :name, GOBL::I18n::String
14
19
 
15
20
  # @!attribute [r] type
16
21
  # Type of document, if present.
@@ -18,14 +23,19 @@ module GOBL
18
23
  property :type, [GOBL::CBC::Key]
19
24
 
20
25
  # @!attribute [r] tags
21
- # Tag that was applied to the document
26
+ # Array of tags that have been applied to the document.
22
27
  # @return [Array<GOBL::CBC::Key>]
23
28
  property :tags, [GOBL::CBC::Key]
24
29
 
25
- # @!attribute [r] name
26
- # Name of the scenario for further information.
27
- # @return [GOBL::I18n::String]
28
- property :name, GOBL::I18n::String
30
+ # @!attribute [r] ext_key
31
+ # Extension key that must be present in the document.
32
+ # @return [GOBL::CBC::Key]
33
+ property :ext_key, GOBL::CBC::Key
34
+
35
+ # @!attribute [r] ext_value
36
+ # Extension value that along side the key must be present for a match to happen. This cannot be used without an `ExtKey`. The value will be copied to the note code if needed.
37
+ # @return [String]
38
+ property :ext_value, String
29
39
 
30
40
  # @!attribute [r] note
31
41
  # A note to be added to the document if the scenario is applied.
@@ -37,10 +47,10 @@ module GOBL
37
47
  # @return [GOBL::CBC::CodeMap]
38
48
  property :codes, GOBL::CBC::CodeMap
39
49
 
40
- # @!attribute [r] meta
41
- # Any additional local meta data that may be useful in integrations.
42
- # @return [GOBL::CBC::Meta]
43
- property :meta, GOBL::CBC::Meta
50
+ # @!attribute [r] ext
51
+ # Ext represents a set of tax extensions that should be applied to the document in the appropriate "tax" context.
52
+ # @return [GOBL::Tax::Extensions]
53
+ property :ext, GOBL::Tax::Extensions
44
54
  end
45
55
  end
46
56
  end
@@ -10,7 +10,7 @@ module GOBL
10
10
  # 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.
11
11
  class ScenarioSet < GOBL::Object
12
12
  # The Schema ID of the GOBL ScenarioSet structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/ScenarioSet'
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/ScenarioSet'
14
14
 
15
15
  # @!attribute [r] schema
16
16
  # Partial or complete schema URL for the document type
@@ -10,7 +10,7 @@ module GOBL
10
10
  # Source describes where the information for the taxes comes from.
11
11
  class Source < GOBL::Object
12
12
  # The Schema ID of the GOBL Source structure
13
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Source'
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/Source'
14
14
 
15
15
  # @!attribute [r] title
16
16
  # Title of the linked source to help distinguish between this and other links.
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ##
7
+
8
+ module GOBL
9
+ module Tax
10
+ # TagSet defines a set of tags and their descriptions that can be used for a specific schema in the context of a Regime or Addon.
11
+ class TagSet < GOBL::Object
12
+ # The Schema ID of the GOBL TagSet structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/TagSet'
14
+
15
+ # @!attribute [r] schema
16
+ # Schema that the tags are associated with.
17
+ # @return [String]
18
+ property :schema, String
19
+ validates_presence_of :schema
20
+
21
+ # @!attribute [r] list
22
+ # List of tags for the schema
23
+ # @return [Array<GOBL::CBC::KeyDefinition>]
24
+ property :list, [GOBL::CBC::KeyDefinition]
25
+ validates_presence_of :list
26
+ end
27
+ end
28
+ end
@@ -5,15 +5,14 @@ module GOBL
5
5
  module Bill
6
6
  # Additional methods for the generated {GOBL::Bill::Invoice} class
7
7
  module InvoiceHelper
8
- # Returns the applicable regime based on the supplier’s tax ID
9
- def regime
10
- regime_country && GOBL::Tax::Regime.fetch(regime_country)
8
+ def self.included(klass)
9
+ klass.alias_method :tags, '$tags'
10
+ klass.alias_method :tags=, '$tags='
11
11
  end
12
12
 
13
- # Returns the invoice’s scenario summary which aggregates the data of
14
- # the matching regime’s scenarios
15
- def scenario_summary
16
- ScenarioSummary.new(matching_scenarios)
13
+ # Returns the applicable regime based on the supplier’s tax ID
14
+ def regime
15
+ regime_country && GOBL::Tax::RegimeDef.fetch(regime_country)
17
16
  end
18
17
 
19
18
  private
@@ -21,35 +20,6 @@ module GOBL
21
20
  def regime_country
22
21
  supplier&.tax_id&.country
23
22
  end
24
-
25
- def matching_scenarios
26
- return [] unless scenario_set
27
-
28
- scenario_set.list.select do |scenario|
29
- matches_scenario?(scenario)
30
- end
31
- end
32
-
33
- def matches_scenario?(scenario)
34
- matches_scenario_tags?(scenario) && matches_scenario_type?(scenario)
35
- end
36
-
37
- def matches_scenario_type?(scenario)
38
- scenario.type.blank? || scenario.type.include?(type)
39
- end
40
-
41
- def matches_scenario_tags?(scenario)
42
- scenario_tags = scenario.tags || []
43
- tax_tags = tax&.tags || []
44
-
45
- (scenario_tags - tax_tags).empty?
46
- end
47
-
48
- def scenario_set
49
- regime&.scenarios&.find do |scenario_set|
50
- self.class::SCHEMA_ID.include?(scenario_set.schema)
51
- end
52
- end
53
23
  end
54
24
  end
55
25
  end
@@ -17,6 +17,10 @@ module GOBL
17
17
  def extract
18
18
  doc.extract
19
19
  end
20
+
21
+ def signed?
22
+ sigs.present?
23
+ end
20
24
  end
21
25
  end
22
26
  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.21.0'
4
+ VERSION = '0.22.0'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -18,7 +18,8 @@ loader.inflector.inflect(
18
18
  'tax_id' => 'TaxID',
19
19
  'dsig' => 'DSig',
20
20
  'id' => 'ID',
21
- 'cbc' => 'CBC'
21
+ 'cbc' => 'CBC',
22
+ 'iso_country_code' => 'ISOCountryCode'
22
23
  )
23
24
  loader.ignore("#{__dir__}/ext")
24
25
  loader.setup
@@ -49,5 +50,5 @@ GOBL::I18n::String.include GOBL::Extensions::I18n::ValueKeysHelper
49
50
  GOBL::Schema::Object.include GOBL::Extensions::Schema::ObjectHelper
50
51
  GOBL::Schema::Object.extend GOBL::Extensions::Schema::ObjectHelper::ClassMethods
51
52
  GOBL::Envelope.include GOBL::Extensions::EnvelopeHelper
52
- GOBL::Tax::Regime.extend GOBL::Extensions::Tax::RegimeHelper::ClassMethods
53
+ GOBL::Tax::RegimeDef.extend GOBL::Extensions::Tax::RegimeHelper::ClassMethods
53
54
  GOBL::Bill::Invoice.include GOBL::Extensions::Bill::InvoiceHelper