gobl 0.24.1 → 0.24.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c05a8d2c663dacaf04ba2e47c8e301896866c057891faaf8f7b5db1168af0131
4
- data.tar.gz: 06a29df7b9d6fa1d7f1cc4c40edbf7b097c8d70475989dfea18bcde1fdef2313
3
+ metadata.gz: 649f344374756decacf923113d2108a67234f9b66b289c3c0259e719355f1b05
4
+ data.tar.gz: 4562e67e48582d269a4b8523b697bd47f9fcd6a6ef54eade9d1b1030234696ce
5
5
  SHA512:
6
- metadata.gz: d14527af4570cc0f2eb47809e6afb5d8818cb156db9366577c71196950a9c37240764d988c6023a7bec7bbb52b4d2484ae5d14a75789f4803265441960350b04
7
- data.tar.gz: c50f2055c93d4a81eeb046a214f2e8af3fb2f2ee63d08b147f1d26705ae567ce428d16e6b447d6f8d22f783910225f84ae14d9354adb5b3afe5a9c76dede25d3
6
+ metadata.gz: 5a2f3b8785f823c1645f640e831a7c41fbe7b43a42a1c8c44acdb68c7135ea9c64ddabb342477bc54776aa30f328ab7fcd550399a729acceea931e81458a6905
7
+ data.tar.gz: 6c80265fcadf4b1bb5aa25e09a667a32d6606cf14c365270419ef520733762e64b02ef1cc1371dfb2f763fd68dc520c7e192313b454160cf4ac1ac3be09882a4
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GOBL
4
+ module Extensions
5
+ module Tax
6
+ # Additional methods for the generated {GOBL::Tax::Regime} class
7
+ module AddonHelper
8
+ module ClassMethods
9
+ # Loads a {GOBL::Tax::Regime} object identified by the given code with all its data
10
+ #
11
+ # @param code [String] the code of the regime to load
12
+ #
13
+ # @return [Regime] the requested regime
14
+ def fetch(code)
15
+ addons[code] ||= load_addon(code)
16
+ end
17
+
18
+ protected
19
+
20
+ # map of regime ID to regime instance
21
+ def addons
22
+ @addons ||= {}
23
+ end
24
+
25
+ def load_addon(code)
26
+ path = File.join("#{__dir__}/../../../../data/addons", "#{code.to_s.downcase}.json")
27
+ msg = "addon definition for #{code} does not exist at #{path}"
28
+ raise StandardError, msg unless File.exist?(path)
29
+
30
+ data = File.read(path)
31
+ from_json!(data)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ 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.24.1'
4
+ VERSION = '0.24.2'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -51,4 +51,5 @@ GOBL::Schema::Object.include GOBL::Extensions::Schema::ObjectHelper
51
51
  GOBL::Schema::Object.extend GOBL::Extensions::Schema::ObjectHelper::ClassMethods
52
52
  GOBL::Envelope.include GOBL::Extensions::EnvelopeHelper
53
53
  GOBL::Tax::RegimeDef.extend GOBL::Extensions::Tax::RegimeHelper::ClassMethods
54
+ GOBL::Tax::AddonDef.extend GOBL::Extensions::Tax::AddonHelper::ClassMethods
54
55
  GOBL::Bill::Invoice.include GOBL::Extensions::Bill::InvoiceHelper
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.24.1
4
+ version: 0.24.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luismi Cavalle
@@ -188,6 +188,7 @@ files:
188
188
  - lib/gobl/extensions/envelope_helper.rb
189
189
  - lib/gobl/extensions/i18n/value_keys_helper.rb
190
190
  - lib/gobl/extensions/schema/object_helper.rb
191
+ - lib/gobl/extensions/tax/addon_helper.rb
191
192
  - lib/gobl/extensions/tax/regime_helper.rb
192
193
  - lib/gobl/id.rb
193
194
  - lib/gobl/map.rb