gobl 0.21.0 → 0.23.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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/data/regimes/ae.json +173 -0
  3. data/data/regimes/at.json +56 -50
  4. data/data/regimes/be.json +56 -50
  5. data/data/regimes/br.json +135 -0
  6. data/data/regimes/ca.json +2 -1
  7. data/data/regimes/ch.json +56 -50
  8. data/data/regimes/co.json +34 -203
  9. data/data/regimes/de.json +74 -47
  10. data/data/regimes/el.json +211 -0
  11. data/data/regimes/es.json +69 -550
  12. data/data/regimes/fr.json +56 -50
  13. data/data/regimes/gb.json +60 -50
  14. data/data/regimes/in.json +128 -0
  15. data/data/regimes/it.json +48 -1311
  16. data/data/regimes/mx.json +39 -639
  17. data/data/regimes/nl.json +56 -50
  18. data/data/regimes/pl.json +101 -97
  19. data/data/regimes/pt.json +1459 -227
  20. data/data/regimes/us.json +55 -50
  21. data/lib/generated/gobl/bill/charge.rb +34 -19
  22. data/lib/generated/gobl/bill/correction_options.rb +8 -3
  23. data/lib/generated/gobl/bill/delivery.rb +184 -16
  24. data/lib/generated/gobl/bill/delivery_details.rb +41 -0
  25. data/lib/generated/gobl/bill/discount.rb +36 -13
  26. data/lib/generated/gobl/bill/invoice.rb +88 -41
  27. data/lib/generated/gobl/bill/line.rb +39 -4
  28. data/lib/generated/gobl/bill/line_charge.rb +56 -11
  29. data/lib/generated/gobl/bill/line_discount.rb +45 -12
  30. data/lib/generated/gobl/bill/order.rb +208 -0
  31. data/lib/generated/gobl/bill/ordering.rb +40 -35
  32. data/lib/generated/gobl/bill/payment.rb +155 -15
  33. data/lib/generated/gobl/bill/payment_details.rb +36 -0
  34. data/lib/generated/gobl/bill/payment_line.rb +77 -0
  35. data/lib/generated/gobl/bill/sub_line.rb +83 -0
  36. data/lib/generated/gobl/bill/tax.rb +19 -5
  37. data/lib/generated/gobl/bill/totals.rb +18 -18
  38. data/lib/generated/gobl/bill/tracking.rb +26 -0
  39. data/lib/generated/gobl/cal/date_time.rb +1 -1
  40. data/lib/generated/gobl/cal/time.rb +16 -0
  41. data/lib/generated/gobl/cbc/code.rb +2 -1
  42. data/lib/generated/gobl/cbc/{key_definition.rb → definition.rb} +18 -14
  43. data/lib/generated/gobl/cbc/source.rb +37 -0
  44. data/lib/generated/gobl/currency/code.rb +16 -16
  45. data/lib/generated/gobl/currency/exchange_rate.rb +10 -5
  46. data/lib/generated/gobl/head/header.rb +5 -5
  47. data/lib/generated/gobl/head/link.rb +43 -0
  48. data/lib/generated/gobl/l10n/{country_code.rb → iso_country_code.rb} +3 -3
  49. data/lib/generated/gobl/l10n/tax_country_code.rb +277 -0
  50. data/lib/generated/gobl/org/address.rb +11 -7
  51. data/lib/generated/gobl/org/attachment.rb +62 -0
  52. data/lib/generated/gobl/org/document_ref.rb +102 -0
  53. data/lib/generated/gobl/org/identity.rb +11 -1
  54. data/lib/generated/gobl/org/inbox.rb +22 -14
  55. data/lib/generated/gobl/org/item.rb +4 -5
  56. data/lib/generated/gobl/org/name.rb +0 -2
  57. data/lib/generated/gobl/{cbc → org}/note.rb +16 -5
  58. data/lib/generated/gobl/org/party.rb +9 -6
  59. data/lib/generated/gobl/org/person.rb +5 -0
  60. data/lib/generated/gobl/org/registration.rb +4 -0
  61. data/lib/generated/gobl/org/telephone.rb +1 -1
  62. data/lib/generated/gobl/org/unit.rb +2 -1
  63. data/lib/generated/gobl/pay/advance.rb +8 -1
  64. data/lib/generated/gobl/pay/card.rb +5 -2
  65. data/lib/generated/gobl/pay/instructions.rb +10 -3
  66. data/lib/generated/gobl/pay/terms.rb +7 -2
  67. data/lib/generated/gobl/regimes/mx/food_vouchers_line.rb +5 -0
  68. data/lib/generated/gobl/regimes/mx/fuel_account_line.rb +5 -0
  69. data/lib/generated/gobl/tax/addon_def.rb +76 -0
  70. data/lib/generated/gobl/tax/catalogue_def.rb +39 -0
  71. data/lib/generated/gobl/tax/{category.rb → category_def.rb} +14 -14
  72. data/lib/generated/gobl/tax/combo.rb +5 -0
  73. data/lib/generated/gobl/tax/correction_definition.rb +6 -1
  74. data/lib/generated/gobl/tax/correction_set.rb +13 -0
  75. data/lib/generated/gobl/tax/identity.rb +8 -3
  76. data/lib/generated/gobl/tax/{rate.rb → rate_def.rb} +11 -16
  77. data/lib/generated/gobl/tax/rate_total.rb +5 -0
  78. data/lib/generated/gobl/tax/{rate_value.rb → rate_value_def.rb} +4 -4
  79. data/lib/generated/gobl/tax/{regime.rb → regime_def.rb} +38 -33
  80. data/lib/generated/gobl/tax/scenario.rb +22 -12
  81. data/lib/generated/gobl/tax/scenario_note.rb +42 -0
  82. data/lib/generated/gobl/tax/scenario_set.rb +1 -1
  83. data/lib/generated/gobl/tax/tag_set.rb +28 -0
  84. data/lib/generated/gobl/tax/total.rb +6 -1
  85. data/lib/gobl/extensions/bill/invoice_helper.rb +6 -36
  86. data/lib/gobl/extensions/envelope_helper.rb +4 -0
  87. data/lib/gobl/version.rb +1 -1
  88. data/lib/gobl.rb +3 -2
  89. metadata +36 -21
  90. data/lib/generated/gobl/bill/document_reference.rb +0 -36
  91. data/lib/generated/gobl/bill/outlay.rb +0 -58
  92. data/lib/generated/gobl/bill/preceding.rb +0 -78
  93. data/lib/generated/gobl/cbc/code_definition.rb +0 -37
  94. data/lib/generated/gobl/tax/source.rb +0 -27
  95. data/lib/gobl/extensions/bill/scenario_summary.rb +0 -25
