write_invoice 0.1.81
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/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +21 -0
- data/README.md +114 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/write_invoice/document/index.rb +289 -0
- data/lib/write_invoice/document/options.rb +913 -0
- data/lib/write_invoice/document/sections.rb +513 -0
- data/lib/write_invoice/example/index.rb +200 -0
- data/lib/write_invoice/version.rb +5 -0
- data/lib/write_invoice.rb +67 -0
- data/write_invoice-0.1.8.gem +0 -0
- metadata +148 -0
@@ -0,0 +1,913 @@
|
|
1
|
+
|
2
|
+
module Options
|
3
|
+
|
4
|
+
|
5
|
+
def get_options()
|
6
|
+
return {
|
7
|
+
show: {
|
8
|
+
qr_code: true,
|
9
|
+
sub_total: true,
|
10
|
+
shipping: true,
|
11
|
+
total_net: true,
|
12
|
+
vat: true,
|
13
|
+
total_gross: true,
|
14
|
+
logo: false,
|
15
|
+
watermark: true,
|
16
|
+
unencrypted: true
|
17
|
+
},
|
18
|
+
order: [
|
19
|
+
{ name: :header, move_down: [ 0 ] },
|
20
|
+
{ name: :two, move_down: [ :style__sections__pad ] },
|
21
|
+
{ name: :three, move_down: [ :style__sections__pad ] },
|
22
|
+
{ name: :four, move_down: [ :style__sections__pad, :style__sections__pad ] },
|
23
|
+
{ name: :five, move_down: [ :style__sections__pad, :style__sections__pad ] },
|
24
|
+
{ name: :six, move_down: [ 0 ] },
|
25
|
+
{ name: :seven, move_down: [ :style__sections__pad, :style__sections__pad ] },
|
26
|
+
{ name: :eight, move_down: [ :style__sections__pad ] }
|
27
|
+
],
|
28
|
+
text: {
|
29
|
+
phone: 'Phone:',
|
30
|
+
mobile: 'Mobil:',
|
31
|
+
email: 'Email:',
|
32
|
+
website: 'Website:',
|
33
|
+
tax_id: 'Tax ID:',
|
34
|
+
invoice: 'Invoice',
|
35
|
+
page_count: '<page> / <total>',
|
36
|
+
articles: {
|
37
|
+
nr: '<b>NR</b>',
|
38
|
+
id: '<b>ID</b>',
|
39
|
+
article: '<b>ARTICLE</b>',
|
40
|
+
piece: '<b>PIECE</b>',
|
41
|
+
single: '<b>SINGLE</b>',
|
42
|
+
total: '<b>TOTAL</b>'
|
43
|
+
},
|
44
|
+
total: {
|
45
|
+
sub_total: 'Subtotal:',
|
46
|
+
shipping: '+ Shipping',
|
47
|
+
total_net: '<b>Total (net):</b>',
|
48
|
+
vat: '+ VAT 19 %',
|
49
|
+
total_gross: '<b>Total (gross):</b>'
|
50
|
+
},
|
51
|
+
footer: {
|
52
|
+
left: 'Postal',
|
53
|
+
center: 'Bank',
|
54
|
+
right: 'Contact'
|
55
|
+
},
|
56
|
+
watermark: 'Example'
|
57
|
+
},
|
58
|
+
style: {
|
59
|
+
document: {
|
60
|
+
format: 'A4',
|
61
|
+
width: nil
|
62
|
+
},
|
63
|
+
page_count: {
|
64
|
+
align: :right,
|
65
|
+
start_count_at: 1,
|
66
|
+
offset_y: 0
|
67
|
+
},
|
68
|
+
font: {
|
69
|
+
family: {},
|
70
|
+
name: 'Helvetica',
|
71
|
+
default: 10,
|
72
|
+
small: 8
|
73
|
+
},
|
74
|
+
colors: {
|
75
|
+
background: 'FFFFFF',
|
76
|
+
header: {
|
77
|
+
default: '000000',
|
78
|
+
},
|
79
|
+
rows: {
|
80
|
+
even: "F0F0F0",
|
81
|
+
odd: "FFFFFF"
|
82
|
+
}
|
83
|
+
},
|
84
|
+
header: {
|
85
|
+
height: 90,
|
86
|
+
},
|
87
|
+
address_label: {
|
88
|
+
offset_x: 20,
|
89
|
+
move_down_one: 15,
|
90
|
+
move_down_two: 100
|
91
|
+
},
|
92
|
+
footer: {
|
93
|
+
height: 60,
|
94
|
+
border_width: 1,
|
95
|
+
borders: [ :top ]
|
96
|
+
},
|
97
|
+
sections: {
|
98
|
+
pad: 10
|
99
|
+
},
|
100
|
+
articles: {
|
101
|
+
nr: {
|
102
|
+
align: :left,
|
103
|
+
width: 40
|
104
|
+
},
|
105
|
+
id: {
|
106
|
+
align: :left,
|
107
|
+
width: 60
|
108
|
+
},
|
109
|
+
article: {
|
110
|
+
align: :left,
|
111
|
+
width: 220
|
112
|
+
},
|
113
|
+
piece: {
|
114
|
+
align: :right,
|
115
|
+
width: 80
|
116
|
+
},
|
117
|
+
single: {
|
118
|
+
align: :right,
|
119
|
+
width: 60,
|
120
|
+
format: :format_types__currency__short
|
121
|
+
},
|
122
|
+
total: {
|
123
|
+
align: :right,
|
124
|
+
width: 60,
|
125
|
+
format: :format_types__currency__short
|
126
|
+
}
|
127
|
+
},
|
128
|
+
total: {
|
129
|
+
sub_total: {
|
130
|
+
borders: [ :top ],
|
131
|
+
border_width: 1
|
132
|
+
},
|
133
|
+
shipping: {
|
134
|
+
borders: [ :top ],
|
135
|
+
border_width: 0
|
136
|
+
},
|
137
|
+
total_net: {
|
138
|
+
borders: [ :top ],
|
139
|
+
border_width: 1
|
140
|
+
},
|
141
|
+
vat: {
|
142
|
+
borders: [ :top ],
|
143
|
+
border_width: 0
|
144
|
+
},
|
145
|
+
total_gross: {
|
146
|
+
borders: [ :top ],
|
147
|
+
border_width: 0
|
148
|
+
}
|
149
|
+
},
|
150
|
+
qr_code: {
|
151
|
+
width: 40
|
152
|
+
},
|
153
|
+
watermark: {
|
154
|
+
rotate: 45,
|
155
|
+
fill_color: '383838',
|
156
|
+
font_size: 180,
|
157
|
+
font_family: 'Times-Roman',
|
158
|
+
transparency: 0.1,
|
159
|
+
}
|
160
|
+
},
|
161
|
+
format_types: {
|
162
|
+
currency: {
|
163
|
+
short: {
|
164
|
+
delimiter: '.',
|
165
|
+
separator: ',',
|
166
|
+
precision: 2,
|
167
|
+
unit: '',
|
168
|
+
format: '%n €'
|
169
|
+
},
|
170
|
+
long: {
|
171
|
+
delimiter: '.',
|
172
|
+
separator: ',',
|
173
|
+
precision: 2,
|
174
|
+
unit: '',
|
175
|
+
format: '%n EUR'
|
176
|
+
}
|
177
|
+
},
|
178
|
+
date: {
|
179
|
+
eu: {
|
180
|
+
strf: '%d.%m.%Y'
|
181
|
+
},
|
182
|
+
short: {
|
183
|
+
strf: '%B %d'
|
184
|
+
},
|
185
|
+
default: {
|
186
|
+
strf: '%B %d, %Y'
|
187
|
+
},
|
188
|
+
long: {
|
189
|
+
strf: '%A %B %d %Y %I:%M%P UTC'
|
190
|
+
},
|
191
|
+
year: {
|
192
|
+
strf: '%Y'
|
193
|
+
}
|
194
|
+
}
|
195
|
+
},
|
196
|
+
sections: {
|
197
|
+
nine: {
|
198
|
+
left_headline: {
|
199
|
+
content: nil,
|
200
|
+
struct: '<b><<--a-->></b>',
|
201
|
+
assigns: [
|
202
|
+
{
|
203
|
+
value: :obj__text__footer__left,
|
204
|
+
format: nil
|
205
|
+
}
|
206
|
+
]
|
207
|
+
},
|
208
|
+
left_one: {
|
209
|
+
content: nil,
|
210
|
+
struct: '<<--a-->>',
|
211
|
+
assigns: [
|
212
|
+
{
|
213
|
+
value: :payload__from__address__name,
|
214
|
+
format: nil
|
215
|
+
}
|
216
|
+
]
|
217
|
+
},
|
218
|
+
left_two: {
|
219
|
+
content: nil,
|
220
|
+
struct: '<<--a-->>',
|
221
|
+
assigns: [
|
222
|
+
{
|
223
|
+
value: :payload__from__address__street,
|
224
|
+
format: nil
|
225
|
+
}
|
226
|
+
]
|
227
|
+
},
|
228
|
+
left_three: {
|
229
|
+
content: nil,
|
230
|
+
struct: '<<--a-->>',
|
231
|
+
assigns: [
|
232
|
+
{
|
233
|
+
value: :payload__from__address__city,
|
234
|
+
format: nil
|
235
|
+
}
|
236
|
+
]
|
237
|
+
},
|
238
|
+
left_four: {
|
239
|
+
content: nil,
|
240
|
+
struct: '<<--a-->>',
|
241
|
+
assigns: [
|
242
|
+
{
|
243
|
+
value: :payload__from__address__country,
|
244
|
+
format: nil
|
245
|
+
}
|
246
|
+
]
|
247
|
+
},
|
248
|
+
center_headline: {
|
249
|
+
content: nil,
|
250
|
+
struct: '<b><<--a-->></b>',
|
251
|
+
assigns: [
|
252
|
+
{
|
253
|
+
value: :obj__text__footer__center,
|
254
|
+
format: nil
|
255
|
+
}
|
256
|
+
]
|
257
|
+
},
|
258
|
+
center_one: {
|
259
|
+
content: nil,
|
260
|
+
struct: '<<--a-->>',
|
261
|
+
assigns: [
|
262
|
+
{
|
263
|
+
value: :payload__from__bank__name,
|
264
|
+
format: nil
|
265
|
+
}
|
266
|
+
]
|
267
|
+
},
|
268
|
+
center_two: {
|
269
|
+
content: nil,
|
270
|
+
struct: '<<--a-->>',
|
271
|
+
assigns: [
|
272
|
+
{
|
273
|
+
value: :payload__from__bank__iban,
|
274
|
+
format: nil
|
275
|
+
}
|
276
|
+
]
|
277
|
+
},
|
278
|
+
center_three: {
|
279
|
+
content: nil,
|
280
|
+
struct: '<<--a-->>',
|
281
|
+
assigns: [
|
282
|
+
{
|
283
|
+
value: :payload__from__bank__bic,
|
284
|
+
format: nil
|
285
|
+
}
|
286
|
+
]
|
287
|
+
},
|
288
|
+
center_four: {
|
289
|
+
content: nil,
|
290
|
+
struct: '<b><<--a-->> <<--b-->></b>',
|
291
|
+
assigns: [
|
292
|
+
{
|
293
|
+
value: :obj__text__tax_id,
|
294
|
+
format: nil
|
295
|
+
},
|
296
|
+
{
|
297
|
+
value: :payload__from__tax_id,
|
298
|
+
format: nil
|
299
|
+
}
|
300
|
+
]
|
301
|
+
},
|
302
|
+
right_headline: {
|
303
|
+
content: nil,
|
304
|
+
struct: '<b><<--a-->></b>',
|
305
|
+
assigns: [
|
306
|
+
{
|
307
|
+
value: :obj__text__footer__right,
|
308
|
+
format: nil
|
309
|
+
}
|
310
|
+
]
|
311
|
+
},
|
312
|
+
right_one: {
|
313
|
+
content: nil,
|
314
|
+
struct: '<<--a-->> <<--b-->>',
|
315
|
+
assigns: [
|
316
|
+
{
|
317
|
+
value: :obj__text__phone,
|
318
|
+
format: nil
|
319
|
+
},
|
320
|
+
{
|
321
|
+
value: :payload__from__contact__phone,
|
322
|
+
format: nil
|
323
|
+
}
|
324
|
+
]
|
325
|
+
},
|
326
|
+
right_two: {
|
327
|
+
content: nil,
|
328
|
+
struct: '<<--a-->> <<--b-->>',
|
329
|
+
assigns: [
|
330
|
+
{
|
331
|
+
value: :obj__text__mobile,
|
332
|
+
format: nil
|
333
|
+
},
|
334
|
+
{
|
335
|
+
value: :payload__from__contact__mobile,
|
336
|
+
format: nil
|
337
|
+
}
|
338
|
+
]
|
339
|
+
},
|
340
|
+
right_three: {
|
341
|
+
content: nil,
|
342
|
+
struct: '<<--a-->> <<--b-->>',
|
343
|
+
assigns: [
|
344
|
+
{
|
345
|
+
value: :obj__text__email,
|
346
|
+
format: nil
|
347
|
+
},
|
348
|
+
{
|
349
|
+
value: :payload__from__contact__email,
|
350
|
+
format: nil
|
351
|
+
}
|
352
|
+
]
|
353
|
+
},
|
354
|
+
right_four: {
|
355
|
+
content: nil,
|
356
|
+
struct: '<<--a-->> <<--b-->>',
|
357
|
+
assigns: [
|
358
|
+
{
|
359
|
+
value: :obj__text__website,
|
360
|
+
format: nil
|
361
|
+
},
|
362
|
+
{
|
363
|
+
value: :payload__from__contact__website,
|
364
|
+
format: nil
|
365
|
+
}
|
366
|
+
]
|
367
|
+
},
|
368
|
+
},
|
369
|
+
eight: {
|
370
|
+
snippet: {
|
371
|
+
content: nil,
|
372
|
+
struct: "Thank you for using <<--a-->> Services.\n\n\nSincerely,\n\n<<--a-->>",
|
373
|
+
assigns: [
|
374
|
+
{
|
375
|
+
value: :payload__from__address__name,
|
376
|
+
format: nil
|
377
|
+
}
|
378
|
+
]
|
379
|
+
}
|
380
|
+
},
|
381
|
+
seven: {
|
382
|
+
snippet: {
|
383
|
+
content: nil,
|
384
|
+
struct: ' We will debit your bank account for <b><<--a-->></b> on <<--b-->>. Please ensure you have sufficient funds in your bank account to avoid service disruptions.',
|
385
|
+
assigns: [
|
386
|
+
{
|
387
|
+
value: :payload__items__total_gross,
|
388
|
+
format: :obj__format_types__currency__long
|
389
|
+
},
|
390
|
+
{
|
391
|
+
value: :payload__date__billing,
|
392
|
+
format: :obj__format_types__date__long
|
393
|
+
}
|
394
|
+
]
|
395
|
+
}
|
396
|
+
},
|
397
|
+
six: {
|
398
|
+
sub_total: {
|
399
|
+
content: nil,
|
400
|
+
struct: '<<--a-->>',
|
401
|
+
assigns: [
|
402
|
+
{
|
403
|
+
value: :payload__items__sub_total,
|
404
|
+
format: :obj__format_types__currency__short
|
405
|
+
}
|
406
|
+
]
|
407
|
+
},
|
408
|
+
shipping: {
|
409
|
+
content: nil,
|
410
|
+
struct: '<<--a-->>',
|
411
|
+
assigns: [
|
412
|
+
{
|
413
|
+
value: :payload__items__shipping_fee,
|
414
|
+
format: :obj__format_types__currency__short
|
415
|
+
}
|
416
|
+
]
|
417
|
+
},
|
418
|
+
total_net: {
|
419
|
+
content: nil,
|
420
|
+
struct: '<b><<--a-->><b> ',
|
421
|
+
assigns: [
|
422
|
+
{
|
423
|
+
value: :payload__items__total_net,
|
424
|
+
format: :obj__format_types__currency__short
|
425
|
+
}
|
426
|
+
]
|
427
|
+
},
|
428
|
+
vat: {
|
429
|
+
content: nil,
|
430
|
+
struct: '<<--a-->>',
|
431
|
+
assigns: [
|
432
|
+
{
|
433
|
+
value: :payload__items__vat,
|
434
|
+
format: :obj__format_types__currency__short
|
435
|
+
}
|
436
|
+
]
|
437
|
+
},
|
438
|
+
total_gross: {
|
439
|
+
content: nil,
|
440
|
+
struct: '<b><<--a-->></b>',
|
441
|
+
assigns: [
|
442
|
+
{
|
443
|
+
value: :payload__items__total_gross,
|
444
|
+
format: :obj__format_types__currency__short
|
445
|
+
}
|
446
|
+
]
|
447
|
+
}
|
448
|
+
},
|
449
|
+
four: {
|
450
|
+
snippet: {
|
451
|
+
content: nil,
|
452
|
+
struct: "Greetings from <<--a-->>,\n\nThis is a <u>demo invoice</u> for usage of <<--a-->> services for billing period <b><<--b-->> - <<--c-->></b>.",
|
453
|
+
assigns: [
|
454
|
+
{
|
455
|
+
value: :payload__from__address__name,
|
456
|
+
format: nil
|
457
|
+
},
|
458
|
+
{
|
459
|
+
value: :payload__date__period__from,
|
460
|
+
format: :obj__format_types__date__short
|
461
|
+
},
|
462
|
+
{
|
463
|
+
value: :payload__date__period__to,
|
464
|
+
format: :obj__format_types__date__default
|
465
|
+
}
|
466
|
+
]
|
467
|
+
}
|
468
|
+
},
|
469
|
+
three: {
|
470
|
+
qr_code: {
|
471
|
+
content: nil,
|
472
|
+
struct: '<<--a-->>',
|
473
|
+
assigns: [
|
474
|
+
{
|
475
|
+
value: :payload__meta__qr_code,
|
476
|
+
format: nil
|
477
|
+
}
|
478
|
+
]
|
479
|
+
},
|
480
|
+
date: {
|
481
|
+
content: nil,
|
482
|
+
struct: '<<--a-->>',
|
483
|
+
assigns: [
|
484
|
+
{
|
485
|
+
value: :payload__date__invoice,
|
486
|
+
format: :obj__format_types__date__eu
|
487
|
+
}
|
488
|
+
]
|
489
|
+
},
|
490
|
+
headline: {
|
491
|
+
content: nil,
|
492
|
+
struct: '<b><<--a-->> | <<--b-->></b>',
|
493
|
+
assigns: [
|
494
|
+
{
|
495
|
+
value: :obj__text__invoice,
|
496
|
+
format: nil
|
497
|
+
},
|
498
|
+
{
|
499
|
+
value: :payload__meta__id,
|
500
|
+
format: nil
|
501
|
+
}
|
502
|
+
]
|
503
|
+
}
|
504
|
+
},
|
505
|
+
two: {
|
506
|
+
small: {
|
507
|
+
content: nil,
|
508
|
+
struct: '<u><<--a-->> - <<--b-->> - <<--c-->></u>',
|
509
|
+
assigns: [
|
510
|
+
{
|
511
|
+
value: :payload__from__address__name,
|
512
|
+
format: nil
|
513
|
+
},
|
514
|
+
{
|
515
|
+
value: :payload__from__address__street,
|
516
|
+
format: nil
|
517
|
+
},
|
518
|
+
{
|
519
|
+
value: :payload__from__address__city,
|
520
|
+
format: nil
|
521
|
+
}
|
522
|
+
]
|
523
|
+
},
|
524
|
+
to: {
|
525
|
+
content: nil,
|
526
|
+
struct: "\t\t<b><<--a-->></b>\n<<--b-->>\n<<--c-->>\nTax ID: <<--d-->>",
|
527
|
+
assigns: [
|
528
|
+
{
|
529
|
+
value: :payload__to__address__name,
|
530
|
+
format: nil
|
531
|
+
},
|
532
|
+
{
|
533
|
+
value: :payload__to__address__street,
|
534
|
+
format: nil
|
535
|
+
},
|
536
|
+
{
|
537
|
+
value: :payload__to__address__city,
|
538
|
+
format: nil
|
539
|
+
},
|
540
|
+
{
|
541
|
+
value: :payload__to__tax_id,
|
542
|
+
format: nil
|
543
|
+
}
|
544
|
+
]
|
545
|
+
}
|
546
|
+
},
|
547
|
+
one: {
|
548
|
+
name: {
|
549
|
+
content: nil,
|
550
|
+
struct: "<b><<--a-->></b>\n<<--b-->>\n<<--c-->>\n<<--d-->>",
|
551
|
+
assigns: [
|
552
|
+
{
|
553
|
+
value: :payload__from__address__name,
|
554
|
+
format: nil
|
555
|
+
},
|
556
|
+
{
|
557
|
+
value: :payload__from__address__phrase,
|
558
|
+
format: nil
|
559
|
+
},
|
560
|
+
{
|
561
|
+
value: :payload__from__address__city,
|
562
|
+
format: nil
|
563
|
+
},
|
564
|
+
{
|
565
|
+
value: :payload__from__address__country,
|
566
|
+
format: nil
|
567
|
+
}
|
568
|
+
]
|
569
|
+
}
|
570
|
+
},
|
571
|
+
custom: {}
|
572
|
+
},
|
573
|
+
headline: {
|
574
|
+
grid: {
|
575
|
+
x: 3,
|
576
|
+
y: 1
|
577
|
+
},
|
578
|
+
default: {
|
579
|
+
content: '',
|
580
|
+
style: :style__document__font_size__small,
|
581
|
+
align: :right,
|
582
|
+
text_color: :style__colors__header__default,
|
583
|
+
borders: [ :left ],
|
584
|
+
border_width: 2
|
585
|
+
},
|
586
|
+
image: {
|
587
|
+
src: '',
|
588
|
+
colspan: 2,
|
589
|
+
rowspan: 2,
|
590
|
+
grid: [ 0, 0 ],
|
591
|
+
borders: [],
|
592
|
+
fit: [ 160, 100 ],
|
593
|
+
border_width: 0
|
594
|
+
},
|
595
|
+
texts: [
|
596
|
+
{
|
597
|
+
content: :sections__one__name__content,
|
598
|
+
grid: [ 2, 0 ],
|
599
|
+
style: :style__document__font_size__h1,
|
600
|
+
align: :right,
|
601
|
+
text_color: :style__colors__header__default,
|
602
|
+
borders: [ ],
|
603
|
+
border_width: 0
|
604
|
+
}
|
605
|
+
]
|
606
|
+
},
|
607
|
+
footer: {
|
608
|
+
left: {
|
609
|
+
one: :sections__nine__left_one__content,
|
610
|
+
two: :sections__nine__left_two__content,
|
611
|
+
three: :sections__nine__left_three__content,
|
612
|
+
four: :sections__nine__left_four__content
|
613
|
+
},
|
614
|
+
center: {
|
615
|
+
one: :sections__nine__center_one__content,
|
616
|
+
two: :sections__nine__center_two__content,
|
617
|
+
three: :sections__nine__center_three__content,
|
618
|
+
four: :sections__nine__center_four__content
|
619
|
+
},
|
620
|
+
right: {
|
621
|
+
one: :sections__nine__right_one__content,
|
622
|
+
two: :sections__nine__right_two__content,
|
623
|
+
three: :sections__nine__right_three__content,
|
624
|
+
four: :sections__nine__right_four__content
|
625
|
+
}
|
626
|
+
},
|
627
|
+
validation: {
|
628
|
+
allows: [
|
629
|
+
:show__qr_code,
|
630
|
+
:show__sub_total,
|
631
|
+
:show__shipping,
|
632
|
+
:show__total_net,
|
633
|
+
:show__vat,
|
634
|
+
:show__total_gross,
|
635
|
+
:show__logo,
|
636
|
+
:show__watermark,
|
637
|
+
:show__unencrypted,
|
638
|
+
:order,
|
639
|
+
:text__phone,
|
640
|
+
:text__mobile,
|
641
|
+
:text__email,
|
642
|
+
:text__website,
|
643
|
+
:text__tax_id,
|
644
|
+
:text__invoice,
|
645
|
+
:text__page_count,
|
646
|
+
:text__articles__nr,
|
647
|
+
:text__articles__id,
|
648
|
+
:text__articles__article,
|
649
|
+
:text__articles__piece,
|
650
|
+
:text__articles__single,
|
651
|
+
:text__articles__total,
|
652
|
+
:text__total__sub_total,
|
653
|
+
:text__total__shipping,
|
654
|
+
:text__total__total_net,
|
655
|
+
:text__total__vat,
|
656
|
+
:text__total__total_gross,
|
657
|
+
:text__footer__left,
|
658
|
+
:text__footer__center,
|
659
|
+
:text__footer__right,
|
660
|
+
:text__watermark,
|
661
|
+
:style__document__format,
|
662
|
+
:style__page_count__align,
|
663
|
+
:style__page_count__start_count_at,
|
664
|
+
:style__page_count__offset_y,
|
665
|
+
:style__font__name,
|
666
|
+
:style__font__family,
|
667
|
+
:style__font__default,
|
668
|
+
:style__font__small,
|
669
|
+
:style__colors__background,
|
670
|
+
:style__colors__header__default,
|
671
|
+
:style__colors__rows__even,
|
672
|
+
:style__colors__rows__odd,
|
673
|
+
:style__header__height,
|
674
|
+
:style__address_label__offset_x,
|
675
|
+
:style__address_label__move_down_one,
|
676
|
+
:style__address_label__move_down_two,
|
677
|
+
:style__footer__height,
|
678
|
+
:style__footer__border_width,
|
679
|
+
:style__footer__borders,
|
680
|
+
:style__sections__pad,
|
681
|
+
:style__articles__nr__align,
|
682
|
+
:style__articles__nr__width,
|
683
|
+
:style__articles__id__align,
|
684
|
+
:style__articles__id__width,
|
685
|
+
:style__articles__article__align,
|
686
|
+
:style__articles__article__width,
|
687
|
+
:style__articles__piece__align,
|
688
|
+
:style__articles__piece__width,
|
689
|
+
:style__articles__single__align,
|
690
|
+
:style__articles__single__width,
|
691
|
+
:style__articles__single__format,
|
692
|
+
:style__articles__total__align,
|
693
|
+
:style__articles__total__width,
|
694
|
+
:style__articles__total__format,
|
695
|
+
:style__total__sub_total__borders,
|
696
|
+
:style__total__sub_total__border_width,
|
697
|
+
:style__total__shipping__borders,
|
698
|
+
:style__total__shipping__border_width,
|
699
|
+
:style__total__total_net__borders,
|
700
|
+
:style__total__total_net__border_width,
|
701
|
+
:style__total__vat__borders,
|
702
|
+
:style__total__vat__border_width,
|
703
|
+
:style__total__total_gross__borders,
|
704
|
+
:style__total__total_gross__border_width,
|
705
|
+
:style__qr_code__width,
|
706
|
+
:style__watermark__rotate,
|
707
|
+
:style__watermark__fill_color,
|
708
|
+
:style__watermark__font_size,
|
709
|
+
:style__watermark__font_family,
|
710
|
+
:style__watermark__transparency,
|
711
|
+
:format_types__currency__short,
|
712
|
+
:format_types__currency__long,
|
713
|
+
:format_types__date__eu,
|
714
|
+
:format_types__date__short,
|
715
|
+
:format_types__date__default,
|
716
|
+
:format_types__date__long,
|
717
|
+
:format_types__date__year,
|
718
|
+
:sections__nine__left_headline,
|
719
|
+
:sections__nine__left_one,
|
720
|
+
:sections__nine__left_two,
|
721
|
+
:sections__nine__left_three,
|
722
|
+
:sections__nine__left_four,
|
723
|
+
:sections__nine__center_headline,
|
724
|
+
:sections__nine__center_one,
|
725
|
+
:sections__nine__center_two,
|
726
|
+
:sections__nine__center_three,
|
727
|
+
:sections__nine__center_four,
|
728
|
+
:sections__nine__right_headline,
|
729
|
+
:sections__nine__right_one,
|
730
|
+
:sections__nine__right_two,
|
731
|
+
:sections__nine__right_three,
|
732
|
+
:sections__nine__right_four,
|
733
|
+
:sections__eight__snippet,
|
734
|
+
:sections__seven__snippet,
|
735
|
+
:sections__six__sub_total,
|
736
|
+
:sections__six__shipping,
|
737
|
+
:sections__six__total_net,
|
738
|
+
:sections__six__vat,
|
739
|
+
:sections__six__total_gross,
|
740
|
+
:sections__four__snippet,
|
741
|
+
:sections__three__qr_code,
|
742
|
+
:sections__three__date,
|
743
|
+
:sections__three__headline,
|
744
|
+
:sections__two__small,
|
745
|
+
:sections__two__to,
|
746
|
+
:sections__one__name,
|
747
|
+
:headline__grid__x,
|
748
|
+
:headline__grid__y,
|
749
|
+
:headline__default__content,
|
750
|
+
:headline__default__style,
|
751
|
+
:headline__default__align,
|
752
|
+
:headline__default__text_color,
|
753
|
+
:headline__default__borders,
|
754
|
+
:headline__default__border_width,
|
755
|
+
:headline__image__src,
|
756
|
+
:headline__image__colspan,
|
757
|
+
:headline__image__rowspan,
|
758
|
+
:headline__image__grid,
|
759
|
+
:headline__image__borders,
|
760
|
+
:headline__image__fit,
|
761
|
+
:headline__image__border_width,
|
762
|
+
:headline__texts,
|
763
|
+
:footer__left__one,
|
764
|
+
:footer__left__two,
|
765
|
+
:footer__left__three,
|
766
|
+
:footer__left__four,
|
767
|
+
:footer__center__one,
|
768
|
+
:footer__center__two,
|
769
|
+
:footer__center__three,
|
770
|
+
:footer__center__four,
|
771
|
+
:footer__right__one,
|
772
|
+
:footer__right__two,
|
773
|
+
:footer__right__three,
|
774
|
+
:footer__right__four
|
775
|
+
],
|
776
|
+
wildcards: []
|
777
|
+
}
|
778
|
+
}
|
779
|
+
end
|
780
|
+
|
781
|
+
|
782
|
+
private
|
783
|
+
|
784
|
+
|
785
|
+
def options_update( options, obj, validation )
|
786
|
+
def str_difference( a, b )
|
787
|
+
a = a.to_s.downcase.split( '_' ).join( '' )
|
788
|
+
b = b.to_s.downcase.split( '_' ).join( '' )
|
789
|
+
longer = [ a.size, b.size ].max
|
790
|
+
same = a
|
791
|
+
.each_char
|
792
|
+
.zip( b.each_char )
|
793
|
+
.select { | a, b | a == b }
|
794
|
+
.size
|
795
|
+
( longer - same ) / a.size.to_f
|
796
|
+
end
|
797
|
+
|
798
|
+
|
799
|
+
allows = obj[:validation][:allows]
|
800
|
+
wildcards = obj[:validation][:wildcards]
|
801
|
+
|
802
|
+
messages = []
|
803
|
+
insert = Marshal.load( Marshal.dump( obj ) )
|
804
|
+
|
805
|
+
options.keys.each do | key |
|
806
|
+
if allows.include?( key )
|
807
|
+
|
808
|
+
keys = key.to_s.split( '__' ).map { | a | a.to_sym }
|
809
|
+
case( keys.length )
|
810
|
+
when 1
|
811
|
+
insert[ keys[ 0 ] ] = options[ key ]
|
812
|
+
when 2
|
813
|
+
insert[ keys[ 0 ] ][ keys[ 1 ] ] = options[ key ]
|
814
|
+
when 3
|
815
|
+
insert[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ] = options[ key ]
|
816
|
+
when 4
|
817
|
+
insert[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ][ keys[ 3 ] ] = options[ key ]
|
818
|
+
end
|
819
|
+
else
|
820
|
+
standard = true
|
821
|
+
keys = key.to_s.split( '__' ).map { | a | a.to_sym }
|
822
|
+
case keys.length
|
823
|
+
when 1
|
824
|
+
inside = wildcards
|
825
|
+
.map { | a | a.to_s.split( '__' ).first.to_sym }
|
826
|
+
.include?( keys[ 0 ] )
|
827
|
+
|
828
|
+
if inside
|
829
|
+
message = "\"#{key}\" is a potential Wildcard key but has an invalid length. Use two additional keys (plus '__') to set your option."
|
830
|
+
messages.push( message )
|
831
|
+
standard = false
|
832
|
+
else
|
833
|
+
end
|
834
|
+
when 2..3
|
835
|
+
wildcard = [ keys[ 0 ].to_s, keys[ 1 ].to_s ].join( '__' ).to_sym
|
836
|
+
if wildcards.include?( wildcard )
|
837
|
+
if keys.length == 2
|
838
|
+
message = "\"#{key}\" is a Wildcard key but has an invalid length. Use an additional key (plus '__') to set your option."
|
839
|
+
messages.push( message )
|
840
|
+
standard = false
|
841
|
+
else
|
842
|
+
!insert.keys.include?( keys[ 0 ] ) ? insert[ keys[ 0 ] ] = {} : ''
|
843
|
+
!insert[ keys[ 0 ] ].keys.include?( keys[ 1 ] ) ? insert[ keys[ 0 ] ][ keys[ 1 ] ] = {} : ''
|
844
|
+
insert[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ] = options[ key ]
|
845
|
+
standard = false
|
846
|
+
end
|
847
|
+
else
|
848
|
+
end
|
849
|
+
else
|
850
|
+
end
|
851
|
+
|
852
|
+
if standard
|
853
|
+
nearest = allows
|
854
|
+
.map { | word | { score: str_difference( key, word ), word: word } }
|
855
|
+
.min_by { | item | item[:score] }
|
856
|
+
|
857
|
+
if nearest.nil?
|
858
|
+
message = "\"#{key}\" is not a valid key."
|
859
|
+
else
|
860
|
+
message = "\"#{key}\" is not a valid key, did you mean \"<--similar-->\"?"
|
861
|
+
message = message.gsub( '<--similar-->', nearest[:word].to_s )
|
862
|
+
end
|
863
|
+
|
864
|
+
messages.push( message )
|
865
|
+
end
|
866
|
+
end
|
867
|
+
end
|
868
|
+
|
869
|
+
if messages.length != 0
|
870
|
+
messages.length == 1 ? puts( 'Error found:' ) : puts( 'Errors found:' )
|
871
|
+
messages.each { | m | puts( '- ' + m ) }
|
872
|
+
end
|
873
|
+
|
874
|
+
return validation ? messages.length == 0 : insert
|
875
|
+
end
|
876
|
+
|
877
|
+
|
878
|
+
def get_value( keys, data, drop )
|
879
|
+
|
880
|
+
drop ? keys = keys.drop( 1 ) : ''
|
881
|
+
case keys.length
|
882
|
+
when 1
|
883
|
+
params = data[ keys[ 0 ] ]
|
884
|
+
when 2
|
885
|
+
params = data[ keys[ 0 ] ][ keys[ 1 ] ]
|
886
|
+
when 3
|
887
|
+
params = data[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ]
|
888
|
+
when 4
|
889
|
+
params = data[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ][ keys[ 3 ] ]
|
890
|
+
when 5
|
891
|
+
params = data[ keys[ 0 ] ][ keys[ 1 ] ][ keys[ 2 ] ][ keys[ 3 ] ][ keys[ 4 ] ]
|
892
|
+
end
|
893
|
+
|
894
|
+
return params
|
895
|
+
end
|
896
|
+
|
897
|
+
|
898
|
+
def get_format( type, value, _format )
|
899
|
+
case type
|
900
|
+
when :date
|
901
|
+
result = DateTime.strptime( value.to_s, '%s' )
|
902
|
+
.strftime( _format[:strf] )
|
903
|
+
when :currency
|
904
|
+
result = ActiveSupport::NumberHelper
|
905
|
+
.number_to_currency( value.to_s, _format )
|
906
|
+
else
|
907
|
+
result = value
|
908
|
+
end
|
909
|
+
|
910
|
+
return result
|
911
|
+
end
|
912
|
+
|
913
|
+
end
|