gobl 0.4.0 → 0.5.0

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/lib/extensions.rb +1 -1
  3. data/lib/gobl/bill/advances.rb +1 -1
  4. data/lib/gobl/bill/charge.rb +3 -3
  5. data/lib/gobl/bill/delivery.rb +1 -1
  6. data/lib/gobl/bill/discount.rb +3 -3
  7. data/lib/gobl/bill/exchange_rates.rb +1 -1
  8. data/lib/gobl/bill/invoice.rb +5 -5
  9. data/lib/gobl/bill/invoice_type.rb +1 -1
  10. data/lib/gobl/bill/line.rb +3 -3
  11. data/lib/gobl/bill/line_charge.rb +1 -1
  12. data/lib/gobl/bill/line_discount.rb +1 -1
  13. data/lib/gobl/bill/ordering.rb +1 -1
  14. data/lib/gobl/bill/outlay.rb +1 -1
  15. data/lib/gobl/bill/payment.rb +1 -1
  16. data/lib/gobl/bill/preceding.rb +5 -5
  17. data/lib/gobl/bill/scheme_keys.rb +2 -2
  18. data/lib/gobl/bill/tax.rb +5 -5
  19. data/lib/gobl/bill/totals.rb +1 -1
  20. data/lib/gobl/cal/date.rb +1 -1
  21. data/lib/gobl/cal/period.rb +1 -1
  22. data/lib/gobl/{org → cbc}/code.rb +3 -3
  23. data/lib/gobl/{org → cbc}/key.rb +3 -3
  24. data/lib/gobl/{org → cbc}/meta.rb +2 -2
  25. data/lib/gobl/{org → cbc}/note.rb +3 -3
  26. data/lib/gobl/{org → cbc}/note_key.rb +3 -3
  27. data/lib/gobl/{org → cbc}/stamp.rb +5 -5
  28. data/lib/gobl/currency/code.rb +1 -1
  29. data/lib/gobl/currency/exchange_rate.rb +1 -1
  30. data/lib/gobl/document.rb +1 -1
  31. data/lib/gobl/dsig/digest.rb +1 -1
  32. data/lib/gobl/dsig/signature.rb +1 -1
  33. data/lib/gobl/envelope.rb +1 -1
  34. data/lib/gobl/header.rb +5 -5
  35. data/lib/gobl/i18n/string.rb +1 -1
  36. data/lib/gobl/l10n/code.rb +1 -1
  37. data/lib/gobl/l10n/country_code.rb +1 -1
  38. data/lib/gobl/map.rb +5 -1
  39. data/lib/gobl/note/message.rb +3 -3
  40. data/lib/gobl/org/address.rb +5 -6
  41. data/lib/gobl/org/coordinates.rb +1 -1
  42. data/lib/gobl/org/email.rb +3 -3
  43. data/lib/gobl/org/inbox.rb +5 -5
  44. data/lib/gobl/org/item.rb +3 -3
  45. data/lib/gobl/org/item_code.rb +1 -1
  46. data/lib/gobl/org/name.rb +3 -3
  47. data/lib/gobl/org/party.rb +5 -5
  48. data/lib/gobl/org/person.rb +3 -3
  49. data/lib/gobl/org/registration.rb +1 -1
  50. data/lib/gobl/org/telephone.rb +1 -1
  51. data/lib/gobl/org/unit.rb +1 -1
  52. data/lib/gobl/pay/advance.rb +1 -1
  53. data/lib/gobl/pay/card.rb +1 -1
  54. data/lib/gobl/pay/credit_transfer.rb +1 -1
  55. data/lib/gobl/pay/direct_debit.rb +1 -1
  56. data/lib/gobl/pay/due_date.rb +1 -1
  57. data/lib/gobl/pay/instructions.rb +3 -3
  58. data/lib/gobl/pay/method_key.rb +1 -1
  59. data/lib/gobl/pay/online.rb +1 -1
  60. data/lib/gobl/pay/term_key.rb +1 -1
  61. data/lib/gobl/pay/terms.rb +1 -1
  62. data/lib/gobl/tax/category.rb +4 -4
  63. data/lib/gobl/tax/category_total.rb +3 -3
  64. data/lib/gobl/tax/combo.rb +5 -5
  65. data/lib/gobl/{org/tax_identity.rb → tax/identity.rb} +11 -11
  66. data/lib/gobl/tax/rate.rb +4 -4
  67. data/lib/gobl/tax/rate_total.rb +3 -3
  68. data/lib/gobl/tax/rate_total_surcharge.rb +1 -1
  69. data/lib/gobl/tax/rate_value.rb +2 -2
  70. data/lib/gobl/tax/{region.rb → regime.rb} +14 -14
  71. data/lib/gobl/tax/scheme.rb +8 -8
  72. data/lib/gobl/tax/schemes.rb +1 -1
  73. data/lib/gobl/tax/set.rb +1 -1
  74. data/lib/gobl/{org → tax}/source_key.rb +3 -3
  75. data/lib/gobl/tax/total.rb +1 -1
  76. data/lib/gobl/tax/zone.rb +43 -0
  77. data/lib/gobl/uuid/uuid.rb +1 -1
  78. data/lib/gobl/value.rb +19 -0
  79. data/lib/gobl/version.rb +1 -1
  80. data/lib/gobl.rb +2 -1
  81. data/lib/gobl_extensions/tax/regime_helper.rb +35 -0
  82. metadata +14 -20
  83. data/data/tax/CO.json +0 -10212
  84. data/data/tax/ES.json +0 -902
  85. data/data/tax/FR.json +0 -47
  86. data/data/tax/GB.json +0 -56
  87. data/data/tax/NL.json +0 -60
  88. data/lib/gobl/tax/localities.rb +0 -14
  89. data/lib/gobl/tax/locality.rb +0 -34
  90. 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
