gobl 0.13.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/data/regimes/it.json +13 -0
  3. data/data/regimes/pt.json +69 -0
  4. data/data/regimes/us.json +20 -0
  5. data/lib/generated/gobl/bill/charge.rb +1 -1
  6. data/lib/generated/gobl/bill/delivery.rb +1 -1
  7. data/lib/generated/gobl/bill/discount.rb +1 -1
  8. data/lib/generated/gobl/bill/document_reference.rb +1 -1
  9. data/lib/generated/gobl/bill/invoice.rb +1 -1
  10. data/lib/generated/gobl/bill/line.rb +1 -1
  11. data/lib/generated/gobl/bill/line_charge.rb +1 -1
  12. data/lib/generated/gobl/bill/line_discount.rb +1 -1
  13. data/lib/generated/gobl/bill/ordering.rb +1 -1
  14. data/lib/generated/gobl/bill/outlay.rb +1 -1
  15. data/lib/generated/gobl/bill/payment.rb +1 -1
  16. data/lib/generated/gobl/bill/preceding.rb +1 -1
  17. data/lib/generated/gobl/bill/tax.rb +1 -1
  18. data/lib/generated/gobl/bill/totals.rb +1 -1
  19. data/lib/generated/gobl/cal/date.rb +1 -1
  20. data/lib/generated/gobl/cal/period.rb +1 -1
  21. data/lib/generated/gobl/cbc/code.rb +1 -1
  22. data/lib/generated/gobl/cbc/key.rb +1 -1
  23. data/lib/generated/gobl/cbc/meta.rb +1 -1
  24. data/lib/generated/gobl/cbc/note.rb +1 -1
  25. data/lib/generated/gobl/cbc/stamp.rb +1 -1
  26. data/lib/generated/gobl/currency/code.rb +1 -1
  27. data/lib/generated/gobl/currency/exchange_rate.rb +1 -1
  28. data/lib/generated/gobl/document.rb +1 -1
  29. data/lib/generated/gobl/dsig/digest.rb +1 -1
  30. data/lib/generated/gobl/dsig/signature.rb +1 -1
  31. data/lib/generated/gobl/envelope.rb +1 -1
  32. data/lib/generated/gobl/header.rb +2 -2
  33. data/lib/generated/gobl/i18n/string.rb +1 -1
  34. data/lib/generated/gobl/l10n/code.rb +1 -1
  35. data/lib/generated/gobl/l10n/country_code.rb +38 -38
  36. data/lib/generated/gobl/note/message.rb +1 -1
  37. data/lib/generated/gobl/org/address.rb +1 -1
  38. data/lib/generated/gobl/org/coordinates.rb +1 -1
  39. data/lib/generated/gobl/org/email.rb +1 -1
  40. data/lib/generated/gobl/org/identity.rb +1 -1
  41. data/lib/generated/gobl/org/image.rb +1 -1
  42. data/lib/generated/gobl/org/inbox.rb +1 -1
  43. data/lib/generated/gobl/org/item.rb +1 -1
  44. data/lib/generated/gobl/org/name.rb +1 -1
  45. data/lib/generated/gobl/org/party.rb +1 -1
  46. data/lib/generated/gobl/org/person.rb +1 -1
  47. data/lib/generated/gobl/org/registration.rb +1 -1
  48. data/lib/generated/gobl/org/telephone.rb +1 -1
  49. data/lib/generated/gobl/org/unit.rb +1 -1
  50. data/lib/generated/gobl/org/website.rb +1 -1
  51. data/lib/generated/gobl/pay/advance.rb +1 -1
  52. data/lib/generated/gobl/pay/card.rb +1 -1
  53. data/lib/generated/gobl/pay/credit_transfer.rb +1 -1
  54. data/lib/generated/gobl/pay/direct_debit.rb +1 -1
  55. data/lib/generated/gobl/pay/due_date.rb +1 -1
  56. data/lib/generated/gobl/pay/instructions.rb +1 -1
  57. data/lib/generated/gobl/pay/online.rb +1 -1
  58. data/lib/generated/gobl/pay/terms.rb +2 -2
  59. data/lib/generated/gobl/tax/category.rb +1 -1
  60. data/lib/generated/gobl/tax/category_total.rb +1 -1
  61. data/lib/generated/gobl/tax/combo.rb +1 -1
  62. data/lib/generated/gobl/tax/identity.rb +1 -1
  63. data/lib/generated/gobl/tax/identity_type.rb +1 -1
  64. data/lib/generated/gobl/tax/key_definition.rb +1 -1
  65. data/lib/generated/gobl/tax/preceding_definitions.rb +1 -1
  66. data/lib/generated/gobl/tax/rate.rb +1 -1
  67. data/lib/generated/gobl/tax/rate_total.rb +1 -1
  68. data/lib/generated/gobl/tax/rate_total_surcharge.rb +1 -1
  69. data/lib/generated/gobl/tax/rate_value.rb +1 -1
  70. data/lib/generated/gobl/tax/regime.rb +1 -1
  71. data/lib/generated/gobl/tax/scenario.rb +1 -1
  72. data/lib/generated/gobl/tax/scenario_set.rb +1 -1
  73. data/lib/generated/gobl/tax/set.rb +1 -1
  74. data/lib/generated/gobl/tax/tag.rb +1 -1
  75. data/lib/generated/gobl/tax/total.rb +1 -1
  76. data/lib/generated/gobl/tax/zone.rb +1 -1
  77. data/lib/generated/gobl/uuid/uuid.rb +1 -1
  78. data/lib/gobl/extensions/bill/invoice_helper.rb +56 -0
  79. data/lib/gobl/extensions/bill/scenario_summary.rb +25 -0
  80. data/lib/gobl/version.rb +1 -1
  81. data/lib/gobl.rb +1 -0
  82. metadata +5 -2
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -23,7 +23,7 @@ module GOBL
23
23
  'instant' => 'On receipt of invoice',
