gobl 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/tax/CO.json +420 -0
- data/data/tax/ES.json +61 -0
- data/lib/ext/hashme.rb +28 -0
- data/lib/gobl/bill/advances.rb +1 -77
- data/lib/gobl/bill/charge.rb +11 -65
- data/lib/gobl/bill/delivery.rb +5 -47
- data/lib/gobl/bill/discount.rb +11 -65
- data/lib/gobl/bill/exchange_rates.rb +1 -77
- data/lib/gobl/bill/invoice.rb +28 -104
- data/lib/gobl/bill/invoice_type.rb +3 -134
- data/lib/gobl/bill/line.rb +13 -65
- data/lib/gobl/bill/line_charge.rb +5 -47
- data/lib/gobl/bill/line_discount.rb +5 -47
- data/lib/gobl/bill/ordering.rb +2 -38
- data/lib/gobl/bill/outlay.rb +11 -59
- data/lib/gobl/bill/payment.rb +5 -47
- data/lib/gobl/bill/preceding.rb +12 -62
- data/lib/gobl/bill/scheme_keys.rb +1 -77
- data/lib/gobl/bill/tax.rb +4 -44
- data/lib/gobl/bill/totals.rb +17 -71
- data/lib/gobl/cal/date.rb +1 -90
- data/lib/gobl/cal/period.rb +5 -41
- data/lib/gobl/currency/code.rb +3 -134
- data/lib/gobl/currency/exchange_rate.rb +5 -41
- data/lib/gobl/document.rb +1 -58
- data/lib/gobl/dsig/digest.rb +5 -41
- data/lib/gobl/dsig/signature.rb +1 -90
- data/lib/gobl/enum.rb +81 -0
- data/lib/gobl/envelope.rb +9 -48
- data/lib/gobl/header.rb +10 -56
- data/lib/gobl/i18n/string.rb +1 -58
- data/lib/gobl/l10n/code.rb +1 -90
- data/lib/gobl/l10n/country_code.rb +3 -134
- data/lib/gobl/map.rb +62 -0
- data/lib/gobl/note/message.rb +5 -44
- data/lib/gobl/num/amount.rb +6 -35
- data/lib/gobl/object.rb +21 -0
- data/lib/gobl/operations.rb +3 -3
- data/lib/gobl/org/address.rb +18 -80
- data/lib/gobl/org/code.rb +1 -90
- data/lib/gobl/org/coordinates.rb +5 -47
- data/lib/gobl/org/email.rb +6 -47
- data/lib/gobl/org/inbox.rb +8 -50
- data/lib/gobl/org/item.rb +13 -65
- data/lib/gobl/org/item_code.rb +4 -41
- data/lib/gobl/org/key.rb +1 -90
- data/lib/gobl/org/meta.rb +1 -58
- data/lib/gobl/org/name.rb +12 -62
- data/lib/gobl/org/note.rb +6 -47
- data/lib/gobl/org/note_key.rb +3 -134
- data/lib/gobl/org/party.rb +14 -71
- data/lib/gobl/org/person.rb +9 -56
- data/lib/gobl/org/registration.rb +9 -59
- data/lib/gobl/org/source_key.rb +3 -134
- data/lib/gobl/org/tax_identity.rb +8 -53
- data/lib/gobl/org/telephone.rb +5 -44
- data/lib/gobl/org/unit.rb +1 -136
- data/lib/gobl/pay/advance.rb +11 -59
- data/lib/gobl/pay/card.rb +5 -41
- data/lib/gobl/pay/credit_transfer.rb +6 -50
- data/lib/gobl/pay/direct_debit.rb +4 -44
- data/lib/gobl/pay/due_date.rb +8 -50
- data/lib/gobl/pay/instructions.rb +11 -62
- data/lib/gobl/pay/method_key.rb +3 -134
- data/lib/gobl/pay/online.rb +4 -41
- data/lib/gobl/pay/term_key.rb +3 -134
- data/lib/gobl/pay/terms.rb +6 -47
- data/lib/gobl/stamp.rb +5 -41
- data/lib/gobl/struct.rb +15 -15
- data/lib/gobl/tax/category.rb +9 -50
- data/lib/gobl/tax/category_total.rb +11 -53
- data/lib/gobl/tax/combo.rb +6 -47
- data/lib/gobl/tax/localities.rb +1 -77
- data/lib/gobl/tax/locality.rb +6 -44
- data/lib/gobl/tax/rate.rb +8 -47
- data/lib/gobl/tax/rate_total.rb +9 -50
- data/lib/gobl/tax/rate_total_surcharge.rb +5 -41
- data/lib/gobl/tax/rate_value.rb +6 -47
- data/lib/gobl/tax/region.rb +12 -56
- data/lib/gobl/tax/scheme.rb +8 -50
- data/lib/gobl/tax/schemes.rb +1 -77
- data/lib/gobl/tax/set.rb +1 -77
- data/lib/gobl/tax/total.rb +4 -41
- data/lib/gobl/uuid/uuid.rb +1 -90
- data/lib/gobl/value.rb +58 -0
- data/lib/gobl/version.rb +1 -1
- data/lib/gobl.rb +3 -1
- data/lib/gobl_extensions/document_helper.rb +3 -3
- data/lib/gobl_extensions/envelope_helper.rb +5 -0
- data/lib/gobl_extensions/i18n/value_keys_helper.rb +3 -3
- data/lib/gobl_extensions/tax/region_helper.rb +3 -9
- metadata +12 -35
- data/lib/gobl/types.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a390a31d1775261bd8d96d822e8ed3930d72182b415fbaab018f9770f5b4dd58
|
4
|
+
data.tar.gz: dd5941c6852c584338073791df5795c3850df86767a0d5389c308101592a8bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566063350518154791aed662b0282764e774111e6b9b2c38602a0ada0c85171d22a2e9d98a7d35248991e085fe878c03e510032143dcc3f515ad33244500aab1
|
7
|
+
data.tar.gz: 2d70dd28fe21aad06e20e84345deeee4267cbbb6e94944ea844b2ab1259e9a2e015a97e83b5ea091c9d3e7350d028216b38b54c3ea6a586274d3ffa2fa90b4e3
|
data/data/tax/CO.json
ADDED
@@ -0,0 +1,420 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://gobl.org/draft-0/tax/region",
|
3
|
+
"name": {
|
4
|
+
"en": "Colombia",
|
5
|
+
"es": "Colombia"
|
6
|
+
},
|
7
|
+
"country": "CO",
|
8
|
+
"localities": [
|
9
|
+
{
|
10
|
+
"code": "AMA",
|
11
|
+
"name": {
|
12
|
+
"es": "Amazonas"
|
13
|
+
},
|
14
|
+
"meta": {
|
15
|
+
"post": "91"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"code": "ANT",
|
20
|
+
"name": {
|
21
|
+
"es": "Antioquia"
|
22
|
+
},
|
23
|
+
"meta": {
|
24
|
+
"post": "05"
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"code": "ARA",
|
29
|
+
"name": {
|
30
|
+
"es": "Arauca"
|
31
|
+
},
|
32
|
+
"meta": {
|
33
|
+
"post": "81"
|
34
|
+
}
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"code": "ATL",
|
38
|
+
"name": {
|
39
|
+
"es": "Atlántico"
|
40
|
+
},
|
41
|
+
"meta": {
|
42
|
+
"post": "08"
|
43
|
+
}
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"code": "DC",
|
47
|
+
"name": {
|
48
|
+
"es": "Bogotá"
|
49
|
+
},
|
50
|
+
"meta": {
|
51
|
+
"post": "11"
|
52
|
+
}
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"code": "BOL",
|
56
|
+
"name": {
|
57
|
+
"es": "Bolívar"
|
58
|
+
},
|
59
|
+
"meta": {
|
60
|
+
"post": "13"
|
61
|
+
}
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"code": "BOY",
|
65
|
+
"name": {
|
66
|
+
"es": "Boyacá"
|
67
|
+
},
|
68
|
+
"meta": {
|
69
|
+
"post": "15"
|
70
|
+
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"code": "CAL",
|
74
|
+
"name": {
|
75
|
+
"es": "Caldas"
|
76
|
+
},
|
77
|
+
"meta": {
|
78
|
+
"post": "17"
|
79
|
+
}
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"code": "CAQ",
|
83
|
+
"name": {
|
84
|
+
"es": "Caquetá"
|
85
|
+
},
|
86
|
+
"meta": {
|
87
|
+
"post": "18"
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"code": "CAS",
|
92
|
+
"name": {
|
93
|
+
"es": "Casanare"
|
94
|
+
},
|
95
|
+
"meta": {
|
96
|
+
"post": "85"
|
97
|
+
}
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"code": "CAU",
|
101
|
+
"name": {
|
102
|
+
"es": "Cauca"
|
103
|
+
},
|
104
|
+
"meta": {
|
105
|
+
"post": "19"
|
106
|
+
}
|
107
|
+
},
|
108
|
+
{
|
109
|
+
"code": "CES",
|
110
|
+
"name": {
|
111
|
+
"es": "Cesar"
|
112
|
+
},
|
113
|
+
"meta": {
|
114
|
+
"post": "20"
|
115
|
+
}
|
116
|
+
},
|
117
|
+
{
|
118
|
+
"code": "CHO",
|
119
|
+
"name": {
|
120
|
+
"es": "Chocó"
|
121
|
+
},
|
122
|
+
"meta": {
|
123
|
+
"post": "27"
|
124
|
+
}
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"code": "COR",
|
128
|
+
"name": {
|
129
|
+
"es": "Córdoba"
|
130
|
+
},
|
131
|
+
"meta": {
|
132
|
+
"post": "23"
|
133
|
+
}
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"code": "CUN",
|
137
|
+
"name": {
|
138
|
+
"es": "Cundinamarca"
|
139
|
+
},
|
140
|
+
"meta": {
|
141
|
+
"post": "25"
|
142
|
+
}
|
143
|
+
},
|
144
|
+
{
|
145
|
+
"code": "GUA",
|
146
|
+
"name": {
|
147
|
+
"es": "Guainía"
|
148
|
+
},
|
149
|
+
"meta": {
|
150
|
+
"post": "94"
|
151
|
+
}
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"code": "GUV",
|
155
|
+
"name": {
|
156
|
+
"es": "Guaviare"
|
157
|
+
},
|
158
|
+
"meta": {
|
159
|
+
"post": "95"
|
160
|
+
}
|
161
|
+
},
|
162
|
+
{
|
163
|
+
"code": "HUI",
|
164
|
+
"name": {
|
165
|
+
"es": "Huila"
|
166
|
+
},
|
167
|
+
"meta": {
|
168
|
+
"post": "41"
|
169
|
+
}
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"code": "LAG",
|
173
|
+
"name": {
|
174
|
+
"es": "La Guajira"
|
175
|
+
},
|
176
|
+
"meta": {
|
177
|
+
"post": "44"
|
178
|
+
}
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"code": "MAG",
|
182
|
+
"name": {
|
183
|
+
"es": "Magdalena"
|
184
|
+
},
|
185
|
+
"meta": {
|
186
|
+
"post": "47"
|
187
|
+
}
|
188
|
+
},
|
189
|
+
{
|
190
|
+
"code": "MET",
|
191
|
+
"name": {
|
192
|
+
"es": "Meta"
|
193
|
+
},
|
194
|
+
"meta": {
|
195
|
+
"post": "50"
|
196
|
+
}
|
197
|
+
},
|
198
|
+
{
|
199
|
+
"code": "NAR",
|
200
|
+
"name": {
|
201
|
+
"es": "Nariño"
|
202
|
+
},
|
203
|
+
"meta": {
|
204
|
+
"post": "52"
|
205
|
+
}
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"code": "NSA",
|
209
|
+
"name": {
|
210
|
+
"es": "Norte de Santander"
|
211
|
+
},
|
212
|
+
"meta": {
|
213
|
+
"post": "54"
|
214
|
+
}
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"code": "PUT",
|
218
|
+
"name": {
|
219
|
+
"es": "Putumayo"
|
220
|
+
},
|
221
|
+
"meta": {
|
222
|
+
"post": "86"
|
223
|
+
}
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"code": "QUI",
|
227
|
+
"name": {
|
228
|
+
"es": "Quindío"
|
229
|
+
},
|
230
|
+
"meta": {
|
231
|
+
"post": "63"
|
232
|
+
}
|
233
|
+
},
|
234
|
+
{
|
235
|
+
"code": "RIS",
|
236
|
+
"name": {
|
237
|
+
"es": "Risaralda"
|
238
|
+
},
|
239
|
+
"meta": {
|
240
|
+
"post": "66"
|
241
|
+
}
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"code": "SAP",
|
245
|
+
"name": {
|
246
|
+
"es": "San Andrés y Providencia"
|
247
|
+
},
|
248
|
+
"meta": {
|
249
|
+
"post": "88"
|
250
|
+
}
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"code": "SAN",
|
254
|
+
"name": {
|
255
|
+
"es": "Santander"
|
256
|
+
},
|
257
|
+
"meta": {
|
258
|
+
"post": "68"
|
259
|
+
}
|
260
|
+
},
|
261
|
+
{
|
262
|
+
"code": "SUC",
|
263
|
+
"name": {
|
264
|
+
"es": "Sucre"
|
265
|
+
},
|
266
|
+
"meta": {
|
267
|
+
"post": "70"
|
268
|
+
}
|
269
|
+
},
|
270
|
+
{
|
271
|
+
"code": "TOL",
|
272
|
+
"name": {
|
273
|
+
"es": "Tolima"
|
274
|
+
},
|
275
|
+
"meta": {
|
276
|
+
"post": "73"
|
277
|
+
}
|
278
|
+
},
|
279
|
+
{
|
280
|
+
"code": "VAC",
|
281
|
+
"name": {
|
282
|
+
"es": "Valle de Cauca"
|
283
|
+
},
|
284
|
+
"meta": {
|
285
|
+
"post": "76"
|
286
|
+
}
|
287
|
+
},
|
288
|
+
{
|
289
|
+
"code": "VAU",
|
290
|
+
"name": {
|
291
|
+
"es": "Vaupés"
|
292
|
+
},
|
293
|
+
"meta": {
|
294
|
+
"post": "97"
|
295
|
+
}
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"code": "VID",
|
299
|
+
"name": {
|
300
|
+
"es": "Vichada"
|
301
|
+
},
|
302
|
+
"meta": {
|
303
|
+
"post": "99"
|
304
|
+
}
|
305
|
+
}
|
306
|
+
],
|
307
|
+
"currency": "COP",
|
308
|
+
"categories": [
|
309
|
+
{
|
310
|
+
"code": "VAT",
|
311
|
+
"name": {
|
312
|
+
"en": "VAT",
|
313
|
+
"es": "IVA"
|
314
|
+
},
|
315
|
+
"desc": {
|
316
|
+
"en": "Value Added Tax",
|
317
|
+
"es": "Impuesto al Valor Agregado"
|
318
|
+
},
|
319
|
+
"rates": [
|
320
|
+
{
|
321
|
+
"key": "zero",
|
322
|
+
"name": {
|
323
|
+
"en": "Zero Rate",
|
324
|
+
"es": "Zero"
|
325
|
+
},
|
326
|
+
"values": [
|
327
|
+
{
|
328
|
+
"percent": "0.0%"
|
329
|
+
}
|
330
|
+
]
|
331
|
+
},
|
332
|
+
{
|
333
|
+
"key": "standard",
|
334
|
+
"name": {
|
335
|
+
"en": "Standard Rate",
|
336
|
+
"es": "Estándar"
|
337
|
+
},
|
338
|
+
"values": [
|
339
|
+
{
|
340
|
+
"since": "2017-01-01",
|
341
|
+
"percent": "19.0%"
|
342
|
+
},
|
343
|
+
{
|
344
|
+
"since": "2006-01-01",
|
345
|
+
"percent": "16.0%"
|
346
|
+
}
|
347
|
+
]
|
348
|
+
},
|
349
|
+
{
|
350
|
+
"key": "reduced",
|
351
|
+
"name": {
|
352
|
+
"en": "Reduced Rate",
|
353
|
+
"es": "Reducido"
|
354
|
+
},
|
355
|
+
"values": [
|
356
|
+
{
|
357
|
+
"since": "2006-01-01",
|
358
|
+
"percent": "5.0%"
|
359
|
+
}
|
360
|
+
]
|
361
|
+
}
|
362
|
+
]
|
363
|
+
},
|
364
|
+
{
|
365
|
+
"code": "IC",
|
366
|
+
"name": {
|
367
|
+
"es": "IC"
|
368
|
+
},
|
369
|
+
"desc": {
|
370
|
+
"en": "Consumption Tax",
|
371
|
+
"es": "Impuesto sobre Consumo"
|
372
|
+
},
|
373
|
+
"rates": []
|
374
|
+
},
|
375
|
+
{
|
376
|
+
"code": "ICA",
|
377
|
+
"name": {
|
378
|
+
"es": "ICA"
|
379
|
+
},
|
380
|
+
"desc": {
|
381
|
+
"en": "Industry and Commerce Tax",
|
382
|
+
"es": "Impuesto de Industria y Comercio"
|
383
|
+
},
|
384
|
+
"rates": []
|
385
|
+
},
|
386
|
+
{
|
387
|
+
"code": "RVAT",
|
388
|
+
"name": {
|
389
|
+
"es": "ReteIVA"
|
390
|
+
},
|
391
|
+
"desc": {
|
392
|
+
"es": "Retención en la fuente por el Impuesto al Valor Agregado"
|
393
|
+
},
|
394
|
+
"retained": true,
|
395
|
+
"rates": []
|
396
|
+
},
|
397
|
+
{
|
398
|
+
"code": "RICA",
|
399
|
+
"name": {
|
400
|
+
"es": "ReteICA"
|
401
|
+
},
|
402
|
+
"desc": {
|
403
|
+
"es": "Retención en la fuente por el Impuesto de Industria y Comercio"
|
404
|
+
},
|
405
|
+
"retained": true,
|
406
|
+
"rates": []
|
407
|
+
},
|
408
|
+
{
|
409
|
+
"code": "RR",
|
410
|
+
"name": {
|
411
|
+
"es": "ReteRenta"
|
412
|
+
},
|
413
|
+
"desc": {
|
414
|
+
"es": "Retención en la fuente por el Impuesto de la Renta"
|
415
|
+
},
|
416
|
+
"retained": true,
|
417
|
+
"rates": []
|
418
|
+
}
|
419
|
+
]
|
420
|
+
}
|
data/data/tax/ES.json
CHANGED
@@ -759,6 +759,67 @@
|
|
759
759
|
}
|
760
760
|
]
|
761
761
|
},
|
762
|
+
{
|
763
|
+
"code": "IGIC",
|
764
|
+
"name": {
|
765
|
+
"en": "IGIC",
|
766
|
+
"es": "IGIC"
|
767
|
+
},
|
768
|
+
"desc": {
|
769
|
+
"en": "Canary Island General Indirect Tax",
|
770
|
+
"es": "Impuesto General Indirecto Canario"
|
771
|
+
},
|
772
|
+
"rates": [
|
773
|
+
{
|
774
|
+
"key": "zero",
|
775
|
+
"name": {
|
776
|
+
"en": "Zero Rate",
|
777
|
+
"es": "Tipo Zero"
|
778
|
+
},
|
779
|
+
"values": [
|
780
|
+
{
|
781
|
+
"percent": "0.0%"
|
782
|
+
}
|
783
|
+
]
|
784
|
+
},
|
785
|
+
{
|
786
|
+
"key": "standard",
|
787
|
+
"name": {
|
788
|
+
"en": "Standard Rate",
|
789
|
+
"es": "Tipo General"
|
790
|
+
},
|
791
|
+
"values": [
|
792
|
+
{
|
793
|
+
"percent": "7.0%"
|
794
|
+
}
|
795
|
+
]
|
796
|
+
},
|
797
|
+
{
|
798
|
+
"key": "reduced",
|
799
|
+
"name": {
|
800
|
+
"en": "Reduced Rate",
|
801
|
+
"es": "Tipo Reducido"
|
802
|
+
},
|
803
|
+
"values": [
|
804
|
+
{
|
805
|
+
"percent": "3.0%"
|
806
|
+
}
|
807
|
+
]
|
808
|
+
}
|
809
|
+
]
|
810
|
+
},
|
811
|
+
{
|
812
|
+
"code": "IPSI",
|
813
|
+
"name": {
|
814
|
+
"en": "IPSI",
|
815
|
+
"es": "IPSI"
|
816
|
+
},
|
817
|
+
"desc": {
|
818
|
+
"en": "Production, Services, and Import Tax",
|
819
|
+
"es": "Impuesto sobre la Producción, los Servicios y la Importación"
|
820
|
+
},
|
821
|
+
"rates": []
|
822
|
+
},
|
762
823
|
{
|
763
824
|
"code": "IRPF",
|
764
825
|
"name": {
|
data/lib/ext/hashme.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
raise 'The `hashme` library version has changed. Review if this extension still applies' if Hashme::VERSION != '0.2.6'
|
4
|
+
|
5
|
+
# Temporary extensions for the `hashme` gem. To be removed when the library supports them.
|
6
|
+
# @api private
|
7
|
+
module Hashme
|
8
|
+
# Adds an URI helper class to the Hashme namespace so that properties referencing them
|
9
|
+
# typecast to URI objects in Ruby standard library.
|
10
|
+
class URI
|
11
|
+
def self.new(value)
|
12
|
+
URI(value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# TrueClass typecasts to a boolean in Hashme. We alias it to `Boolean` for clarity
|
17
|
+
Boolean = TrueClass
|
18
|
+
|
19
|
+
class CastedArray
|
20
|
+
# Provides access to the whole Enumerable set of methods
|
21
|
+
include Enumerable
|
22
|
+
|
23
|
+
# Fixes equality between CastedArray objects
|
24
|
+
def ==(other)
|
25
|
+
@_array == other.to_a
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/gobl/bill/advances.rb
CHANGED
@@ -9,82 +9,6 @@
|
|
9
9
|
module GOBL
|
10
10
|
module Bill
|
11
11
|
# Advances contains an array of advance objects.
|
12
|
-
|
13
|
-
extend Forwardable
|
14
|
-
include Enumerable
|
15
|
-
|
16
|
-
# The Schema ID of the GOBL Advances structure
|
17
|
-
SCHEMA_ID = 'https://gobl.org/draft-0/bill/invoice#/$defs/Advances'
|
18
|
-
|
19
|
-
attribute :_ary, GOBL::Types::Array.of(GOBL::Pay::Advance)
|
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 [GOBL::Pay::Advance] 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<GOBL::Pay::Advance>] 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<GOBL::Pay::Advance>] 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 [Advances] the object created from the given data
|
61
|
-
def self.from_gobl!(data)
|
62
|
-
new(_ary: data&.map { |item| GOBL::Pay::Advance.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 {Advances} object from a given array of structs. The array may
|
73
|
-
# contain {GOBL::Pay::Advance} objects or hashes. If hashes are provided, the constructor
|
74
|
-
# will call `GOBL::Pay::Advance#new` to generate the objects that will be part of the
|
75
|
-
# returned {Advances} object
|
76
|
-
#
|
77
|
-
# @param object [Array<GOBL::Pay::Advance, Hash>] the array containing the structs
|
78
|
-
#
|
79
|
-
# @return [Advances] 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
|
12
|
+
Advances = [GOBL::Pay::Advance] # rubocop:disable Naming/ConstantName, Style/MutableConstant
|
89
13
|
end
|
90
14
|
end
|