data/lib/gobl/value.rb CHANGED
@@ -46,6 +46,25 @@ module GOBL
46
46
  end
47
47
  end
48
48
 
49
+ # Returns whether the current value is equal to a given one, unlike `#==`, without
50
+ # doing any coercion. That is, the other object must be of the same class to return
51
+ # true.
52
+ #
53
+ # @param other [Object] the other value to compare with
54
+ #
55
+ # @return [Boolean] `true` if the values are equal, `false` otherwise
56
+ def eql?(other)
57
+ self.class == other.class && _value.eql?(other._value)
58
+ end
59
+
60
+ # Returns a integer hash code of the current value that respects the following
61
+ # property: Given objects `a` and `b`. If `a.eql?(b)`, then `a.hash == b.hash`.
62
+ #
63
+ # @return [Integer] hash code of the current value
64
+ def hash
65
+ [self.class.name, _value].hash
66
+ end
67
+
49
68
  # @api private
50
69
  def as_json(...)
51
70
  _value.as_json(...)
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.0'
4
+ VERSION = '0.5.0'
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.0
4
+ version: 0.5.0
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-11-30 00:00:00.000000000 Z
13
+ date: 2023-01-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -74,11 +74,6 @@ 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
82
77
  - lib/ext/hashme.rb
83
78
  - lib/extensions.rb
84
79
  - lib/gobl.rb
@@ -101,6 +96,12 @@ files:
101
96
  - lib/gobl/bill/totals.rb
102
97
  - lib/gobl/cal/date.rb
103
98
  - lib/gobl/cal/period.rb
99
+ - lib/gobl/cbc/code.rb
100
+ - lib/gobl/cbc/key.rb
101
+ - lib/gobl/cbc/meta.rb
102
+ - lib/gobl/cbc/note.rb
103
+ - lib/gobl/cbc/note_key.rb
104
+ - lib/gobl/cbc/stamp.rb
104
105
  - lib/gobl/config.rb
105
106
  - lib/gobl/currency/code.rb
106
107
  - lib/gobl/currency/exchange_rate.rb
@@ -123,23 +124,15 @@ files:
123
124
  - lib/gobl/operations/service_error.rb
124
125
  - lib/gobl/operations/validation_result.rb
125
126
  - lib/gobl/org/address.rb
126
- - lib/gobl/org/code.rb
127
127
  - lib/gobl/org/coordinates.rb
128
128
  - lib/gobl/org/email.rb
129
129
  - lib/gobl/org/inbox.rb
130
130
  - lib/gobl/org/item.rb
131
131
  - lib/gobl/org/item_code.rb
132
- - lib/gobl/org/key.rb
133
- - lib/gobl/org/meta.rb
134
132
  - lib/gobl/org/name.rb
135
- - lib/gobl/org/note.rb
136
- - lib/gobl/org/note_key.rb
137
133
  - lib/gobl/org/party.rb
138
134
  - lib/gobl/org/person.rb
139
135
  - 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
136
  - lib/gobl/org/telephone.rb
144
137
  - lib/gobl/org/unit.rb
145
138
  - lib/gobl/pay/advance.rb
@@ -156,24 +149,25 @@ files:
156
149
  - lib/gobl/tax/category.rb
157
150
  - lib/gobl/tax/category_total.rb
158
151
  - lib/gobl/tax/combo.rb
159
- - lib/gobl/tax/localities.rb
160
- - lib/gobl/tax/locality.rb
152
+ - lib/gobl/tax/identity.rb
161
153
  - lib/gobl/tax/rate.rb
162
154
  - lib/gobl/tax/rate_total.rb
163
155
  - lib/gobl/tax/rate_total_surcharge.rb
164
156
  - lib/gobl/tax/rate_value.rb
165
- - lib/gobl/tax/region.rb
157
+ - lib/gobl/tax/regime.rb
166
158
  - lib/gobl/tax/scheme.rb
167
159
  - lib/gobl/tax/schemes.rb
168
160
  - lib/gobl/tax/set.rb
161
+ - lib/gobl/tax/source_key.rb
169
162
  - lib/gobl/tax/total.rb
163
+ - lib/gobl/tax/zone.rb
170
164
  - lib/gobl/uuid/uuid.rb
171
165
  - lib/gobl/value.rb
172
166
  - lib/gobl/version.rb
173
167
  - lib/gobl_extensions/document_helper.rb
174
168
  - lib/gobl_extensions/envelope_helper.rb
175
169
  - lib/gobl_extensions/i18n/value_keys_helper.rb
176
- - lib/gobl_extensions/tax/region_helper.rb
170
+ - lib/gobl_extensions/tax/regime_helper.rb
177
171
  homepage: https://github.com/invopop/gobl.ruby
178
172
  licenses:
179
173
  - Apache-2.0
@@ -194,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
188
  - !ruby/object:Gem::Version
195
189
  version: 3.1.4
196
190
  requirements: []
197
- rubygems_version: 3.3.7
191
+ rubygems_version: 3.3.26
198
192
  signing_key:
199
193
  specification_version: 4
200
194
  summary: Minimalist ruby version of the GOBL library