gobl 0.1.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 +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,204 @@
|
|
|
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
|
+
# Unit describes how the quantity of the product should be interpreted.
|
|
12
|
+
class Unit < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL Unit structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/org/unit'
|
|
15
|
+
|
|
16
|
+
# The enumeration of values of the object and their descriptions (Values different to these are also allowed)
|
|
17
|
+
ENUM = {
|
|
18
|
+
'g' => 'Metric grams',
|
|
19
|
+
'kg' => 'Metric kilograms',
|
|
20
|
+
't' => 'Metric tons',
|
|
21
|
+
'mm' => 'Milimetres',
|
|
22
|
+
'cm' => 'Centimetres',
|
|
23
|
+
'm' => 'Metres',
|
|
24
|
+
'km' => 'Kilometers',
|
|
25
|
+
'in' => 'Inches',
|
|
26
|
+
'ft' => 'Feet',
|
|
27
|
+
'm2' => 'Square metres',
|
|
28
|
+
'm3' => 'Cubic metres',
|
|
29
|
+
'cl' => 'Centilitres',
|
|
30
|
+
'l' => 'Litres',
|
|
31
|
+
'w' => 'Watts',
|
|
32
|
+
'kw' => 'Kilowatts',
|
|
33
|
+
'kwh' => 'Kilowatt Hours',
|
|
34
|
+
'day' => 'Days',
|
|
35
|
+
's' => 'Seconds',
|
|
36
|
+
'h' => 'Hours',
|
|
37
|
+
'min' => 'Minutes',
|
|
38
|
+
'piece' => 'Pieces',
|
|
39
|
+
'bag' => 'Bags',
|
|
40
|
+
'box' => 'Boxes',
|
|
41
|
+
'bin' => 'Bins',
|
|
42
|
+
'can' => 'Cans',
|
|
43
|
+
'tub' => 'Tubs',
|
|
44
|
+
'case' => 'Cases',
|
|
45
|
+
'tray' => 'Trays',
|
|
46
|
+
'portion' => 'Portions',
|
|
47
|
+
'dozen' => 'Dozens',
|
|
48
|
+
'roll' => 'Rolls',
|
|
49
|
+
'carton' => 'Cartons',
|
|
50
|
+
'cylinder' => 'Cylinders',
|
|
51
|
+
'barrel' => 'Barrels',
|
|
52
|
+
'jerrican' => 'Jerricans',
|
|
53
|
+
'carboy' => 'Carboys',
|
|
54
|
+
'demijohn' => 'Demijohn',
|
|
55
|
+
'bottle' => 'Bottles',
|
|
56
|
+
'6pack' => 'Six Packs',
|
|
57
|
+
'canister' => 'Canisters',
|
|
58
|
+
'pkg' => 'Packages',
|
|
59
|
+
'bunch' => 'Bunches',
|
|
60
|
+
'tetrabrik' => 'Tetra-Briks',
|
|
61
|
+
'pallet' => 'Pallets',
|
|
62
|
+
'reel' => 'Reels',
|
|
63
|
+
'sack' => 'Sacks',
|
|
64
|
+
'sheet' => 'Sheets',
|
|
65
|
+
'envelope' => 'Envelopes'
|
|
66
|
+
}.freeze
|
|
67
|
+
|
|
68
|
+
attribute :_value, GOBL::Types::String
|
|
69
|
+
private :_value
|
|
70
|
+
|
|
71
|
+
# Creates a new object from a GOBL value
|
|
72
|
+
#
|
|
73
|
+
# @param data [String] the GOBL value
|
|
74
|
+
#
|
|
75
|
+
# @return [Unit] the object created from the given data
|
|
76
|
+
def self.from_gobl!(data)
|
|
77
|
+
new(_value: data)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Returns a GOBL value representing the current object
|
|
81
|
+
#
|
|
82
|
+
# @return [String] the GOBL value that represents the current object
|
|
83
|
+
def to_gobl
|
|
84
|
+
_value
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Returns a {Unit} that corresponds to a given object. The object can be a
|
|
88
|
+
# `Symbol`, a `String` or anything coercible into one (via `#to_s`).
|
|
89
|
+
#
|
|
90
|
+
# @param object [Symbol, String, #to_s] the value of the object.
|
|
91
|
+
#
|
|
92
|
+
# @return [Unit] the object corresponding to the given value.
|
|
93
|
+
#
|
|
94
|
+
# @example Instantiating from a symbol
|
|
95
|
+
# unit = GOBL::Org::Unit.new(:g)
|
|
96
|
+
#
|
|
97
|
+
# @example Instantiating from a string
|
|
98
|
+
# unit = GOBL::Org::Unit.new('g')
|
|
99
|
+
def self.new(object)
|
|
100
|
+
case object
|
|
101
|
+
when Hash, self # internal use, not to be used in public calls
|
|
102
|
+
super
|
|
103
|
+
when Symbol
|
|
104
|
+
new find_by_sym(object) || object.to_s
|
|
105
|
+
else
|
|
106
|
+
super _value: object.to_s
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Returns the string representation of the current object
|
|
111
|
+
#
|
|
112
|
+
# @return [String] the string representation of the current object
|
|
113
|
+
def to_s
|
|
114
|
+
_value.to_s
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Returns the symbol representation of the current object
|
|
118
|
+
#
|
|
119
|
+
# @return [Symbol] the symbol representation of the current object
|
|
120
|
+
def to_sym
|
|
121
|
+
to_s.parameterize.underscore.to_sym
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Returns whether the current object is equivalent to a given one. In addition
|
|
125
|
+
# to {Unit} objects, the current object can be compared to a `Symbol`, a
|
|
126
|
+
# `String` or anything coercible into one (via `#to_s`)
|
|
127
|
+
#
|
|
128
|
+
# @param other [Unit, Symbol, String, #to_s] the other object to compare to
|
|
129
|
+
#
|
|
130
|
+
# @return [Boolean] `true` if the objects are equivalent, `false` otherwise
|
|
131
|
+
#
|
|
132
|
+
# @example Comparing to another {Unit} object
|
|
133
|
+
# unit = GOBL::Org::Unit.new('g')
|
|
134
|
+
# unit == GOBL::Org::Unit.new('g') #=> true
|
|
135
|
+
# unit == GOBL::Org::Unit.new('kg') #=> false
|
|
136
|
+
#
|
|
137
|
+
# @example Comparing to a string
|
|
138
|
+
# unit = GOBL::Org::Unit.new('g')
|
|
139
|
+
# unit == 'g' #=> true
|
|
140
|
+
# unit == 'kg' #=> false
|
|
141
|
+
#
|
|
142
|
+
# @example Comparing to a symbol
|
|
143
|
+
# unit = GOBL::Org::Unit.new('g')
|
|
144
|
+
# unit == :g #=> true
|
|
145
|
+
# unit == :kg #=> false
|
|
146
|
+
def ==(other)
|
|
147
|
+
case other
|
|
148
|
+
when self.class
|
|
149
|
+
super
|
|
150
|
+
when Symbol
|
|
151
|
+
to_sym == other
|
|
152
|
+
else
|
|
153
|
+
to_s == other.to_s
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Returns an array with all the enumerated objects of this type
|
|
158
|
+
#
|
|
159
|
+
# @return [Array<Unit>] the array of enumerated objects
|
|
160
|
+
def self.all
|
|
161
|
+
ENUM.keys.map { |key| new(key) }
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# @api private
|
|
165
|
+
def self.find_by_sym(sym)
|
|
166
|
+
all.find { |object| object.to_sym == sym }
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# @api private
|
|
170
|
+
def self.find_by_inquirer(method_name)
|
|
171
|
+
method_name =~ /(.+)\?$/ && find_by_sym(Regexp.last_match(1).to_sym)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns the description of the current object
|
|
175
|
+
#
|
|
176
|
+
# @return [String] the description of the current object
|
|
177
|
+
def description
|
|
178
|
+
ENUM.fetch(_value, _value)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# @api private
|
|
182
|
+
def respond_to_missing?(method_name, include_private = false)
|
|
183
|
+
self.class.find_by_inquirer(method_name) || super
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# Enables dynamic value inquirers like `Unit#g?` for
|
|
187
|
+
# each of the declared enum values (see {ENUM}). Each inquirer returns a
|
|
188
|
+
# `Boolean` denoting whether the value equals the enquired value (`true`) or
|
|
189
|
+
# not (`false`)
|
|
190
|
+
#
|
|
191
|
+
# @example
|
|
192
|
+
# unit = GOBL::Org::Unit.new('g')
|
|
193
|
+
# unit.g? # => true
|
|
194
|
+
# unit.kg? # => false
|
|
195
|
+
def method_missing(method_name, *args, &block)
|
|
196
|
+
if value = self.class.find_by_inquirer(method_name)
|
|
197
|
+
self == value
|
|
198
|
+
else
|
|
199
|
+
super
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
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 Pay
|
|
11
|
+
# Advance represents a single payment that has been made already, such as a deposit on an intent to purchase, or as credit from a previous invoice which was later corrected or cancelled.
|
|
12
|
+
class Advance < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL Advance structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/pay/advance'
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] uuid
|
|
17
|
+
# Unique identifier for this advance.
|
|
18
|
+
# @return [GOBL::UUID::UUID]
|
|
19
|
+
attribute? :uuid, GOBL::UUID::UUID.optional
|
|
20
|
+
|
|
21
|
+
# @!attribute [r] date
|
|
22
|
+
# When the advance was made.
|
|
23
|
+
# @return [GOBL::Cal::Date]
|
|
24
|
+
attribute? :date, GOBL::Cal::Date.optional
|
|
25
|
+
|
|
26
|
+
# @!attribute [r] ref
|
|
27
|
+
# ID or reference for the advance.
|
|
28
|
+
# @return [String]
|
|
29
|
+
attribute? :ref, GOBL::Types::String.optional
|
|
30
|
+
|
|
31
|
+
# @!attribute [r] grant
|
|
32
|
+
# If this "advance" payment has come from a public grant or subsidy, set this to true.
|
|
33
|
+
# @return [Boolean]
|
|
34
|
+
attribute? :grant, GOBL::Types::Bool.optional
|
|
35
|
+
|
|
36
|
+
# @!attribute [r] desc
|
|
37
|
+
# Details about the advance.
|
|
38
|
+
# @return [String]
|
|
39
|
+
attribute :desc, GOBL::Types::String
|
|
40
|
+
|
|
41
|
+
# @!attribute [r] percent
|
|
42
|
+
# How much as a percentage of the total with tax was paid
|
|
43
|
+
# @return [GOBL::Num::Percentage]
|
|
44
|
+
attribute? :percent, GOBL::Types.Constructor(GOBL::Num::Percentage).optional
|
|
45
|
+
|
|
46
|
+
# @!attribute [r] amount
|
|
47
|
+
# How much was paid.
|
|
48
|
+
# @return [GOBL::Num::Amount]
|
|
49
|
+
attribute :amount, GOBL::Types.Constructor(GOBL::Num::Amount)
|
|
50
|
+
|
|
51
|
+
# @!attribute [r] currency
|
|
52
|
+
# If different from the parent document's base currency.
|
|
53
|
+
# @return [GOBL::Currency::Code]
|
|
54
|
+
attribute? :currency, GOBL::Currency::Code.optional
|
|
55
|
+
|
|
56
|
+
# Creates a new object from a hash of GOBL data
|
|
57
|
+
#
|
|
58
|
+
# @param data [Hash] a hash of GOBL data
|
|
59
|
+
#
|
|
60
|
+
# @return [Advance] the object created from the given data
|
|
61
|
+
def self.from_gobl!(data)
|
|
62
|
+
data = GOBL::Types::Hash[data]
|
|
63
|
+
|
|
64
|
+
new(
|
|
65
|
+
uuid: data['uuid'] ? GOBL::UUID::UUID.from_gobl!(data['uuid']) : nil,
|
|
66
|
+
date: data['date'] ? GOBL::Cal::Date.from_gobl!(data['date']) : nil,
|
|
67
|
+
ref: data['ref'],
|
|
68
|
+
grant: data['grant'],
|
|
69
|
+
desc: data['desc'],
|
|
70
|
+
percent: data['percent'] || nil,
|
|
71
|
+
amount: data['amount'],
|
|
72
|
+
currency: data['currency'] ? GOBL::Currency::Code.from_gobl!(data['currency']) : nil
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns a hash of GOBL data representing the current object
|
|
77
|
+
#
|
|
78
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
|
79
|
+
def to_gobl
|
|
80
|
+
{
|
|
81
|
+
'uuid' => attributes[:uuid]&.to_gobl,
|
|
82
|
+
'date' => attributes[:date]&.to_gobl,
|
|
83
|
+
'ref' => attributes[:ref],
|
|
84
|
+
'grant' => attributes[:grant],
|
|
85
|
+
'desc' => attributes[:desc],
|
|
86
|
+
'percent' => attributes[:percent]&.to_gobl,
|
|
87
|
+
'amount' => attributes[:amount]&.to_gobl,
|
|
88
|
+
'currency' => attributes[:currency]&.to_gobl
|
|
89
|
+
}.compact
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# @!method self.new(attrs)
|
|
93
|
+
#
|
|
94
|
+
# Returns a {Advance} object from a given hash of attributes. Nested
|
|
95
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
|
96
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
|
97
|
+
# parameter.
|
|
98
|
+
#
|
|
99
|
+
# The `new` method will only allow to create a new object if all attributes
|
|
100
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
|
101
|
+
#
|
|
102
|
+
# @param attrs [Hash] the hash of attributes
|
|
103
|
+
#
|
|
104
|
+
# @return [Advance] the object corresponding to the given input
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
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 Pay
|
|
11
|
+
# Card contains simplified card holder data as a reference for the customer.
|
|
12
|
+
class Card < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL Card structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/pay/instructions#/$defs/Card'
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] last4
|
|
17
|
+
# Last 4 digits of the card's Primary Account Number (PAN).
|
|
18
|
+
# @return [String]
|
|
19
|
+
attribute :last4, GOBL::Types::String
|
|
20
|
+
|
|
21
|
+
# @!attribute [r] holder
|
|
22
|
+
# Name of the person whom the card belongs to.
|
|
23
|
+
# @return [String]
|
|
24
|
+
attribute :holder, GOBL::Types::String
|
|
25
|
+
|
|
26
|
+
# Creates a new object from a hash of GOBL data
|
|
27
|
+
#
|
|
28
|
+
# @param data [Hash] a hash of GOBL data
|
|
29
|
+
#
|
|
30
|
+
# @return [Card] the object created from the given data
|
|
31
|
+
def self.from_gobl!(data)
|
|
32
|
+
data = GOBL::Types::Hash[data]
|
|
33
|
+
|
|
34
|
+
new(
|
|
35
|
+
last4: data['last4'],
|
|
36
|
+
holder: data['holder']
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Returns a hash of GOBL data representing the current object
|
|
41
|
+
#
|
|
42
|
+
# @return [Hash] the array of GOBL data that represents the current object
|
|
43
|
+
def to_gobl
|
|
44
|
+
{
|
|
45
|
+
'last4' => attributes[:last4],
|
|
46
|
+
'holder' => attributes[:holder]
|
|
47
|
+
}.compact
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @!method self.new(attrs)
|
|
51
|
+
#
|
|
52
|
+
# Returns a {Card} object from a given hash of attributes. Nested
|
|
53
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
|
54
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
|
55
|
+
# parameter.
|
|
56
|
+
#
|
|
57
|
+
# The `new` method will only allow to create a new object if all attributes
|
|
58
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
|
59
|
+
#
|
|
60
|
+
# @param attrs [Hash] the hash of attributes
|
|
61
|
+
#
|
|
62
|
+
# @return [Card] the object corresponding to the given input
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
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 Pay
|
|
11
|
+
# CreditTransfer contains fields that can be used for making payments via a bank transfer or wire.
|
|
12
|
+
class CreditTransfer < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL CreditTransfer structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/pay/instructions#/$defs/CreditTransfer'
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] iban
|
|
17
|
+
# International Bank Account Number
|
|
18
|
+
# @return [String]
|
|
19
|
+
attribute? :iban, GOBL::Types::String.optional
|
|
20
|
+
|
|
21
|
+
# @!attribute [r] bic
|
|
22
|
+
# Bank Identifier Code used for international transfers.
|
|
23
|
+
# @return [String]
|
|
24
|
+
attribute? :bic, GOBL::Types::String.optional
|
|
25
|
+
|
|
26
|
+
# @!attribute [r] number
|
|
27
|
+
# Account number, if IBAN not available.
|
|
28
|
+
# @return [String]
|
|
29
|
+
attribute? :number, GOBL::Types::String.optional
|
|
30
|
+
|
|
31
|
+
# @!attribute [r] name
|
|
32
|
+
# Name of the bank.
|
|
33
|
+
# @return [String]
|
|
34
|
+
attribute? :name, GOBL::Types::String.optional
|
|
35
|
+
|
|
36
|
+
# @!attribute [r] branch
|
|
37
|
+
# Bank office branch address, not normally required.
|
|
38
|
+
# @return [GOBL::Org::Address]
|
|
39
|
+
attribute? :branch, GOBL::Org::Address.optional
|
|
40
|
+
|
|
41
|
+
# Creates a new object from a hash of GOBL data
|
|
42
|
+
#
|
|
43
|
+
# @param data [Hash] a hash of GOBL data
|
|
44
|
+
#
|
|
45
|
+
# @return [CreditTransfer] the object created from the given data
|
|
46
|
+
def self.from_gobl!(data)
|
|
47
|
+
data = GOBL::Types::Hash[data]
|
|
48
|
+
|
|
49
|
+
new(
|
|
50
|
+
iban: data['iban'],
|
|
51
|
+
bic: data['bic'],
|
|
52
|
+
number: data['number'],
|
|
53
|
+
name: data['name'],
|
|
54
|
+
branch: data['branch'] ? GOBL::Org::Address.from_gobl!(data['branch']) : 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
|
+
'iban' => attributes[:iban],
|
|
64
|
+
'bic' => attributes[:bic],
|
|
65
|
+
'number' => attributes[:number],
|
|
66
|
+
'name' => attributes[:name],
|
|
67
|
+
'branch' => attributes[:branch]&.to_gobl
|
|
68
|
+
}.compact
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @!method self.new(attrs)
|
|
72
|
+
#
|
|
73
|
+
# Returns a {CreditTransfer} object from a given hash of attributes. Nested
|
|
74
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
|
75
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
|
76
|
+
# parameter.
|
|
77
|
+
#
|
|
78
|
+
# The `new` method will only allow to create a new object if all attributes
|
|
79
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
|
80
|
+
#
|
|
81
|
+
# @param attrs [Hash] the hash of attributes
|
|
82
|
+
#
|
|
83
|
+
# @return [CreditTransfer] the object corresponding to the given input
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
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 Pay
|
|
11
|
+
# DirectDebit defines the data that will be used to make the direct debit.
|
|
12
|
+
class DirectDebit < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL DirectDebit structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/pay/instructions#/$defs/DirectDebit'
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] ref
|
|
17
|
+
# Unique identifier assigned by the payee for referencing the direct debit.
|
|
18
|
+
# @return [String]
|
|
19
|
+
attribute? :ref, GOBL::Types::String.optional
|
|
20
|
+
|
|
21
|
+
# @!attribute [r] creditor
|
|
22
|
+
# Unique banking reference that identifies the payee or seller assigned by the bank.
|
|
23
|
+
# @return [String]
|
|
24
|
+
attribute? :creditor, GOBL::Types::String.optional
|
|
25
|
+
|
|
26
|
+
# @!attribute [r] account
|
|
27
|
+
# Account identifier to be debited by the direct debit.
|
|
28
|
+
# @return [String]
|
|
29
|
+
attribute? :account, GOBL::Types::String.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 [DirectDebit] the object created from the given data
|
|
36
|
+
def self.from_gobl!(data)
|
|
37
|
+
data = GOBL::Types::Hash[data]
|
|
38
|
+
|
|
39
|
+
new(
|
|
40
|
+
ref: data['ref'],
|
|
41
|
+
creditor: data['creditor'],
|
|
42
|
+
account: data['account']
|
|
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
|
+
'ref' => attributes[:ref],
|
|
52
|
+
'creditor' => attributes[:creditor],
|
|
53
|
+
'account' => attributes[:account]
|
|
54
|
+
}.compact
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# @!method self.new(attrs)
|
|
58
|
+
#
|
|
59
|
+
# Returns a {DirectDebit} 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 [DirectDebit] the object corresponding to the given input
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
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 Pay
|
|
11
|
+
# DueDate contains an amount that should be paid by the given date.
|
|
12
|
+
class DueDate < GOBL::Struct
|
|
13
|
+
# The Schema ID of the GOBL DueDate structure
|
|
14
|
+
SCHEMA_ID = 'https://gobl.org/draft-0/pay/terms#/$defs/DueDate'
|
|
15
|
+
|
|
16
|
+
# @!attribute [r] date
|
|
17
|
+
# When the payment is due.
|
|
18
|
+
# @return [GOBL::Cal::Date]
|
|
19
|
+
attribute :date, GOBL::Cal::Date
|
|
20
|
+
|
|
21
|
+
# @!attribute [r] notes
|
|
22
|
+
# Other details to take into account for the due date.
|
|
23
|
+
# @return [String]
|
|
24
|
+
attribute? :notes, GOBL::Types::String.optional
|
|
25
|
+
|
|
26
|
+
# @!attribute [r] amount
|
|
27
|
+
# How much needs to be paid by the date.
|
|
28
|
+
# @return [GOBL::Num::Amount]
|
|
29
|
+
attribute :amount, GOBL::Types.Constructor(GOBL::Num::Amount)
|
|
30
|
+
|
|
31
|
+
# @!attribute [r] percent
|
|
32
|
+
# Percentage of the total that should be paid by the date.
|
|
33
|
+
# @return [GOBL::Num::Percentage]
|
|
34
|
+
attribute? :percent, GOBL::Types.Constructor(GOBL::Num::Percentage).optional
|
|
35
|
+
|
|
36
|
+
# @!attribute [r] currency
|
|
37
|
+
# If different from the parent document's base currency.
|
|
38
|
+
# @return [GOBL::Currency::Code]
|
|
39
|
+
attribute? :currency, GOBL::Currency::Code.optional
|
|
40
|
+
|
|
41
|
+
# Creates a new object from a hash of GOBL data
|
|
42
|
+
#
|
|
43
|
+
# @param data [Hash] a hash of GOBL data
|
|
44
|
+
#
|
|
45
|
+
# @return [DueDate] the object created from the given data
|
|
46
|
+
def self.from_gobl!(data)
|
|
47
|
+
data = GOBL::Types::Hash[data]
|
|
48
|
+
|
|
49
|
+
new(
|
|
50
|
+
date: GOBL::Cal::Date.from_gobl!(data['date']),
|
|
51
|
+
notes: data['notes'],
|
|
52
|
+
amount: data['amount'],
|
|
53
|
+
percent: data['percent'] || nil,
|
|
54
|
+
currency: data['currency'] ? GOBL::Currency::Code.from_gobl!(data['currency']) : 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
|
+
'date' => attributes[:date]&.to_gobl,
|
|
64
|
+
'notes' => attributes[:notes],
|
|
65
|
+
'amount' => attributes[:amount]&.to_gobl,
|
|
66
|
+
'percent' => attributes[:percent]&.to_gobl,
|
|
67
|
+
'currency' => attributes[:currency]&.to_gobl
|
|
68
|
+
}.compact
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# @!method self.new(attrs)
|
|
72
|
+
#
|
|
73
|
+
# Returns a {DueDate} object from a given hash of attributes. Nested
|
|
74
|
+
# attributes are supported: the constructor will instantiate the proper GOBL
|
|
75
|
+
# objects when nested hashes or arrays are given as part of the `attrs`
|
|
76
|
+
# parameter.
|
|
77
|
+
#
|
|
78
|
+
# The `new` method will only allow to create a new object if all attributes
|
|
79
|
+
# marked as mandatory and not calculated in the JSON schema are provided.
|
|
80
|
+
#
|
|
81
|
+
# @param attrs [Hash] the hash of attributes
|
|
82
|
+
#
|
|
83
|
+
# @return [DueDate] the object corresponding to the given input
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|