gobl 0.4.1 → 0.5.1

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 (89) hide show
  1. checksums.yaml +4 -4
  2. data/data/regimes/co.json +14696 -0
  3. data/data/{tax/ES.json → regimes/es.json} +57 -57
  4. data/data/{tax/FR.json → regimes/fr.json} +1 -1
  5. data/data/{tax/GB.json → regimes/gb.json} +1 -1
  6. data/data/{tax/NL.json → regimes/nl.json} +1 -1
  7. data/lib/extensions.rb +1 -1
  8. data/lib/gobl/bill/advances.rb +1 -1
  9. data/lib/gobl/bill/charge.rb +3 -3
  10. data/lib/gobl/bill/delivery.rb +1 -1
  11. data/lib/gobl/bill/discount.rb +3 -3
  12. data/lib/gobl/bill/exchange_rates.rb +1 -1
  13. data/lib/gobl/bill/invoice.rb +5 -5
  14. data/lib/gobl/bill/invoice_type.rb +1 -1
  15. data/lib/gobl/bill/line.rb +3 -3
  16. data/lib/gobl/bill/line_charge.rb +1 -1
  17. data/lib/gobl/bill/line_discount.rb +1 -1
  18. data/lib/gobl/bill/ordering.rb +1 -1
  19. data/lib/gobl/bill/outlay.rb +1 -1
  20. data/lib/gobl/bill/payment.rb +1 -1
  21. data/lib/gobl/bill/preceding.rb +5 -5
  22. data/lib/gobl/bill/scheme_keys.rb +2 -2
  23. data/lib/gobl/bill/tax.rb +5 -5
  24. data/lib/gobl/bill/totals.rb +1 -1
  25. data/lib/gobl/cal/date.rb +1 -1
  26. data/lib/gobl/cal/period.rb +1 -1
  27. data/lib/gobl/{org → cbc}/code.rb +3 -3
  28. data/lib/gobl/{org → cbc}/key.rb +3 -3
  29. data/lib/gobl/{org → cbc}/meta.rb +2 -2
  30. data/lib/gobl/{org → cbc}/note.rb +3 -3
  31. data/lib/gobl/{org → cbc}/note_key.rb +3 -3
  32. data/lib/gobl/{org → cbc}/stamp.rb +5 -5
  33. data/lib/gobl/currency/code.rb +1 -1
  34. data/lib/gobl/currency/exchange_rate.rb +1 -1
  35. data/lib/gobl/document.rb +1 -1
  36. data/lib/gobl/dsig/digest.rb +1 -1
  37. data/lib/gobl/dsig/signature.rb +1 -1
  38. data/lib/gobl/envelope.rb +1 -1
  39. data/lib/gobl/header.rb +5 -5
  40. data/lib/gobl/i18n/string.rb +1 -1
  41. data/lib/gobl/l10n/code.rb +1 -1
  42. data/lib/gobl/l10n/country_code.rb +1 -1
  43. data/lib/gobl/note/message.rb +3 -3
  44. data/lib/gobl/org/address.rb +5 -6
  45. data/lib/gobl/org/coordinates.rb +1 -1
  46. data/lib/gobl/org/email.rb +3 -3
  47. data/lib/gobl/org/inbox.rb +5 -5
  48. data/lib/gobl/org/item.rb +3 -3
  49. data/lib/gobl/org/item_code.rb +1 -1
  50. data/lib/gobl/org/name.rb +3 -3
  51. data/lib/gobl/org/party.rb +5 -5
  52. data/lib/gobl/org/person.rb +3 -3
  53. data/lib/gobl/org/registration.rb +1 -1
  54. data/lib/gobl/org/telephone.rb +1 -1
  55. data/lib/gobl/org/unit.rb +1 -1
  56. data/lib/gobl/pay/advance.rb +1 -1
  57. data/lib/gobl/pay/card.rb +1 -1
  58. data/lib/gobl/pay/credit_transfer.rb +1 -1
  59. data/lib/gobl/pay/direct_debit.rb +1 -1
  60. data/lib/gobl/pay/due_date.rb +1 -1
  61. data/lib/gobl/pay/instructions.rb +3 -3
  62. data/lib/gobl/pay/method_key.rb +1 -1
  63. data/lib/gobl/pay/online.rb +1 -1
  64. data/lib/gobl/pay/term_key.rb +1 -1
  65. data/lib/gobl/pay/terms.rb +1 -1
  66. data/lib/gobl/tax/category.rb +4 -4
  67. data/lib/gobl/tax/category_total.rb +3 -3
  68. data/lib/gobl/tax/combo.rb +5 -5
  69. data/lib/gobl/{org/tax_identity.rb → tax/identity.rb} +11 -11
  70. data/lib/gobl/tax/rate.rb +4 -4
  71. data/lib/gobl/tax/rate_total.rb +3 -3
  72. data/lib/gobl/tax/rate_total_surcharge.rb +1 -1
  73. data/lib/gobl/tax/rate_value.rb +2 -2
  74. data/lib/gobl/tax/{region.rb → regime.rb} +14 -14
  75. data/lib/gobl/tax/scheme.rb +8 -8
  76. data/lib/gobl/tax/schemes.rb +1 -1
  77. data/lib/gobl/tax/set.rb +1 -1
  78. data/lib/gobl/{org → tax}/source_key.rb +3 -3
  79. data/lib/gobl/tax/total.rb +1 -1
  80. data/lib/gobl/tax/zone.rb +43 -0
  81. data/lib/gobl/uuid/uuid.rb +1 -1
  82. data/lib/gobl/version.rb +1 -1
  83. data/lib/gobl.rb +2 -1
  84. data/lib/gobl_extensions/tax/regime_helper.rb +35 -0
  85. metadata +18 -19
  86. data/data/tax/CO.json +0 -10212
  87. data/lib/gobl/tax/localities.rb +0 -14
  88. data/lib/gobl/tax/locality.rb +0 -34
  89. data/lib/gobl_extensions/tax/region_helper.rb +0 -35
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -56,8 +56,8 @@ module GOBL
56
56
 
