invoice_printer 2.0.0.beta1 → 2.0.0.beta2
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 +4 -4
- data/docs/LIBRARY.md +2 -0
- data/lib/invoice_printer/pdf_document.rb +33 -8
- data/lib/invoice_printer/version.rb +1 -1
- data/test/api_test.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 253de7f5df575343e45fad182f3a6e62fca98cac0758da832361f15b1a11ddbb
|
4
|
+
data.tar.gz: fe9755f88c5b148829050a565d9bcb043e3e1b36c64b7bbd2e5519fd3a4542fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a603e7f39acc192dbd81efe372538df190ae4ac90eb15b0a8103477030663162bdcdfd5647cfc98455e756028109b5eb3c91e0a312e5862d72ea88d2a5f3b5e
|
7
|
+
data.tar.gz: 63e01b1748787113d5d70d4dca62aa20501588ae9b9a74fe1a8944d61a5c78e8a9c66a4208d5d78fa01ba0df1029b6ec4f01ae3b207eadf49d293bae9cea5c33
|
data/docs/LIBRARY.md
CHANGED
@@ -94,11 +94,7 @@ module InvoicePrinter
|
|
94
94
|
end
|
95
95
|
|
96
96
|
if used? @font
|
97
|
-
|
98
|
-
set_fonts(@font) if @font
|
99
|
-
else
|
100
|
-
raise FontFileNotFound, "Font file not found at #{@font}"
|
101
|
-
end
|
97
|
+
use_font(@font)
|
102
98
|
end
|
103
99
|
|
104
100
|
# Version 2.1 deprecation warnings
|
@@ -146,8 +142,36 @@ module InvoicePrinter
|
|
146
142
|
|
147
143
|
private
|
148
144
|
|
145
|
+
def use_font(font)
|
146
|
+
if File.exist?(@font)
|
147
|
+
set_font_from_path(@font)
|
148
|
+
elsif @font == 'dejavu'
|
149
|
+
set_dejavu_font
|
150
|
+
else
|
151
|
+
raise FontFileNotFound, "Font file not found at #{font}"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# DejaVu from dejavu-fonts gem
|
156
|
+
def set_dejavu_font
|
157
|
+
require 'dejavu-fonts'
|
158
|
+
font_name = 'dejavu'
|
159
|
+
|
160
|
+
@pdf.font_families.update(
|
161
|
+
"#{font_name}" => {
|
162
|
+
normal: DejaVu::Fonts.paths[:normal],
|
163
|
+
italic: DejaVu::Fonts.paths[:italic],
|
164
|
+
bold: DejaVu::Fonts.paths[:bold],
|
165
|
+
bold_italic: DejaVu::Fonts.paths[:bold_italic]
|
166
|
+
}
|
167
|
+
)
|
168
|
+
@pdf.font(font_name)
|
169
|
+
rescue
|
170
|
+
raise FontFileNotFound, "Font file not found for #{font}"
|
171
|
+
end
|
172
|
+
|
149
173
|
# Add font family in Prawn for a given +font+ file
|
150
|
-
def
|
174
|
+
def set_font_from_path(font)
|
151
175
|
font_name = Pathname.new(font).basename
|
152
176
|
@pdf.font_families.update(
|
153
177
|
"#{font_name}" => {
|
@@ -447,7 +471,6 @@ module InvoicePrinter
|
|
447
471
|
end
|
448
472
|
|
449
473
|
# Match the height of next box if needed
|
450
|
-
# TODO: it's smaller without sublabels
|
451
474
|
min_height = 60
|
452
475
|
if used?(@document.issue_date) || used?(@document.due_date)
|
453
476
|
min_height = (used?(@document.issue_date) && used?(@document.due_date)) ? 75 : 60
|
@@ -467,7 +490,8 @@ module InvoicePrinter
|
|
467
490
|
at: [10, y(483) - @push_down],
|
468
491
|
width: x(234)
|
469
492
|
)
|
470
|
-
|
493
|
+
|
494
|
+
@pdf.stroke_rounded_rectangle([0, y(508) - @push_down], x(266), @payment_box_height, 6)
|
471
495
|
else
|
472
496
|
@payment_box_height = 60
|
473
497
|
@push_iban = 0
|
@@ -654,6 +678,7 @@ module InvoicePrinter
|
|
654
678
|
height = @payment_box_height if @payment_box_height > height
|
655
679
|
|
656
680
|
@pdf.stroke_rounded_rectangle([x(274), y(508) - @push_down], x(266), height, 6)
|
681
|
+
@push_items_table += 12 if @push_items_table <= 18
|
657
682
|
end
|
658
683
|
end
|
659
684
|
|
data/test/api_test.rb
CHANGED
@@ -73,6 +73,6 @@ class ApiTest < Minitest::Test
|
|
73
73
|
body = JSON.parse last_response.body
|
74
74
|
|
75
75
|
assert last_response.ok?
|
76
|
-
assert_equal body, { 'result' => 'ok', 'data' => Base64.
|
76
|
+
assert_equal body, { 'result' => 'ok', 'data' => Base64.strict_encode64(output) }
|
77
77
|
end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invoice_printer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Strzibny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|