@@ -0,0 +1,39 @@
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
+ # A CatalogueDef contains a set of re-useable extensions, scenarios, and validators that can be used by addons or tax regimes.
11
+ class CatalogueDef < GOBL::Object
12
+ # The Schema ID of the GOBL CatalogueDef structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/catalogue-def'
14
+
15
+ # @!attribute [r] key
16
+ # Key defines a unique identifier for the catalogue.
17
+ # @return [GOBL::CBC::Key]
18
+ property :key, GOBL::CBC::Key
19
+ validates_presence_of :key
20
+
21
+ # @!attribute [r] name
22
+ # Name is the name of the catalogue.
23
+ # @return [GOBL::I18n::String]
24
+ property :name, GOBL::I18n::String
25
+ validates_presence_of :name
26
+
27
+ # @!attribute [r] description
28
+ # Description is a human readable description of the catalogue.
29
+ # @return [GOBL::I18n::String]
30
+ property :description, GOBL::I18n::String
31
+
32
+ # @!attribute [r] extensions
33
+ # Extensions defines all the extensions offered by the catalogue.
34
+ # @return [Array<GOBL::CBC::Definition>]
35
+ property :extensions, [GOBL::CBC::Definition]
36
+ validates_presence_of :extensions
37
+ end
38
+ end
39
+ 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
- # Specific tax definitions inside this category.
49
- # @return [Array<Rate>]
50
- property :rates, [Rate]
43
+ # Specific tax definitions inside this category. Order is important.
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.
@@ -61,8 +56,13 @@ module GOBL
61
56
 
62
57
  # @!attribute [r] sources
63
58
  # List of sources for the information contained in this category.
64
- # @return [Array<Source>]
65
- property :sources, [Source]
59
+ # @return [Array<GOBL::CBC::Source>]
60
+ property :sources, [GOBL::CBC::Source]
61
+
62
+ # @!attribute [r] ext
63
+ # Extension 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
66
 