57
57
  # @!attribute [r] meta
58
58
  # Non-structured additional data that may be useful.
59
- # @return [GOBL::Org::Meta]
60
- property :meta, GOBL::Org::Meta
59
+ # @return [GOBL::CBC::Meta]
60
+ property :meta, GOBL::CBC::Meta
61
61
  end
62
62
  end
63
63
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -11,11 +11,11 @@ module GOBL
11
11
  # Category contains the definition of a general type of tax inside a region.
12
12
  class Category < GOBL::Object
13
13
  # The Schema ID of the GOBL Category structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Category'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Category'
15
15
 
16
16
  # @!attribute [r] code
17
- # @return [GOBL::Org::Code]
18
- property :code, GOBL::Org::Code
17
+ # @return [GOBL::CBC::Code]
18
+ property :code, GOBL::CBC::Code
19
19
  validates :code, presence: true
20
20
 
21
21
  # @!attribute [r] name
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -14,8 +14,8 @@ module GOBL
14
14
  SCHEMA_ID = 'https://gobl.org/draft-0/tax/total#/$defs/CategoryTotal'
15
15
 
16
16
  # @!attribute [r] code
17
- # @return [GOBL::Org::Code]
18
- property :code, GOBL::Org::Code
17
+ # @return [GOBL::CBC::Code]
18
+ property :code, GOBL::CBC::Code
19
19
  validates :code, presence: true
20
20
 
21
21
  # @!attribute [r] retained
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -15,14 +15,14 @@ module GOBL
15
15
 
16
16
  # @!attribute [r] cat
17
17
  # Tax category code from those available inside a region.
18
- # @return [GOBL::Org::Code]
19
- property :cat, GOBL::Org::Code
18
+ # @return [GOBL::CBC::Code]
19
+ property :cat, GOBL::CBC::Code
20
20
  validates :cat, presence: true
21
21
 
22
22
  # @!attribute [r] rate
23
23
  # Rate within a category to apply.
24
- # @return [GOBL::Org::Key]
25
- property :rate, GOBL::Org::Key
24
+ # @return [GOBL::CBC::Key]
25
+ property :rate, GOBL::CBC::Key
26
26
 
27
27
  # @!attribute [r] percent
28
28
  # Percent defines the percentage set manually or determined from the rate key (calculated if rate present).
@@ -3,15 +3,15 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
10
- module Org
11
- # TaxIdentity stores the details required to identify an entity for tax purposes.
12
- class TaxIdentity < GOBL::Object
13
- # The Schema ID of the GOBL TaxIdentity structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/org/tax-identity'
10
+ module Tax
11
+ # Identity stores the details required to identify an entity for tax purposes.
12
+ class Identity < GOBL::Object
13
+ # The Schema ID of the GOBL Identity structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/identity'
15
15
 
16
16
  # @!attribute [r] uuid
17
17
  # Unique universal identity code for this tax identity.
@@ -24,10 +24,10 @@ module GOBL
24
24
  property :country, GOBL::L10n::CountryCode
25
25
  validates :country, presence: true
26
26
 
