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,100 @@
|
|
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 Org
|
11
|
+
# Person represents a human, and how to contact them electronically.
|
12
|
+
class Person < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Person structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/person'
|
15
|
+
|
16
|
+
# @!attribute [r] id
|
17
|
+
# Internal ID used to identify the person inside a document.
|
18
|
+
# @return [String]
|
19
|
+
attribute? :id, GOBL::Types::String.optional
|
20
|
+
|
21
|
+
# @!attribute [r] uuid
|
22
|
+
# Unique identity code
|
23
|
+
# @return [GOBL::UUID::UUID]
|
24
|
+
attribute? :uuid, GOBL::UUID::UUID.optional
|
25
|
+
|
26
|
+
# @!attribute [r] name
|
27
|
+
# Complete details on the name of the person
|
28
|
+
# @return [GOBL::Org::Name]
|
29
|
+
attribute :name, GOBL::Org::Name
|
30
|
+
|
31
|
+
# @!attribute [r] role
|
32
|
+
# What they do within an organization
|
33
|
+
# @return [String]
|
34
|
+
attribute? :role, GOBL::Types::String.optional
|
35
|
+
|
36
|
+
# @!attribute [r] emails
|
37
|
+
# Electronic mail addresses that belong to the person.
|
38
|
+
# @return [Array<GOBL::Org::Email>]
|
39
|
+
attribute? :emails, GOBL::Types::Array.of(GOBL::Org::Email).optional
|
40
|
+
|
41
|
+
# @!attribute [r] telephones
|
42
|
+
# Regular phone or mobile numbers
|
43
|
+
# @return [Array<GOBL::Org::Telephone>]
|
44
|
+
attribute? :telephones, GOBL::Types::Array.of(GOBL::Org::Telephone).optional
|
45
|
+
|
46
|
+
# @!attribute [r] meta
|
47
|
+
# Data about the data.
|
48
|
+
# @return [GOBL::Org::Meta]
|
49
|
+
attribute? :meta, GOBL::Org::Meta.optional
|
50
|
+
|
51
|
+
# Creates a new object from a hash of GOBL data
|
52
|
+
#
|
53
|
+
# @param data [Hash] a hash of GOBL data
|
54
|
+
#
|
55
|
+
# @return [Person] the object created from the given data
|
56
|
+
def self.from_gobl!(data)
|
57
|
+
data = GOBL::Types::Hash[data]
|
58
|
+
|
59
|
+
new(
|
60
|
+
id: data['id'],
|
61
|
+
uuid: data['uuid'] ? GOBL::UUID::UUID.from_gobl!(data['uuid']) : nil,
|
62
|
+
name: GOBL::Org::Name.from_gobl!(data['name']),
|
63
|
+
role: data['role'],
|
64
|
+
emails: data['emails']&.map { |item| GOBL::Org::Email.from_gobl!(item) },
|
65
|
+
telephones: data['telephones']&.map { |item| GOBL::Org::Telephone.from_gobl!(item) },
|
66
|
+
meta: data['meta'] ? GOBL::Org::Meta.from_gobl!(data['meta']) : nil
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns a hash of GOBL data representing the current object
|
71
|
+
#
|
72
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
73
|
+
def to_gobl
|
74
|
+
{
|
75
|
+
'id' => attributes[:id],
|
76
|
+
'uuid' => attributes[:uuid]&.to_gobl,
|
77
|
+
'name' => attributes[:name]&.to_gobl,
|
78
|
+
'role' => attributes[:role],
|
79
|
+
'emails' => attributes[:emails]&.map { |item| item&.to_gobl },
|
80
|
+
'telephones' => attributes[:telephones]&.map { |item| item&.to_gobl },
|
81
|
+
'meta' => attributes[:meta]&.to_gobl
|
82
|
+
}.compact
|
83
|
+
end
|
84
|
+
|
85
|
+
# @!method self.new(attrs)
|
86
|
+
#
|
87
|
+
# Returns a {Person} object from a given hash of attributes. Nested
|
88
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
89
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
90
|
+
# parameter.
|
91
|
+
#
|
92
|
+
# The `new` method will only allow to create a new object if all attributes
|
93
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
94
|
+
#
|
95
|
+
# @param attrs [Hash] the hash of attributes
|
96
|
+
#
|
97
|
+
# @return [Person] the object corresponding to the given input
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,99 @@
|
|
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 Org
|
11
|
+
# Registration is used in countries that require additional information to be associated with a company usually related to a specific registration office.
|
12
|
+
class Registration < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Registration structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/registration'
|
15
|
+
|
16
|
+
# @!attribute [r] uuid
|
17
|
+
# @return [GOBL::UUID::UUID]
|
18
|
+
attribute? :uuid, GOBL::UUID::UUID.optional
|
19
|
+
|
20
|
+
# @!attribute [r] office
|
21
|
+
# @return [String]
|
22
|
+
attribute? :office, GOBL::Types::String.optional
|
23
|
+
|
24
|
+
# @!attribute [r] book
|
25
|
+
# @return [String]
|
26
|
+
attribute? :book, GOBL::Types::String.optional
|
27
|
+
|
28
|
+
# @!attribute [r] volume
|
29
|
+
# @return [String]
|
30
|
+
attribute? :volume, GOBL::Types::String.optional
|
31
|
+
|
32
|
+
# @!attribute [r] sheet
|
33
|
+
# @return [String]
|
34
|
+
attribute? :sheet, GOBL::Types::String.optional
|
35
|
+
|
36
|
+
# @!attribute [r] section
|
37
|
+
# @return [String]
|
38
|
+
attribute? :section, GOBL::Types::String.optional
|
39
|
+
|
40
|
+
# @!attribute [r] page
|
41
|
+
# @return [String]
|
42
|
+
attribute? :page, GOBL::Types::String.optional
|
43
|
+
|
44
|
+
# @!attribute [r] entry
|
45
|
+
# @return [String]
|
46
|
+
attribute? :entry, GOBL::Types::String.optional
|
47
|
+
|
48
|
+
# Creates a new object from a hash of GOBL data
|
49
|
+
#
|
50
|
+
# @param data [Hash] a hash of GOBL data
|
51
|
+
#
|
52
|
+
# @return [Registration] the object created from the given data
|
53
|
+
def self.from_gobl!(data)
|
54
|
+
data = GOBL::Types::Hash[data]
|
55
|
+
|
56
|
+
new(
|
57
|
+
uuid: data['uuid'] ? GOBL::UUID::UUID.from_gobl!(data['uuid']) : nil,
|
58
|
+
office: data['office'],
|
59
|
+
book: data['book'],
|
60
|
+
volume: data['volume'],
|
61
|
+
sheet: data['sheet'],
|
62
|
+
section: data['section'],
|
63
|
+
page: data['page'],
|
64
|
+
entry: data['entry']
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns a hash of GOBL data representing the current object
|
69
|
+
#
|
70
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
71
|
+
def to_gobl
|
72
|
+
{
|
73
|
+
'uuid' => attributes[:uuid]&.to_gobl,
|
74
|
+
'office' => attributes[:office],
|
75
|
+
'book' => attributes[:book],
|
76
|
+
'volume' => attributes[:volume],
|
77
|
+
'sheet' => attributes[:sheet],
|
78
|
+
'section' => attributes[:section],
|
79
|
+
'page' => attributes[:page],
|
80
|
+
'entry' => attributes[:entry]
|
81
|
+
}.compact
|
82
|
+
end
|
83
|
+
|
84
|
+
# @!method self.new(attrs)
|
85
|
+
#
|
86
|
+
# Returns a {Registration} object from a given hash of attributes. Nested
|
87
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
88
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
89
|
+
# parameter.
|
90
|
+
#
|
91
|
+
# The `new` method will only allow to create a new object if all attributes
|
92
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
93
|
+
#
|
94
|
+
# @param attrs [Hash] the hash of attributes
|
95
|
+
#
|
96
|
+
# @return [Registration] the object corresponding to the given input
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,161 @@
|
|
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 Org
|
11
|
+
# SourceKey identifies the source of a tax identity
|
12
|
+
class SourceKey < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL SourceKey structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/tax-identity#/$defs/SourceKey'
|
15
|
+
|
16
|
+
# The enumeration of values of the object and their descriptions (Values different to these are not allowed)
|
17
|
+
ENUM = {
|
18
|
+
'tax-agency' => 'Sourced directly from a tax agency',
|
19
|
+
'passport' => 'A passport document',
|
20
|
+
'national' => 'National ID Card or similar',
|
21
|
+
'permit' => 'Residential or similar permit',
|
22
|
+
'other' => 'An other type of source not listed'
|
23
|
+
}.freeze
|
24
|
+
|
25
|
+
attribute :_value, GOBL::Types::String.enum(*ENUM.keys)
|
26
|
+
private :_value
|
27
|
+
|
28
|
+
# Creates a new object from a GOBL value
|
29
|
+
#
|
30
|
+
# @param data [String] the GOBL value
|
31
|
+
#
|
32
|
+
# @return [SourceKey] the object created from the given data
|
33
|
+
def self.from_gobl!(data)
|
34
|
+
new(_value: data)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns a GOBL value representing the current object
|
38
|
+
#
|
39
|
+
# @return [String] the GOBL value that represents the current object
|
40
|
+
def to_gobl
|
41
|
+
_value
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns a {SourceKey} that corresponds to a given object. The object can be a
|
45
|
+
# `Symbol`, a `String` or anything coercible into one (via `#to_s`).
|
46
|
+
#
|
47
|
+
# @param object [Symbol, String, #to_s] the value of the object.
|
48
|
+
#
|
49
|
+
# @return [SourceKey] the object corresponding to the given value.
|
50
|
+
#
|
51
|
+
# @example Instantiating from a symbol
|
52
|
+
# source_key = GOBL::Org::SourceKey.new(:tax_agency)
|
53
|
+
#
|
54
|
+
# @example Instantiating from a string
|
55
|
+
# source_key = GOBL::Org::SourceKey.new('tax-agency')
|
56
|
+
def self.new(object)
|
57
|
+
case object
|
58
|
+
when Hash, self # internal use, not to be used in public calls
|
59
|
+
super
|
60
|
+
when Symbol
|
61
|
+
new find_by_sym(object)
|
62
|
+
else
|
63
|
+
super _value: object.to_s
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the string representation of the current object
|
68
|
+
#
|
69
|
+
# @return [String] the string representation of the current object
|
70
|
+
def to_s
|
71
|
+
_value.to_s
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns the symbol representation of the current object
|
75
|
+
#
|
76
|
+
# @return [Symbol] the symbol representation of the current object
|
77
|
+
def to_sym
|
78
|
+
to_s.parameterize.underscore.to_sym
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns whether the current object is equivalent to a given one. In addition
|
82
|
+
# to {SourceKey} objects, the current object can be compared to a `Symbol`, a
|
83
|
+
# `String` or anything coercible into one (via `#to_s`)
|
84
|
+
#
|
85
|
+
# @param other [SourceKey, Symbol, String, #to_s] the other object to compare to
|
86
|
+
#
|
87
|
+
# @return [Boolean] `true` if the objects are equivalent, `false` otherwise
|
88
|
+
#
|
89
|
+
# @example Comparing to another {SourceKey} object
|
90
|
+
# source_key = GOBL::Org::SourceKey.new('tax-agency')
|
91
|
+
# source_key == GOBL::Org::SourceKey.new('tax-agency') #=> true
|
92
|
+
# source_key == GOBL::Org::SourceKey.new('passport') #=> false
|
93
|
+
#
|
94
|
+
# @example Comparing to a string
|
95
|
+
# source_key = GOBL::Org::SourceKey.new('tax-agency')
|
96
|
+
# source_key == 'tax-agency' #=> true
|
97
|
+
# source_key == 'passport' #=> false
|
98
|
+
#
|
99
|
+
# @example Comparing to a symbol
|
100
|
+
# source_key = GOBL::Org::SourceKey.new('tax-agency')
|
101
|
+
# source_key == :tax_agency #=> true
|
102
|
+
# source_key == :passport #=> false
|
103
|
+
def ==(other)
|
104
|
+
case other
|
105
|
+
when self.class
|
106
|
+
super
|
107
|
+
when Symbol
|
108
|
+
to_sym == other
|
109
|
+
else
|
110
|
+
to_s == other.to_s
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns an array with all the enumerated objects of this type
|
115
|
+
#
|
116
|
+
# @return [Array<SourceKey>] the array of enumerated objects
|
117
|
+
def self.all
|
118
|
+
ENUM.keys.map { |key| new(key) }
|
119
|
+
end
|
120
|
+
|
121
|
+
# @api private
|
122
|
+
def self.find_by_sym(sym)
|
123
|
+
all.find { |object| object.to_sym == sym }
|
124
|
+
end
|
125
|
+
|
126
|
+
# @api private
|
127
|
+
def self.find_by_inquirer(method_name)
|
128
|
+
method_name =~ /(.+)\?$/ && find_by_sym(Regexp.last_match(1).to_sym)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Returns the description of the current object
|
132
|
+
#
|
133
|
+
# @return [String] the description of the current object
|
134
|
+
def description
|
135
|
+
ENUM.fetch(_value, _value)
|
136
|
+
end
|
137
|
+
|
138
|
+
# @api private
|
139
|
+
def respond_to_missing?(method_name, include_private = false)
|
140
|
+
self.class.find_by_inquirer(method_name) || super
|
141
|
+
end
|
142
|
+
|
143
|
+
# Enables dynamic value inquirers like `SourceKey#tax_agency?` for
|
144
|
+
# each of the declared enum values (see {ENUM}). Each inquirer returns a
|
145
|
+
# `Boolean` denoting whether the value equals the enquired value (`true`) or
|
146
|
+
# not (`false`)
|
147
|
+
#
|
148
|
+
# @example
|
149
|
+
# source_key = GOBL::Org::SourceKey.new('tax-agency')
|
150
|
+
# source_key.tax_agency? # => true
|
151
|
+
# source_key.passport? # => false
|
152
|
+
def method_missing(method_name, *args, &block)
|
153
|
+
if value = self.class.find_by_inquirer(method_name)
|
154
|
+
self == value
|
155
|
+
else
|
156
|
+
super
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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 Org
|
11
|
+
# TaxIdentity stores the details required to identify an entity for tax purposes.
|
12
|
+
class TaxIdentity < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL TaxIdentity structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/tax-identity'
|
15
|
+
|
16
|
+
# @!attribute [r] uuid
|
17
|
+
# Unique universal identity code.
|
18
|
+
# @return [GOBL::UUID::UUID]
|
19
|
+
attribute? :uuid, GOBL::UUID::UUID.optional
|
20
|
+
|
21
|
+
# @!attribute [r] country
|
22
|
+
# ISO country code for Where the tax identity was issued.
|
23
|
+
# @return [GOBL::L10n::CountryCode]
|
24
|
+
attribute :country, GOBL::L10n::CountryCode
|
25
|
+
|
26
|
+
# @!attribute [r] locality
|
27
|
+
# Where inside a country the Tax ID was issued, if required.
|
28
|
+
# @return [GOBL::L10n::Code]
|
29
|
+
attribute? :locality, GOBL::L10n::Code.optional
|
30
|
+
|
31
|
+
# @!attribute [r] source
|
32
|
+
# What is the source document of this tax identity.
|
33
|
+
# @return [SourceKey]
|
34
|
+
attribute? :source, SourceKey.optional
|
35
|
+
|
36
|
+
# @!attribute [r] code
|
37
|
+
# Tax identity Code
|
38
|
+
# @return [String]
|
39
|
+
attribute? :code, GOBL::Types::String.optional
|
40
|
+
|
41
|
+
# @!attribute [r] meta
|
42
|
+
# Additional details that may be required.
|
43
|
+
# @return [GOBL::Org::Meta]
|
44
|
+
attribute? :meta, GOBL::Org::Meta.optional
|
45
|
+
|
46
|
+
# Creates a new object from a hash of GOBL data
|
47
|
+
#
|
48
|
+
# @param data [Hash] a hash of GOBL data
|
49
|
+
#
|
50
|
+
# @return [TaxIdentity] the object created from the given data
|
51
|
+
def self.from_gobl!(data)
|
52
|
+
data = GOBL::Types::Hash[data]
|
53
|
+
|
54
|
+
new(
|
55
|
+
uuid: data['uuid'] ? GOBL::UUID::UUID.from_gobl!(data['uuid']) : nil,
|
56
|
+
country: GOBL::L10n::CountryCode.from_gobl!(data['country']),
|
57
|
+
locality: data['locality'] ? GOBL::L10n::Code.from_gobl!(data['locality']) : nil,
|
58
|
+
source: data['source'] ? SourceKey.from_gobl!(data['source']) : nil,
|
59
|
+
code: data['code'],
|
60
|
+
meta: data['meta'] ? GOBL::Org::Meta.from_gobl!(data['meta']) : nil
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns a hash of GOBL data representing the current object
|
65
|
+
#
|
66
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
67
|
+
def to_gobl
|
68
|
+
{
|
69
|
+
'uuid' => attributes[:uuid]&.to_gobl,
|
70
|
+
'country' => attributes[:country]&.to_gobl,
|
71
|
+
'locality' => attributes[:locality]&.to_gobl,
|
72
|
+
'source' => attributes[:source]&.to_gobl,
|
73
|
+
'code' => attributes[:code],
|
74
|
+
'meta' => attributes[:meta]&.to_gobl
|
75
|
+
}.compact
|
76
|
+
end
|
77
|
+
|
78
|
+
# @!method self.new(attrs)
|
79
|
+
#
|
80
|
+
# Returns a {TaxIdentity} object from a given hash of attributes. Nested
|
81
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
82
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
83
|
+
# parameter.
|
84
|
+
#
|
85
|
+
# The `new` method will only allow to create a new object if all attributes
|
86
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
87
|
+
#
|
88
|
+
# @param attrs [Hash] the hash of attributes
|
89
|
+
#
|
90
|
+
# @return [TaxIdentity] the object corresponding to the given input
|
91
|
+
end
|
92
|
+
end
|
93
|
+
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 Org
|
11
|
+
# Telephone describes what is expected for a telephone number.
|
12
|
+
class Telephone < GOBL::Struct
|
13
|
+
# The Schema ID of the GOBL Telephone structure
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/telephone'
|
15
|
+
|
16
|
+
# @!attribute [r] uuid
|
17
|
+
# Unique identity code
|
18
|
+
# @return [GOBL::UUID::UUID]
|
19
|
+
attribute? :uuid, GOBL::UUID::UUID.optional
|
20
|
+
|
21
|
+
# @!attribute [r] label
|
22
|
+
# Identifier for this number.
|
23
|
+
# @return [String]
|
24
|
+
attribute? :label, GOBL::Types::String.optional
|
25
|
+
|
26
|
+
# @!attribute [r] num
|
27
|
+
# The number to be dialed in ITU E.164 international format.
|
28
|
+
# @return [String]
|
29
|
+
attribute :num, GOBL::Types::String
|
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 [Telephone] the object created from the given data
|
36
|
+
def self.from_gobl!(data)
|
37
|
+
data = GOBL::Types::Hash[data]
|
38
|
+
|
39
|
+
new(
|
40
|
+
uuid: data['uuid'] ? GOBL::UUID::UUID.from_gobl!(data['uuid']) : nil,
|
41
|
+
label: data['label'],
|
42
|
+
num: data['num']
|
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
|
+
'uuid' => attributes[:uuid]&.to_gobl,
|
52
|
+
'label' => attributes[:label],
|
53
|
+
'num' => attributes[:num]
|
54
|
+
}.compact
|
55
|
+
end
|
56
|
+
|
57
|
+
# @!method self.new(attrs)
|
58
|
+
#
|
59
|
+
# Returns a {Telephone} 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 [Telephone] the object corresponding to the given input
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|