67
67
  # @!attribute [r] meta
68
68
  # Meta contains additional information about the category that is relevant for local frequently used formats.
@@ -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.
@@ -37,6 +37,11 @@ module GOBL
37
37
  # Stamps that must be copied from the preceding document.
38
38
  # @return [Array<GOBL::CBC::Key>]
39
39
  property :stamps, [GOBL::CBC::Key]
40
+
41
+ # @!attribute [r] copy_tax
42
+ # Copy tax from the preceding document to the document ref.
43
+ # @return [Boolean]
44
+ property :copy_tax, Boolean
40
45
  end
41
46
  end
42
47
  end
@@ -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
@@ -23,6 +23,11 @@ module GOBL
23
23
  # @return [GOBL::CBC::Code]
24
24
  property :code, GOBL::CBC::Code
25
25
 
26
+ # @!attribute [r] scheme
27
+ # Scheme is an optional field that may be used to override the tax regime's default tax scheme. Many electronic formats such as UBL or CII define an equivalent field. Examples: `VAT`, `GST`, `ST`, etc.
28
+ # @return [GOBL::CBC::Code]
29
+ property :scheme, GOBL::CBC::Code
30
+
26
31
  # @!attribute [r] type
27
32
  # Type is set according to the requirements of each regime, some have a single tax document type code, others require a choice to be made. Deprecated: Tax Identities should only be used for VAT or similar codes for companies. Use the identities array for other types of identification.
28
33
  # @return [GOBL::CBC::Key]
@@ -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,40 +51,40 @@ module GOBL
46
51
  property :currency, GOBL::Currency::Code
47
52
  validates_presence_of :currency
48
53
 
54
+ # @!attribute [r] tax_scheme
55
+ # TaxScheme defines the principal scheme of consumption tax that should be applied to the regime and associated with Tax IDs in some export formats such as UBL or CII. Some regimes may not have a Tax Scheme and as a consequence will not use tax identities, like the US.
56
+ # @return [GOBL::CBC::Code]
57
+ property :tax_scheme, GOBL::CBC::Code
58
+
59
+ # @!attribute [r] calculator_rounding_rule
60
+ # Rounding rule to use when calculating the tax totals, default is always `sum-then-round`.
61
+ # @return [GOBL::CBC::Key]
62
+ property :calculator_rounding_rule, GOBL::CBC::Key
63
+
49
64
  # @!attribute [r] tags
50
65
  # 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]
66
+ # @return [Array<TagSet>]
67
+ property :tags, [TagSet]
53
68
 
54
69
  # @!attribute [r] extensions
55
70
  # 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.
56
- # @return [Array<GOBL::CBC::KeyDefinition>]
57
- property :extensions, [GOBL::CBC::KeyDefinition]
58
-
59
- # @!attribute [r] tax_identity_type_keys
60
- # Tax Identity types specific for the regime and may be validated against.
61
- # @return [Array<GOBL::CBC::KeyDefinition>]
62
- property :tax_identity_type_keys, [GOBL::CBC::KeyDefinition]
63
-
64
- # @!attribute [r] identity_keys
65
- # Identity keys used in addition to regular tax identities and specific for the regime that may be validated against.
66
- # @return [Array<GOBL::CBC::KeyDefinition>]
67
- property :identity_keys, [GOBL::CBC::KeyDefinition]
71
+ # @return [Array<GOBL::CBC::Definition>]
72
+ property :extensions, [GOBL::CBC::Definition]
68
73
 
69
- # @!attribute [r] charge_keys
70
- # Charge keys specific for the regime and may be validated or used in the UI as suggestions
71
- # @return [Array<GOBL::CBC::KeyDefinition>]
72
- property :charge_keys, [GOBL::CBC::KeyDefinition]
74
+ # @!attribute [r] identities
75
+ # Identities used in addition to regular tax identities and specific for the regime that may be validated against.
76
+ # @return [Array<GOBL::CBC::Definition>]
77
+ property :identities, [GOBL::CBC::Definition]
73
78
 
74
79
  # @!attribute [r] payment_means_keys
75
80
  # PaymentMeansKeys specific for the regime that extend the original base payment means keys.