27
- # @!attribute [r] locality
28
- # Where inside a country the identity holder is based for tax purposes, like a city, county, province, state, or combination of various.
27
+ # @!attribute [r] zone
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
- property :locality, GOBL::L10n::Code
30
+ property :zone, GOBL::L10n::Code
31
31
 
32
32
  # @!attribute [r] source
33
33
  # What is the source document of the tax identity.
@@ -41,8 +41,8 @@ module GOBL
41
41
 
42
42
  # @!attribute [r] meta
43
43
  # Additional details that may be required.
44
- # @return [GOBL::Org::Meta]
45
- property :meta, GOBL::Org::Meta
44
+ # @return [GOBL::CBC::Meta]
45
+ property :meta, GOBL::CBC::Meta
46
46
  end
47
47
  end
48
48
  end
data/lib/gobl/tax/rate.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -11,12 +11,12 @@ module GOBL
11
11
  # Rate defines a single rate inside a category
12
12
  class Rate < GOBL::Object
13
13
  # The Schema ID of the GOBL Rate structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Rate'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Rate'
15
15
 
16
16
  # @!attribute [r] key
17
17
  # Key identifies this rate within the system
18
- # @return [GOBL::Org::Key]
19
- property :key, GOBL::Org::Key
18
+ # @return [GOBL::CBC::Key]
19
+ property :key, GOBL::CBC::Key
20
20
  validates :key, presence: true
21
21
 
22
22
  # @!attribute [r] name
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -14,8 +14,8 @@ module GOBL
14
14
  SCHEMA_ID = 'https://gobl.org/draft-0/tax/total#/$defs/RateTotal'
15
15
 
16
16
  # @!attribute [r] key
17
- # @return [GOBL::Org::Key]
18
- property :key, GOBL::Org::Key
17
+ # @return [GOBL::CBC::Key]
18
+ property :key, GOBL::CBC::Key
19
19
 
20
20
  # @!attribute [r] base
21
21
  # @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.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -11,7 +11,7 @@ module GOBL
11
11
  # RateValue contains a percentage rate or fixed amount for a given date range.
12
12
  class RateValue < GOBL::Object
13
13
  # The Schema ID of the GOBL RateValue structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/RateValue'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/RateValue'
15
15
 
16
16
  # @!attribute [r] since
17
17
  # Date from which this value should be applied.
@@ -3,18 +3,18 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
10
10
  module Tax
11
- # Region defines the holding structure for a regions categories and subsequent Rates and Values.
12
- class Region < GOBL::Object
13
- # The Schema ID of the GOBL Region structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/region'
11
+ # Regime defines the holding structure for the definitions of taxes inside a country or territory.
12
+ class Regime < GOBL::Object
13
+ # The Schema ID of the GOBL Regime structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime'
15
15
 
16
16
  # @!attribute [r] name
17
- # Name of the region
17
+ # Name of the country
18
18
  # @return [GOBL::I18n::String]
19
19
  property :name, GOBL::I18n::String
20
20
  validates :name, presence: true
@@ -25,18 +25,18 @@ module GOBL
25
25
  property :country, GOBL::L10n::CountryCode
26
26
  validates :country, presence: true
27
27
 
28
- # @!attribute [r] locality
29
- # Locality, city, province, county, or similar code inside the country, if needed.
28
+ # @!attribute [r] zone
29
+ # Specific Locality, region, city, province, county, or similar code inside the country, if needed.
30
30
  # @return [GOBL::L10n::Code]
31
- property :locality, GOBL::L10n::Code
31
+ property :zone, GOBL::L10n::Code
32
32
 
33
- # @!attribute [r] localities
34
- # List of sub-localities inside a region.
35
- # @return [Array<Locality>]
36
- property :localities, [Locality]
33
+ # @!attribute [r] zones
34
+ # List of sub-zones inside a country.
35
+ # @return [Array<Zone>]
36
+ property :zones, [Zone]
37
37
 
38
38
  # @!attribute [r] currency
39
- # Currency used by the region for tax purposes.
39
+ # Currency used by the country.
40
40
  # @return [GOBL::Currency::Code]
41
41
  property :currency, GOBL::Currency::Code
42
42
  validates :currency, presence: true
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -11,12 +11,12 @@ module GOBL
11
11
  # Scheme contains the definition of a scheme that belongs to a region and can be used to simplify validation processes for document contents.
12
12
  class Scheme < GOBL::Object
13
13
  # The Schema ID of the GOBL Scheme structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Scheme'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Scheme'
15
15
 
16
16
  # @!attribute [r] key
