gobl 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/data/tax/ES.json +841 -0
- data/data/tax/FR.json +47 -0
- data/data/tax/GB.json +56 -0
- data/data/tax/NL.json +60 -0
- data/home/cavalle/workspace/invopop/gobl.ruby/gobl.gemspec +30 -0
- data/lib/extensions.rb +12 -0
- data/lib/gobl/bill/advances.rb +90 -0
- data/lib/gobl/bill/charge.rb +121 -0
- data/lib/gobl/bill/delivery.rb +79 -0
- data/lib/gobl/bill/discount.rb +121 -0
- data/lib/gobl/bill/exchange_rates.rb +90 -0
- data/lib/gobl/bill/invoice.rb +209 -0
- data/lib/gobl/bill/invoice_type.rb +163 -0
- data/lib/gobl/bill/line.rb +121 -0
- data/lib/gobl/bill/line_charge.rb +79 -0
- data/lib/gobl/bill/line_discount.rb +79 -0
- data/lib/gobl/bill/ordering.rb +58 -0
- data/lib/gobl/bill/outlay.rb +107 -0
- data/lib/gobl/bill/payment.rb +79 -0
- data/lib/gobl/bill/preceding.rb +114 -0
- data/lib/gobl/bill/scheme_keys.rb +90 -0
- data/lib/gobl/bill/tax.rb +72 -0
- data/lib/gobl/bill/totals.rb +135 -0
- data/lib/gobl/cal/date.rb +106 -0
- data/lib/gobl/cal/period.rb +63 -0
- data/lib/gobl/config.rb +14 -0
- data/lib/gobl/currency/code.rb +322 -0
- data/lib/gobl/currency/exchange_rate.rb +65 -0
- data/lib/gobl/document.rb +70 -0
- data/lib/gobl/dsig/digest.rb +65 -0
- data/lib/gobl/dsig/signature.rb +106 -0
- data/lib/gobl/envelope.rb +77 -0
- data/lib/gobl/header.rb +98 -0
- data/lib/gobl/i18n/string.rb +72 -0
- data/lib/gobl/id.rb +80 -0
- data/lib/gobl/l10n/code.rb +106 -0
- data/lib/gobl/l10n/country_code.rb +405 -0
- data/lib/gobl/note/message.rb +72 -0
- data/lib/gobl/num/amount.rb +248 -0
- data/lib/gobl/num/percentage.rb +84 -0
- data/lib/gobl/operations/service_error.rb +10 -0
- data/lib/gobl/operations/validation_result.rb +46 -0
- data/lib/gobl/operations.rb +170 -0
- data/lib/gobl/org/address.rb +156 -0
- data/lib/gobl/org/code.rb +106 -0
- data/lib/gobl/org/coordinates.rb +79 -0
- data/lib/gobl/org/email.rb +79 -0
- data/lib/gobl/org/inbox.rb +86 -0
- data/lib/gobl/org/item.rb +121 -0
- data/lib/gobl/org/item_code.rb +65 -0
- data/lib/gobl/org/key.rb +106 -0
- data/lib/gobl/org/meta.rb +72 -0
- data/lib/gobl/org/name.rb +114 -0
- data/lib/gobl/org/note.rb +79 -0
- data/lib/gobl/org/note_key.rb +181 -0
- data/lib/gobl/org/party.rb +135 -0
- data/lib/gobl/org/person.rb +100 -0
- data/lib/gobl/org/registration.rb +99 -0
- data/lib/gobl/org/source_key.rb +161 -0
- data/lib/gobl/org/tax_identity.rb +93 -0
- data/lib/gobl/org/telephone.rb +72 -0
- data/lib/gobl/org/unit.rb +204 -0
- data/lib/gobl/pay/advance.rb +107 -0
- data/lib/gobl/pay/card.rb +65 -0
- data/lib/gobl/pay/credit_transfer.rb +86 -0
- data/lib/gobl/pay/direct_debit.rb +72 -0
- data/lib/gobl/pay/due_date.rb +86 -0
- data/lib/gobl/pay/instructions.rb +114 -0
- data/lib/gobl/pay/method_key.rb +163 -0
- data/lib/gobl/pay/online.rb +65 -0
- data/lib/gobl/pay/term_key.rb +166 -0
- data/lib/gobl/pay/terms.rb +79 -0
- data/lib/gobl/stamp.rb +63 -0
- data/lib/gobl/struct.rb +48 -0
- data/lib/gobl/tax/category.rb +83 -0
- data/lib/gobl/tax/category_total.rb +87 -0
- data/lib/gobl/tax/combo.rb +79 -0
- data/lib/gobl/tax/localities.rb +90 -0
- data/lib/gobl/tax/locality.rb +72 -0
- data/lib/gobl/tax/rate.rb +77 -0
- data/lib/gobl/tax/rate_total.rb +82 -0
- data/lib/gobl/tax/rate_total_surcharge.rb +63 -0
- data/lib/gobl/tax/rate_value.rb +79 -0
- data/lib/gobl/tax/region.rb +100 -0
- data/lib/gobl/tax/scheme.rb +86 -0
- data/lib/gobl/tax/schemes.rb +90 -0
- data/lib/gobl/tax/set.rb +90 -0
- data/lib/gobl/tax/total.rb +65 -0
- data/lib/gobl/types.rb +17 -0
- data/lib/gobl/uuid/uuid.rb +106 -0
- data/lib/gobl/version.rb +5 -0
- data/lib/gobl.rb +41 -0
- data/lib/gobl_extensions/document_helper.rb +45 -0
- data/lib/gobl_extensions/envelope_helper.rb +15 -0
- data/lib/gobl_extensions/i18n/value_keys_helper.rb +27 -0
- data/lib/gobl_extensions/tax/region_helper.rb +41 -0
- metadata +225 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# Category contains the definition of a general type of tax inside a region.
|
12
|
+
class Category < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Category structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Category'
|
15
|
+
|
16
|
+
# @!attribute [r] code
|
17
|
+
# @return [GOBL::Org::Code]
|
18
|
+
attribute :code, GOBL::Org::Code
|
19
|
+
|
20
|
+
# @!attribute [r] name
|
21
|
+
# @return [GOBL::I18n::String]
|
22
|
+
attribute :name, GOBL::I18n::String
|
23
|
+
|
24
|
+
# @!attribute [r] desc
|
25
|
+
# @return [GOBL::I18n::String]
|
26
|
+
attribute? :desc, GOBL::I18n::String.optional
|
27
|
+
|
28
|
+
# @!attribute [r] retained
|
29
|
+
# Retained when true implies that the tax amount will be retained by the buyer on behalf of the supplier, and thus subtracted from the invoice taxable base total. Typically used for taxes related to income.
|
30
|
+
# @return [Boolean]
|
31
|
+
attribute? :retained, GOBL::Types::Bool.optional
|
32
|
+
|
33
|
+
# @!attribute [r] rates
|
34
|
+
# Specific tax definitions inside this category.
|
35
|
+
# @return [Array<Rate>]
|
36
|
+
attribute :rates, GOBL::Types::Array.of(Rate)
|
37
|
+
|
38
|
+
# Creates a new object from a hash of GOBL data
|
39
|
+
#
|
40
|
+
# @param data [Hash] a hash of GOBL data
|
41
|
+
#
|
42
|
+
# @return [Category] the object created from the given data
|
43
|
+
def self.from_gobl!(data)
|
44
|
+
data = GOBL::Types::Hash[data]
|
45
|
+
|
46
|
+
new(
|
47
|
+
code: GOBL::Org::Code.from_gobl!(data['code']),
|
48
|
+
name: GOBL::I18n::String.from_gobl!(data['name']),
|
49
|
+
desc: data['desc'] ? GOBL::I18n::String.from_gobl!(data['desc']) : nil,
|
50
|
+
retained: data['retained'],
|
51
|
+
rates: data['rates']&.map { |item| Rate.from_gobl!(item) }
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Returns a hash of GOBL data representing the current object
|
56
|
+
#
|
57
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
58
|
+
def to_gobl
|
59
|
+
{
|
60
|
+
'code' => attributes[:code]&.to_gobl,
|
61
|
+
'name' => attributes[:name]&.to_gobl,
|
62
|
+
'desc' => attributes[:desc]&.to_gobl,
|
63
|
+
'retained' => attributes[:retained],
|
64
|
+
'rates' => attributes[:rates]&.map { |item| item&.to_gobl }
|
65
|
+
}.compact
|
66
|
+
end
|
67
|
+
|
68
|
+
# @!method self.new(attrs)
|
69
|
+
#
|
70
|
+
# Returns a {Category} object from a given hash of attributes. Nested
|
71
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
72
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
73
|
+
# parameter.
|
74
|
+
#
|
75
|
+
# The `new` method will only allow to create a new object if all attributes
|
76
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
77
|
+
#
|
78
|
+
# @param attrs [Hash] the hash of attributes
|
79
|
+
#
|
80
|
+
# @return [Category] the object corresponding to the given input
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# CategoryTotal groups together all rates inside a given category.
|
12
|
+
class CategoryTotal < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL CategoryTotal structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/total#/$defs/CategoryTotal'
|
15
|
+
|
16
|
+
# @!attribute [r] code
|
17
|
+
# @return [GOBL::Org::Code]
|
18
|
+
attribute :code, GOBL::Org::Code
|
19
|
+
|
20
|
+
# @!attribute [r] retained
|
21
|
+
# @return [Boolean]
|
22
|
+
attribute? :retained, GOBL::Types::Bool.optional
|
23
|
+
|
24
|
+
# @!attribute [r] rates
|
25
|
+
# @return [Array<RateTotal>]
|
26
|
+
attribute :rates, GOBL::Types::Array.of(RateTotal)
|
27
|
+
|
28
|
+
# @!attribute [r] base
|
29
|
+
# @return [GOBL::Num::Amount]
|
30
|
+
attribute :base, GOBL::Types.Constructor(GOBL::Num::Amount)
|
31
|
+
|
32
|
+
# @!attribute [r] amount
|
33
|
+
# @return [GOBL::Num::Amount]
|
34
|
+
attribute :amount, GOBL::Types.Constructor(GOBL::Num::Amount)
|
35
|
+
|
36
|
+
# @!attribute [r] surcharge
|
37
|
+
# @return [GOBL::Num::Amount]
|
38
|
+
attribute? :surcharge, GOBL::Types.Constructor(GOBL::Num::Amount).optional
|
39
|
+
|
40
|
+
# Creates a new object from a hash of GOBL data
|
41
|
+
#
|
42
|
+
# @param data [Hash] a hash of GOBL data
|
43
|
+
#
|
44
|
+
# @return [CategoryTotal] the object created from the given data
|
45
|
+
def self.from_gobl!(data)
|
46
|
+
data = GOBL::Types::Hash[data]
|
47
|
+
|
48
|
+
new(
|
49
|
+
code: GOBL::Org::Code.from_gobl!(data['code']),
|
50
|
+
retained: data['retained'],
|
51
|
+
rates: data['rates']&.map { |item| RateTotal.from_gobl!(item) },
|
52
|
+
base: data['base'],
|
53
|
+
amount: data['amount'],
|
54
|
+
surcharge: data['surcharge'] || nil
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns a hash of GOBL data representing the current object
|
59
|
+
#
|
60
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
61
|
+
def to_gobl
|
62
|
+
{
|
63
|
+
'code' => attributes[:code]&.to_gobl,
|
64
|
+
'retained' => attributes[:retained],
|
65
|
+
'rates' => attributes[:rates]&.map { |item| item&.to_gobl },
|
66
|
+
'base' => attributes[:base]&.to_gobl,
|
67
|
+
'amount' => attributes[:amount]&.to_gobl,
|
68
|
+
'surcharge' => attributes[:surcharge]&.to_gobl
|
69
|
+
}.compact
|
70
|
+
end
|
71
|
+
|
72
|
+
# @!method self.new(attrs)
|
73
|
+
#
|
74
|
+
# Returns a {CategoryTotal} object from a given hash of attributes. Nested
|
75
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
76
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
77
|
+
# parameter.
|
78
|
+
#
|
79
|
+
# The `new` method will only allow to create a new object if all attributes
|
80
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
81
|
+
#
|
82
|
+
# @param attrs [Hash] the hash of attributes
|
83
|
+
#
|
84
|
+
# @return [CategoryTotal] the object corresponding to the given input
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# Combo represents the tax combination of a category code and rate key.
|
12
|
+
class Combo < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Combo structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/set#/$defs/Combo'
|
15
|
+
|
16
|
+
# @!attribute [r] cat
|
17
|
+
# Tax category code from those available inside a region.
|
18
|
+
# @return [GOBL::Org::Code]
|
19
|
+
attribute :cat, GOBL::Org::Code
|
20
|
+
|
21
|
+
# @!attribute [r] rate
|
22
|
+
# Rate within a category to apply.
|
23
|
+
# @return [GOBL::Org::Key]
|
24
|
+
attribute? :rate, GOBL::Org::Key.optional
|
25
|
+
|
26
|
+
# @!attribute [r] percent
|
27
|
+
# Percent defines the percentage set manually or determined from the rate key (calculated if rate present).
|
28
|
+
# @return [GOBL::Num::Percentage]
|
29
|
+
attribute? :percent, GOBL::Types.Constructor(GOBL::Num::Percentage).optional
|
30
|
+
|
31
|
+
# @!attribute [r] surcharge
|
32
|
+
# Some countries require an additional surcharge (calculated if rate present).
|
33
|
+
# @return [GOBL::Num::Percentage]
|
34
|
+
attribute? :surcharge, GOBL::Types.Constructor(GOBL::Num::Percentage).optional
|
35
|
+
|
36
|
+
# Creates a new object from a hash of GOBL data
|
37
|
+
#
|
38
|
+
# @param data [Hash] a hash of GOBL data
|
39
|
+
#
|
40
|
+
# @return [Combo] the object created from the given data
|
41
|
+
def self.from_gobl!(data)
|
42
|
+
data = GOBL::Types::Hash[data]
|
43
|
+
|
44
|
+
new(
|
45
|
+
cat: GOBL::Org::Code.from_gobl!(data['cat']),
|
46
|
+
rate: data['rate'] ? GOBL::Org::Key.from_gobl!(data['rate']) : nil,
|
47
|
+
percent: data['percent'] || nil,
|
48
|
+
surcharge: data['surcharge'] || nil
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a hash of GOBL data representing the current object
|
53
|
+
#
|
54
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
55
|
+
def to_gobl
|
56
|
+
{
|
57
|
+
'cat' => attributes[:cat]&.to_gobl,
|
58
|
+
'rate' => attributes[:rate]&.to_gobl,
|
59
|
+
'percent' => attributes[:percent]&.to_gobl,
|
60
|
+
'surcharge' => attributes[:surcharge]&.to_gobl
|
61
|
+
}.compact
|
62
|
+
end
|
63
|
+
|
64
|
+
# @!method self.new(attrs)
|
65
|
+
#
|
66
|
+
# Returns a {Combo} object from a given hash of attributes. Nested
|
67
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
68
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
69
|
+
# parameter.
|
70
|
+
#
|
71
|
+
# The `new` method will only allow to create a new object if all attributes
|
72
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
73
|
+
#
|
74
|
+
# @param attrs [Hash] the hash of attributes
|
75
|
+
#
|
76
|
+
# @return [Combo] the object corresponding to the given input
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# Localities stores an array of locality objects used to describe areas sub-divisions inside a region.
|
12
|
+
class Localities < GOBL::Struct
|
13
|
+
extend Forwardable
|
14
|
+
include Enumerable
|
15
|
+
|
16
|
+
# The Schema ID of the GOBL Localities structure
|
17
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Localities'
|
18
|
+
|
19
|
+
attribute :_ary, GOBL::Types::Array.of(Locality)
|
20
|
+
|
21
|
+
# @!method [](*args)
|
22
|
+
# Returns elements from the array
|
23
|
+
# @overload [](index)
|
24
|
+
# Returns the element in a specific position
|
25
|
+
# @param index [Integer] the position of the object
|
26
|
+
# @return [Locality] the element in the `index` position
|
27
|
+
# @overload [](start, length)
|
28
|
+
# Returns all the elements within a range of positions
|
29
|
+
# @param start [Integer] start position of the range
|
30
|
+
# @param length [Integer] length of the range
|
31
|
+
# @return [Array<Locality>] the elements in the range
|
32
|
+
# @overload [](range)
|
33
|
+
# Returns all the elements within a range
|
34
|
+
# @param range [Range] start and end positions of the range
|
35
|
+
# @return [Array<Locality>] the elements in the range
|
36
|
+
#
|
37
|
+
# @!method each
|
38
|
+
# Iterates over the array elements
|
39
|
+
# @overload each(&block)
|
40
|
+
# Calls the given block with each element in the array
|
41
|
+
# @yield [element] element of the array
|
42
|
+
# @return [self] the object itself
|
43
|
+
# @overload each
|
44
|
+
# Returns an Enumerator that iterates over the array elements
|
45
|
+
# @return [Enumerator] the enumerator of the array elements
|
46
|
+
#
|
47
|
+
# @!method empty?
|
48
|
+
# Returns `true` if the number of elements in the array is zero, `false` otherwise.
|
49
|
+
# @return [Boolean] whether the array is empty or not
|
50
|
+
#
|
51
|
+
# @!method length
|
52
|
+
# Returns the number of elements in the array
|
53
|
+
# @return [Integer] the number of elements in the array
|
54
|
+
def_delegators :_ary, :[], :each, :empty?, :length
|
55
|
+
|
56
|
+
# Creates a new object from an array of GOBL data
|
57
|
+
#
|
58
|
+
# @param data [Array] an array of GOBL data
|
59
|
+
#
|
60
|
+
# @return [Localities] the object created from the given data
|
61
|
+
def self.from_gobl!(data)
|
62
|
+
new(_ary: data&.map { |item| Locality.from_gobl!(item) })
|
63
|
+
end
|
64
|
+
|
65
|
+
# Returns an array of GOBL data representing the current object
|
66
|
+
#
|
67
|
+
# @return [Array<Hash>] the array of GOBL data that represents the current object
|
68
|
+
def to_gobl
|
69
|
+
_ary.map(&:to_gobl)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns a {Localities} object from a given array of structs. The array may
|
73
|
+
# contain {Locality} objects or hashes. If hashes are provided, the constructor
|
74
|
+
# will call `Locality#new` to generate the objects that will be part of the
|
75
|
+
# returned {Localities} object
|
76
|
+
#
|
77
|
+
# @param object [Array<Locality, Hash>] the array containing the structs
|
78
|
+
#
|
79
|
+
# @return [Localities] the object corresponding to the given input
|
80
|
+
def self.new(object)
|
81
|
+
case object
|
82
|
+
when Array
|
83
|
+
super _ary: object
|
84
|
+
else # internal use, not to be used in public calls
|
85
|
+
super
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# Locality represents an area inside a region, like a province or a state, which shares the basic definitions of the region, but may vary in some validation rules.
|
12
|
+
class Locality < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Locality structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Locality'
|
15
|
+
|
16
|
+
# @!attribute [r] code
|
17
|
+
# Code
|
18
|
+
# @return [GOBL::L10n::Code]
|
19
|
+
attribute :code, GOBL::L10n::Code
|
20
|
+
|
21
|
+
# @!attribute [r] name
|
22
|
+
# Name of the locality with local and hopefully international translations.
|
23
|
+
# @return [GOBL::I18n::String]
|
24
|
+
attribute :name, GOBL::I18n::String
|
25
|
+
|
26
|
+
# @!attribute [r] meta
|
27
|
+
# Any additional information
|
28
|
+
# @return [GOBL::Org::Meta]
|
29
|
+
attribute? :meta, GOBL::Org::Meta.optional
|
30
|
+
|
31
|
+
# Creates a new object from a hash of GOBL data
|
32
|
+
#
|
33
|
+
# @param data [Hash] a hash of GOBL data
|
34
|
+
#
|
35
|
+
# @return [Locality] the object created from the given data
|
36
|
+
def self.from_gobl!(data)
|
37
|
+
data = GOBL::Types::Hash[data]
|
38
|
+
|
39
|
+
new(
|
40
|
+
code: GOBL::L10n::Code.from_gobl!(data['code']),
|
41
|
+
name: GOBL::I18n::String.from_gobl!(data['name']),
|
42
|
+
meta: data['meta'] ? GOBL::Org::Meta.from_gobl!(data['meta']) : nil
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns a hash of GOBL data representing the current object
|
47
|
+
#
|
48
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
49
|
+
def to_gobl
|
50
|
+
{
|
51
|
+
'code' => attributes[:code]&.to_gobl,
|
52
|
+
'name' => attributes[:name]&.to_gobl,
|
53
|
+
'meta' => attributes[:meta]&.to_gobl
|
54
|
+
}.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!method self.new(attrs)
|
58
|
+
#
|
59
|
+
# Returns a {Locality} object from a given hash of attributes. Nested
|
60
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
61
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
62
|
+
# parameter.
|
63
|
+
#
|
64
|
+
# The `new` method will only allow to create a new object if all attributes
|
65
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
66
|
+
#
|
67
|
+
# @param attrs [Hash] the hash of attributes
|
68
|
+
#
|
69
|
+
# @return [Locality] the object corresponding to the given input
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# Rate defines a single rate inside a category
|
12
|
+
class Rate < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Rate structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/region#/$defs/Rate'
|
15
|
+
|
16
|
+
# @!attribute [r] key
|
17
|
+
# Key identifies this rate within the system
|
18
|
+
# @return [GOBL::Org::Key]
|
19
|
+
attribute :key, GOBL::Org::Key
|
20
|
+
|
21
|
+
# @!attribute [r] name
|
22
|
+
# @return [GOBL::I18n::String]
|
23
|
+
attribute :name, GOBL::I18n::String
|
24
|
+
|
25
|
+
# @!attribute [r] desc
|
26
|
+
# @return [GOBL::I18n::String]
|
27
|
+
attribute? :desc, GOBL::I18n::String.optional
|
28
|
+
|
29
|
+
# @!attribute [r] values
|
30
|
+
# Values contains a list of Value objects that contain the current and historical percentage values for the rate; order is important, newer values should come before older values.
|
31
|
+
# @return [Array<RateValue>]
|
32
|
+
attribute :values, GOBL::Types::Array.of(RateValue)
|
33
|
+
|
34
|
+
# Creates a new object from a hash of GOBL data
|
35
|
+
#
|
36
|
+
# @param data [Hash] a hash of GOBL data
|
37
|
+
#
|
38
|
+
# @return [Rate] the object created from the given data
|
39
|
+
def self.from_gobl!(data)
|
40
|
+
data = GOBL::Types::Hash[data]
|
41
|
+
|
42
|
+
new(
|
43
|
+
key: GOBL::Org::Key.from_gobl!(data['key']),
|
44
|
+
name: GOBL::I18n::String.from_gobl!(data['name']),
|
45
|
+
desc: data['desc'] ? GOBL::I18n::String.from_gobl!(data['desc']) : nil,
|
46
|
+
values: data['values']&.map { |item| RateValue.from_gobl!(item) }
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns a hash of GOBL data representing the current object
|
51
|
+
#
|
52
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
53
|
+
def to_gobl
|
54
|
+
{
|
55
|
+
'key' => attributes[:key]&.to_gobl,
|
56
|
+
'name' => attributes[:name]&.to_gobl,
|
57
|
+
'desc' => attributes[:desc]&.to_gobl,
|
58
|
+
'values' => attributes[:values]&.map { |item| item&.to_gobl }
|
59
|
+
}.compact
|
60
|
+
end
|
61
|
+
|
62
|
+
# @!method self.new(attrs)
|
63
|
+
#
|
64
|
+
# Returns a {Rate} object from a given hash of attributes. Nested
|
65
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
66
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
67
|
+
# parameter.
|
68
|
+
#
|
69
|
+
# The `new` method will only allow to create a new object if all attributes
|
70
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
71
|
+
#
|
72
|
+
# @param attrs [Hash] the hash of attributes
|
73
|
+
#
|
74
|
+
# @return [Rate] the object corresponding to the given input
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# RateTotal contains a sum of all the tax rates in the document with a matching category and rate.
|
12
|
+
class RateTotal < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL RateTotal structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/total#/$defs/RateTotal'
|
15
|
+
|
16
|
+
# @!attribute [r] key
|
17
|
+
# @return [GOBL::Org::Key]
|
18
|
+
attribute? :key, GOBL::Org::Key.optional
|
19
|
+
|
20
|
+
# @!attribute [r] base
|
21
|
+
# @return [GOBL::Num::Amount]
|
22
|
+
attribute :base, GOBL::Types.Constructor(GOBL::Num::Amount)
|
23
|
+
|
24
|
+
# @!attribute [r] percent
|
25
|
+
# @return [GOBL::Num::Percentage]
|
26
|
+
attribute :percent, GOBL::Types.Constructor(GOBL::Num::Percentage)
|
27
|
+
|
28
|
+
# @!attribute [r] amount
|
29
|
+
# Total amount of rate, excluding surcharges
|
30
|
+
# @return [GOBL::Num::Amount]
|
31
|
+
attribute :amount, GOBL::Types.Constructor(GOBL::Num::Amount)
|
32
|
+
|
33
|
+
# @!attribute [r] surcharge
|
34
|
+
# @return [RateTotalSurcharge]
|
35
|
+
attribute? :surcharge, RateTotalSurcharge.optional
|
36
|
+
|
37
|
+
# Creates a new object from a hash of GOBL data
|
38
|
+
#
|
39
|
+
# @param data [Hash] a hash of GOBL data
|
40
|
+
#
|
41
|
+
# @return [RateTotal] the object created from the given data
|
42
|
+
def self.from_gobl!(data)
|
43
|
+
data = GOBL::Types::Hash[data]
|
44
|
+
|
45
|
+
new(
|
46
|
+
key: data['key'] ? GOBL::Org::Key.from_gobl!(data['key']) : nil,
|
47
|
+
base: data['base'],
|
48
|
+
percent: data['percent'],
|
49
|
+
amount: data['amount'],
|
50
|
+
surcharge: data['surcharge'] ? RateTotalSurcharge.from_gobl!(data['surcharge']) : nil
|
51
|
+
)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns a hash of GOBL data representing the current object
|
55
|
+
#
|
56
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
57
|
+
def to_gobl
|
58
|
+
{
|
59
|
+
'key' => attributes[:key]&.to_gobl,
|
60
|
+
'base' => attributes[:base]&.to_gobl,
|
61
|
+
'percent' => attributes[:percent]&.to_gobl,
|
62
|
+
'amount' => attributes[:amount]&.to_gobl,
|
63
|
+
'surcharge' => attributes[:surcharge]&.to_gobl
|
64
|
+
}.compact
|
65
|
+
end
|
66
|
+
|
67
|
+
# @!method self.new(attrs)
|
68
|
+
#
|
69
|
+
# Returns a {RateTotal} object from a given hash of attributes. Nested
|
70
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
71
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
72
|
+
# parameter.
|
73
|
+
#
|
74
|
+
# The `new` method will only allow to create a new object if all attributes
|
75
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
76
|
+
#
|
77
|
+
# @param attrs [Hash] the hash of attributes
|
78
|
+
#
|
79
|
+
# @return [RateTotal] the object corresponding to the given input
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
## DO NOT EDIT - This file was generated automatically.
|
5
|
+
##
|
6
|
+
## Generated with GOBL v0.30.4
|
7
|
+
##
|
8
|
+
|
9
|
+
module GOBL
|
10
|
+
module Tax
|
11
|
+
# RateTotalSurcharge reflects the sum surcharges inside the rate.
|
12
|
+
class RateTotalSurcharge < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL RateTotalSurcharge structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/tax/total#/$defs/RateTotalSurcharge'
|
15
|
+
|
16
|
+
# @!attribute [r] percent
|
17
|
+
# @return [GOBL::Num::Percentage]
|
18
|
+
attribute :percent, GOBL::Types.Constructor(GOBL::Num::Percentage)
|
19
|
+
|
20
|
+
# @!attribute [r] amount
|
21
|
+
# @return [GOBL::Num::Amount]
|
22
|
+
attribute :amount, GOBL::Types.Constructor(GOBL::Num::Amount)
|
23
|
+
|
24
|
+
# Creates a new object from a hash of GOBL data
|
25
|
+
#
|
26
|
+
# @param data [Hash] a hash of GOBL data
|
27
|
+
#
|
28
|
+
# @return [RateTotalSurcharge] the object created from the given data
|
29
|
+
def self.from_gobl!(data)
|
30
|
+
data = GOBL::Types::Hash[data]
|
31
|
+
|
32
|
+
new(
|
33
|
+
percent: data['percent'],
|
34
|
+
amount: data['amount']
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns a hash of GOBL data representing the current object
|
39
|
+
#
|
40
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
41
|
+
def to_gobl
|
42
|
+
{
|
43
|
+
'percent' => attributes[:percent]&.to_gobl,
|
44
|
+
'amount' => attributes[:amount]&.to_gobl
|
45
|
+
}.compact
|
46
|
+
end
|
47
|
+
|
48
|
+
# @!method self.new(attrs)
|
49
|
+
#
|
50
|
+
# Returns a {RateTotalSurcharge} object from a given hash of attributes. Nested
|
51
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
52
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
53
|
+
# parameter.
|
54
|
+
#
|
55
|
+
# The `new` method will only allow to create a new object if all attributes
|
56
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
57
|
+
#
|
58
|
+
# @param attrs [Hash] the hash of attributes
|
59
|
+
#
|
60
|
+
# @return [RateTotalSurcharge] the object corresponding to the given input
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|