76
- # @return [Array<GOBL::CBC::KeyDefinition>]
77
- property :payment_means_keys, [GOBL::CBC::KeyDefinition]
81
+ # @return [Array<GOBL::CBC::Definition>]
82
+ property :payment_means_keys, [GOBL::CBC::Definition]
78
83
 
79
84
  # @!attribute [r] inbox_keys
80
85
  # InboxKeys specific to the regime that can be used to identify where a document should be forwarded to.
81
- # @return [Array<GOBL::CBC::KeyDefinition>]
82
- property :inbox_keys, [GOBL::CBC::KeyDefinition]
86
+ # @return [Array<GOBL::CBC::Definition>]
87
+ property :inbox_keys, [GOBL::CBC::Definition]
83
88
 
84
89
  # @!attribute [r] scenarios
85
90
  # @return [Array<ScenarioSet>]
@@ -87,13 +92,13 @@ module GOBL
87
92
 
88
93
  # @!attribute [r] corrections
89
94
  # Configuration details for corrections to be used with correction options.
90
- # @return [Array<CorrectionDefinition>]
91
- property :corrections, [CorrectionDefinition]
95
+ # @return [CorrectionSet]
96
+ property :corrections, CorrectionSet
92
97
 
93
98
  # @!attribute [r] categories
94
99
  # List of tax categories.
95
- # @return [Array<Category>]
96
- property :categories, [Category]
100
+ # @return [Array<CategoryDef>]
101
+ property :categories, [CategoryDef]
97
102
  validates_presence_of :categories
98
103
  end
99
104
  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,29 +23,34 @@ 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_code
36
+ # Extension code that along side the key must be present for a match to happen. This cannot be used without an `cbc.Code`. The value will be copied to the note code if needed.
37
+ # @return [GOBL::CBC::Code]
38
+ property :ext_code, GOBL::CBC::Code
29
39
 
30
40
  # @!attribute [r] note
31
41
  # A note to be added to the document if the scenario is applied.
32
- # @return [GOBL::CBC::Note]
33
- property :note, GOBL::CBC::Note
42
+ # @return [ScenarioNote]
43
+ property :note, ScenarioNote
34
44
 
35
45
  # @!attribute [r] codes
36
46
  # Codes is used to define additional codes for regime specific situations.
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
@@ -0,0 +1,42 @@
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
+ # ScenarioNote represents the structure of the note that needs to be added to the document.
11
+ class ScenarioNote < GOBL::Object
12
+ # The Schema ID of the GOBL ScenarioNote structure
13
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime-def#/$defs/ScenarioNote'
14
+
15
+ # @!attribute [r] key
16
+ # Key specifying subject of the text
17
+ # @return [GOBL::CBC::Key]
18
+ property :key, GOBL::CBC::Key
19
+
20
+ # @!attribute [r] code
21
+ # Code used for additional data that may be required to identify the note.
22
+ # @return [GOBL::CBC::Code]
23
+ property :code, GOBL::CBC::Code
24
+
25
+ # @!attribute [r] src
26
+ # Source of this note, especially useful when auto-generated.
27
+ # @return [GOBL::CBC::Key]
28
+ property :src, GOBL::CBC::Key
29
+
30
+ # @!attribute [r] text
31
+ # The contents of the note
32
+ # @return [String]
33
+ property :text, String
34
+ validates_presence_of :text
35
+
36
+ # @!attribute [r] ext
37
+ # Extension data
38
+ # @return [GOBL::Tax::Extensions]
39
+ property :ext, GOBL::Tax::Extensions
40
+ end
41
+ end
42
+ 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
@@ -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::Definition>]
24
+ property :list, [GOBL::CBC::Definition]
25
+ validates_presence_of :list
26
+ end
27
+ end
28
+ end
@@ -18,10 +18,15 @@ module GOBL
18
18
  property :categories, [CategoryTotal]
19
19
 
20
20
  # @!attribute [r] sum
21
- # Total value of all the taxes applied.
21
+ # Total value of all non-retained or indirect taxes.
22
22
  # @return [GOBL::Num::Amount]
23
23
  property :sum, GOBL::Num::Amount
24
24
  validates_presence_of :sum
25
+
26
+ # @!attribute [r] retained
27
+ # Sum of retained or withheld tax amounts
28
+ # @return [GOBL::Num::Amount]
29
+ property :retained, GOBL::Num::Amount
25
30
  end
26
31
  end
27
32
  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.23.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