17
17
  # Key used to identify this scheme
18
- # @return [GOBL::Org::Key]
19
- property :key, GOBL::Org::Key
18
+ # @return [GOBL::CBC::Key]
19
+ property :key, GOBL::CBC::Key
20
20
  validates :key, presence: true
21
21
 
22
22
  # @!attribute [r] name
@@ -32,13 +32,13 @@ module GOBL
32
32
 
33
33
  # @!attribute [r] categories
34
34
  # List of tax category codes that can be used when this scheme is applied.
35
- # @return [Array<GOBL::Org::Code>]
36
- property :categories, [GOBL::Org::Code]
35
+ # @return [Array<GOBL::CBC::Code>]
36
+ property :categories, [GOBL::CBC::Code]
37
37
 
38
38
  # @!attribute [r] note
39
39
  # Note defines a message that should be added to a document when this scheme is used.
40
- # @return [GOBL::Org::Note]
41
- property :note, GOBL::Org::Note
40
+ # @return [GOBL::CBC::Note]
41
+ property :note, GOBL::CBC::Note
42
42
  end
43
43
  end
44
44
  end
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
data/lib/gobl/tax/set.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -3,15 +3,15 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
10
- module Org
10
+ module Tax
11
11
  # SourceKey identifies the source of a tax identity
12
12
  class SourceKey < GOBL::Enum
13
13
  # The Schema ID of the GOBL SourceKey structure
14
- SCHEMA_ID = 'https://gobl.org/draft-0/org/tax-identity#/$defs/SourceKey'
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/identity#/$defs/SourceKey'
15
15
 
16
16
  # The enumeration of values of the object and their descriptions (Values different to these are not allowed)