24
24
  'elective' => 'Chosen by the buyer',
25
25
  'pending' => 'Seller to advise buyer in separate transaction',
26
- 'advance' => 'Payment made in advance',
26
+ 'advanced' => 'Payment made in advance',
27
27
  'delivery' => 'Payment on Delivery'
28
28
  }.freeze
29
29
 
@@ -3,7 +3,7 @@
3
3
  ##
4
4
  ## DO NOT EDIT - This file was generated automatically.
5
5
  ##
6
- ## Generated with GOBL v0.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
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.42.4
6
+ ## Generated with GOBL v0.42.8
7
7
  ##
8
8
 
9
9
  module GOBL
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GOBL
4
+ module Extensions
5
+ module Bill
6
+ # Additional methods for the generated {GOBL::Bill::Invoice} class
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)
11
+ end
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)
17
+ end
18
+
19
+ private
20
+
21
+ def regime_country
22
+ supplier&.tax_id&.country
23
+ 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
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GOBL
4
+ module Extensions
5
+ module Bill
6
+ # Aggregates the data of collection of scenarios
7
+ class ScenarioSummary
8
+ def initialize(scenarios)
9
+ @scenarios = scenarios
10
+ end
11
+
12
+ # Returns the aggregated metadata of the scenarios
13
+ def meta
14
+ scenarios.inject({}) do |meta, scenario|
15
+ meta.merge(scenario.meta.to_h)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :scenarios
22
+ end
23
+ end
24
+ end
25
+ 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.13.0'
4
+ VERSION = '0.14.1'
5
5
  end
data/lib/gobl.rb CHANGED
@@ -50,3 +50,4 @@ GOBL::Document.include GOBL::Extensions::DocumentHelper
50
50
  GOBL::Document.extend GOBL::Extensions::DocumentHelper::ClassMethods
51
51
  GOBL::Envelope.include GOBL::Extensions::EnvelopeHelper
52
52
  GOBL::Tax::Regime.extend GOBL::Extensions::Tax::RegimeHelper::ClassMethods
53
+ 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.13.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luismi Cavalle
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2023-04-28 00:00:00.000000000 Z
14
+ date: 2023-05-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -69,6 +69,7 @@ files:
69
69
  - data/regimes/it.json
70
70
  - data/regimes/nl.json
71
71
  - data/regimes/pt.json
72
+ - data/regimes/us.json
72
73
  - lib/generated/gobl/bill/charge.rb
73
74
  - lib/generated/gobl/bill/delivery.rb
74
75
  - lib/generated/gobl/bill/discount.rb
@@ -145,6 +146,8 @@ files:
145
146
  - lib/gobl.rb
146
147
  - lib/gobl/config.rb
147
148
  - lib/gobl/enum.rb
149
+ - lib/gobl/extensions/bill/invoice_helper.rb
150
+ - lib/gobl/extensions/bill/scenario_summary.rb
148
151
  - lib/gobl/extensions/document_helper.rb
149
152
  - lib/gobl/extensions/envelope_helper.rb
150
153
  - lib/gobl/extensions/i18n/value_keys_helper.rb