17
17
  ENUM = {
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ ##
4
+ ## DO NOT EDIT - This file was generated automatically.
5
+ ##
6
+ ## Generated with GOBL v0.34.0
7
+ ##
8
+
9
+ module GOBL
10
+ module Tax
11
+ # Zone represents an area inside a country, like a province or a state, which shares the basic definitions of the country, but may vary in some validation rules.
12
+ class Zone < GOBL::Object
13
+ # The Schema ID of the GOBL Zone structure
14
+ SCHEMA_ID = 'https://gobl.org/draft-0/tax/regime#/$defs/Zone'
15
+
16
+ # @!attribute [r] code
17
+ # Unique zone code.
18
+ # @return [GOBL::L10n::Code]
19
+ property :code, GOBL::L10n::Code
20
+ validates :code, presence: true
21
+
22
+ # @!attribute [r] name
23
+ # Name of the zone to be use if a locality or region is not applicable.
24
+ # @return [GOBL::I18n::String]
25
+ property :name, GOBL::I18n::String
26
+
27
+ # @!attribute [r] locality
28
+ # Village, town, district, or city name which should coincide with address data.
29
+ # @return [GOBL::I18n::String]
30
+ property :locality, GOBL::I18n::String
31
+
32
+ # @!attribute [r] region
33
+ # Province, county, or state which should match address data.
34
+ # @return [GOBL::I18n::String]
35
+ property :region, GOBL::I18n::String
36
+
37
+ # @!attribute [r] meta
38
+ # Any additional information
39
+ # @return [GOBL::CBC::Meta]
40
+ property :meta, GOBL::CBC::Meta
41
+ end
42
+ end
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.32.0
6
+ ## Generated with GOBL v0.34.1
7
7
  ##
8
8
 
9
9
  module GOBL
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.4.1'
4
+ VERSION = '0.5.1'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -19,7 +19,8 @@ loader.inflector.inflect(
19
19
  'item_id' => 'ItemID',
20
20
  'tax_id' => 'TaxID',
21
21
  'dsig' => 'DSig',
22
- 'id' => 'ID'
22
+ 'id' => 'ID',
23
+ 'cbc' => 'CBC'
23
24
  )
24
25
  loader.setup
25
26
 
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GOBLExtensions
4
+ module Tax
5
+ # Additional methods for the generated {GOBL::Tax::Regime} class
6
+ module RegimeHelper
7
+ module ClassMethods
8
+ # Loads a {GOBL::Tax::Regime} object identified by the given code with all its data
9
+ #
10
+ # @param code [String] the code of the regime to load
11
+ #
12
+ # @return [Regime] the requested regime
13
+ def fetch(code)
14
+ regimes[code] ||= load_regime(code)
15
+ end
16
+
17
+ protected
18
+
19
+ # map of regime ID to regime instance
20
+ def regimes
21
+ @regimes ||= {}
22
+ end
23
+
24
+ def load_regime(code)
25
+ path = File.join("#{__dir__}/../../../data/regimes", "#{code.to_s.downcase}.json")
26
+ msg = "regime definition for #{code} does not exist at #{path}"
27
+ raise StandardError, msg unless File.exist?(path)
28
+
29
+ data = File.read(path)
30
+ from_json!(data)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
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.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Lilue
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2022-12-13 00:00:00.000000000 Z
13
+ date: 2023-01-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -74,11 +74,11 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - data/tax/CO.json
78
- - data/tax/ES.json
79
- - data/tax/FR.json
80
- - data/tax/GB.json
81
- - data/tax/NL.json
77
+ - data/regimes/co.json
78
+ - data/regimes/es.json
79
+ - data/regimes/fr.json
80
+ - data/regimes/gb.json
81
+ - data/regimes/nl.json
82
82
  - lib/ext/hashme.rb
83
83
  - lib/extensions.rb
84
84
  - lib/gobl.rb
@@ -101,6 +101,12 @@ files:
101
101
  - lib/gobl/bill/totals.rb
102
102
  - lib/gobl/cal/date.rb
103
103
  - lib/gobl/cal/period.rb
104
+ - lib/gobl/cbc/code.rb
105
+ - lib/gobl/cbc/key.rb
106
+ - lib/gobl/cbc/meta.rb
107
+ - lib/gobl/cbc/note.rb
108
+ - lib/gobl/cbc/note_key.rb
109
+ - lib/gobl/cbc/stamp.rb
104
110
  - lib/gobl/config.rb
105
111
  - lib/gobl/currency/code.rb
106
112
  - lib/gobl/currency/exchange_rate.rb
@@ -123,23 +129,15 @@ files:
123
129
  - lib/gobl/operations/service_error.rb
124
130
  - lib/gobl/operations/validation_result.rb
125
131
  - lib/gobl/org/address.rb
126
- - lib/gobl/org/code.rb
127
132
  - lib/gobl/org/coordinates.rb
128
133
  - lib/gobl/org/email.rb
129
134
  - lib/gobl/org/inbox.rb
130
135
  - lib/gobl/org/item.rb
131
136
  - lib/gobl/org/item_code.rb
132
- - lib/gobl/org/key.rb
133
- - lib/gobl/org/meta.rb
134
137
  - lib/gobl/org/name.rb
135
- - lib/gobl/org/note.rb
136
- - lib/gobl/org/note_key.rb
137
138
  - lib/gobl/org/party.rb
138
139
  - lib/gobl/org/person.rb
139
140
  - lib/gobl/org/registration.rb
140
- - lib/gobl/org/source_key.rb
141
- - lib/gobl/org/stamp.rb
142
- - lib/gobl/org/tax_identity.rb
143
141
  - lib/gobl/org/telephone.rb
144
142
  - lib/gobl/org/unit.rb
145
143
  - lib/gobl/pay/advance.rb
@@ -156,24 +154,25 @@ files:
156
154
  - lib/gobl/tax/category.rb
157
155
  - lib/gobl/tax/category_total.rb
158
156
  - lib/gobl/tax/combo.rb
159
- - lib/gobl/tax/localities.rb
160
- - lib/gobl/tax/locality.rb
157
+ - lib/gobl/tax/identity.rb
161
158
  - lib/gobl/tax/rate.rb
162
159
  - lib/gobl/tax/rate_total.rb
163
160
  - lib/gobl/tax/rate_total_surcharge.rb
164
161
  - lib/gobl/tax/rate_value.rb
165
- - lib/gobl/tax/region.rb
162
+ - lib/gobl/tax/regime.rb
166
163
  - lib/gobl/tax/scheme.rb
167
164
  - lib/gobl/tax/schemes.rb
168
165
  - lib/gobl/tax/set.rb
166
+ - lib/gobl/tax/source_key.rb
169
167
  - lib/gobl/tax/total.rb
168
+ - lib/gobl/tax/zone.rb
170
169
  - lib/gobl/uuid/uuid.rb
171
170
  - lib/gobl/value.rb
172
171
  - lib/gobl/version.rb
173
172
  - lib/gobl_extensions/document_helper.rb
174
173
  - lib/gobl_extensions/envelope_helper.rb
175
174
  - lib/gobl_extensions/i18n/value_keys_helper.rb
176
- - lib/gobl_extensions/tax/region_helper.rb
175
+ - lib/gobl_extensions/tax/regime_helper.rb
177
176
  homepage: https://github.com/invopop/gobl.ruby
178
177
  licenses:
179
178
  - Apache-2.0