webtranslateit-payday 1.6.9 → 1.7.0
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/.github/workflows/ci.yml +3 -3
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +53 -41
- data/README.md +16 -0
- data/lib/payday/invoice.rb +3 -1
- data/lib/payday/pdf_renderer.rb +17 -2
- data/payday.gemspec +2 -1
- data/spec/assets/example_invoice_with_qr.pdf +0 -0
- data/spec/invoice_spec.rb +105 -0
- metadata +24 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 288b40a42302084745d843de21dc11073b847efa4a32d03d4a4630c787f5d7fc
|
|
4
|
+
data.tar.gz: c01691b9167248808eaa803d57de94ba689b475af09bceaac6c4f5984eef0653
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1719b034bf1a3555af1e00b074db6dab87118c77b7533356c1a7db22ae35b41ee7b4617d7f5455c0bad26695ee83d968aac3f0ab223a39c74d257d1ca314c28c
|
|
7
|
+
data.tar.gz: 984d41537f2a71ef74c700b89b7a075cb3eb6828c991668038c09ab12787b68fc5c1c7fab0944b60236692b30636dacb19fb1301e8e4f4a21a1e87e2385610fa
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -17,7 +17,7 @@ jobs:
|
|
|
17
17
|
ruby-version: ['3.2', '3.3', '3.4']
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
21
|
- name: Set up Ruby
|
|
22
22
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
|
23
23
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
|
@@ -30,12 +30,12 @@ jobs:
|
|
|
30
30
|
|
|
31
31
|
linters:
|
|
32
32
|
name: Linters
|
|
33
|
-
runs-on: ubuntu-
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
34
|
timeout-minutes: 10
|
|
35
35
|
|
|
36
36
|
steps:
|
|
37
37
|
- name: Checkout repository
|
|
38
|
-
uses: actions/checkout@
|
|
38
|
+
uses: actions/checkout@v6
|
|
39
39
|
|
|
40
40
|
- name: Install ruby and gems
|
|
41
41
|
uses: ruby/setup-ruby@v1
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
webtranslateit-payday (1.
|
|
4
|
+
webtranslateit-payday (1.7.0)
|
|
5
5
|
activesupport (>= 7, < 9)
|
|
6
6
|
i18n (~> 1.12, < 2)
|
|
7
7
|
money (~> 6.16, < 7)
|
|
8
8
|
prawn (~> 2.4, < 3)
|
|
9
9
|
prawn-svg (~> 0.32, < 1)
|
|
10
10
|
prawn-table (~> 0.2, < 1)
|
|
11
|
+
rqrcode (~> 2.0, < 3)
|
|
11
12
|
zeitwerk (~> 2.6, < 3)
|
|
12
13
|
|
|
13
14
|
GEM
|
|
14
15
|
remote: https://rubygems.org/
|
|
15
16
|
specs:
|
|
16
|
-
activesupport (7.2.
|
|
17
|
+
activesupport (7.2.3)
|
|
17
18
|
base64
|
|
18
19
|
benchmark (>= 0.3)
|
|
19
20
|
bigdecimal
|
|
@@ -27,17 +28,18 @@ GEM
|
|
|
27
28
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
28
29
|
addressable (2.8.7)
|
|
29
30
|
public_suffix (>= 2.0.2, < 7.0)
|
|
30
|
-
ast (2.4.
|
|
31
|
-
base64 (0.
|
|
32
|
-
benchmark (0.
|
|
33
|
-
bigdecimal (3.1
|
|
31
|
+
ast (2.4.3)
|
|
32
|
+
base64 (0.3.0)
|
|
33
|
+
benchmark (0.5.0)
|
|
34
|
+
bigdecimal (3.3.1)
|
|
35
|
+
chunky_png (1.4.0)
|
|
34
36
|
coderay (1.1.3)
|
|
35
37
|
concurrent-ruby (1.3.5)
|
|
36
|
-
connection_pool (2.4
|
|
37
|
-
css_parser (1.21.
|
|
38
|
+
connection_pool (2.5.4)
|
|
39
|
+
css_parser (1.21.1)
|
|
38
40
|
addressable
|
|
39
|
-
diff-lcs (1.
|
|
40
|
-
drb (2.2.
|
|
41
|
+
diff-lcs (1.6.2)
|
|
42
|
+
drb (2.2.3)
|
|
41
43
|
ffi (1.17.1-arm64-darwin)
|
|
42
44
|
ffi (1.17.1-x86_64-darwin)
|
|
43
45
|
ffi (1.17.1-x86_64-linux-gnu)
|
|
@@ -63,16 +65,17 @@ GEM
|
|
|
63
65
|
rubocop (< 2.0)
|
|
64
66
|
i18n (1.14.7)
|
|
65
67
|
concurrent-ruby (~> 1.0)
|
|
66
|
-
json (2.
|
|
67
|
-
language_server-protocol (3.17.0.
|
|
68
|
+
json (2.16.0)
|
|
69
|
+
language_server-protocol (3.17.0.5)
|
|
70
|
+
lint_roller (1.1.0)
|
|
68
71
|
listen (3.9.0)
|
|
69
72
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
70
73
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
71
|
-
logger (1.
|
|
74
|
+
logger (1.7.0)
|
|
72
75
|
lumberjack (1.2.10)
|
|
73
|
-
matrix (0.4.
|
|
76
|
+
matrix (0.4.3)
|
|
74
77
|
method_source (1.1.0)
|
|
75
|
-
minitest (5.
|
|
78
|
+
minitest (5.26.0)
|
|
76
79
|
money (6.19.0)
|
|
77
80
|
i18n (>= 0.6.4, <= 2)
|
|
78
81
|
nenv (0.3.0)
|
|
@@ -80,8 +83,8 @@ GEM
|
|
|
80
83
|
nenv (~> 0.1)
|
|
81
84
|
shellany (~> 0.0)
|
|
82
85
|
ostruct (0.6.1)
|
|
83
|
-
parallel (1.
|
|
84
|
-
parser (3.3.
|
|
86
|
+
parallel (1.27.0)
|
|
87
|
+
parser (3.3.10.0)
|
|
85
88
|
ast (~> 2.4.1)
|
|
86
89
|
racc
|
|
87
90
|
pdf-core (0.10.0)
|
|
@@ -89,54 +92,63 @@ GEM
|
|
|
89
92
|
matrix (~> 0.4)
|
|
90
93
|
pdf-core (~> 0.10.0)
|
|
91
94
|
ttfunk (~> 1.8)
|
|
92
|
-
prawn-svg (0.
|
|
95
|
+
prawn-svg (0.38.1)
|
|
93
96
|
css_parser (~> 1.6)
|
|
94
97
|
matrix (~> 0.4.2)
|
|
95
98
|
prawn (>= 0.11.1, < 3)
|
|
96
|
-
rexml (>= 3.
|
|
99
|
+
rexml (>= 3.4.2, < 4)
|
|
97
100
|
prawn-table (0.2.2)
|
|
98
101
|
prawn (>= 1.3.0, < 3.0.0)
|
|
102
|
+
prism (1.6.0)
|
|
99
103
|
pry (0.15.2)
|
|
100
104
|
coderay (~> 1.1)
|
|
101
105
|
method_source (~> 1.0)
|
|
102
|
-
public_suffix (6.0.
|
|
106
|
+
public_suffix (6.0.2)
|
|
103
107
|
racc (1.8.1)
|
|
104
108
|
rainbow (3.1.1)
|
|
105
109
|
rb-fsevent (0.11.2)
|
|
106
110
|
rb-inotify (0.11.1)
|
|
107
111
|
ffi (~> 1.0)
|
|
108
|
-
regexp_parser (2.
|
|
109
|
-
rexml (3.4.
|
|
110
|
-
|
|
112
|
+
regexp_parser (2.11.3)
|
|
113
|
+
rexml (3.4.4)
|
|
114
|
+
rqrcode (2.2.0)
|
|
115
|
+
chunky_png (~> 1.0)
|
|
116
|
+
rqrcode_core (~> 1.0)
|
|
117
|
+
rqrcode_core (1.2.0)
|
|
118
|
+
rspec (3.13.2)
|
|
111
119
|
rspec-core (~> 3.13.0)
|
|
112
120
|
rspec-expectations (~> 3.13.0)
|
|
113
121
|
rspec-mocks (~> 3.13.0)
|
|
114
|
-
rspec-core (3.13.
|
|
122
|
+
rspec-core (3.13.6)
|
|
115
123
|
rspec-support (~> 3.13.0)
|
|
116
|
-
rspec-expectations (3.13.
|
|
124
|
+
rspec-expectations (3.13.5)
|
|
117
125
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
118
126
|
rspec-support (~> 3.13.0)
|
|
119
|
-
rspec-mocks (3.13.
|
|
127
|
+
rspec-mocks (3.13.6)
|
|
120
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
121
129
|
rspec-support (~> 3.13.0)
|
|
122
|
-
rspec-support (3.13.
|
|
123
|
-
rubocop (1.
|
|
130
|
+
rspec-support (3.13.6)
|
|
131
|
+
rubocop (1.81.7)
|
|
124
132
|
json (~> 2.3)
|
|
125
|
-
language_server-protocol (
|
|
133
|
+
language_server-protocol (~> 3.17.0.2)
|
|
134
|
+
lint_roller (~> 1.1.0)
|
|
126
135
|
parallel (~> 1.10)
|
|
127
136
|
parser (>= 3.3.0.2)
|
|
128
137
|
rainbow (>= 2.2.2, < 4.0)
|
|
129
138
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
130
|
-
rubocop-ast (>= 1.
|
|
139
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
131
140
|
ruby-progressbar (~> 1.7)
|
|
132
141
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
133
|
-
rubocop-ast (1.
|
|
134
|
-
parser (>= 3.3.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
rubocop (
|
|
142
|
+
rubocop-ast (1.48.0)
|
|
143
|
+
parser (>= 3.3.7.2)
|
|
144
|
+
prism (~> 1.4)
|
|
145
|
+
rubocop-performance (1.26.1)
|
|
146
|
+
lint_roller (~> 1.1)
|
|
147
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
148
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
149
|
+
rubocop-rspec (3.8.0)
|
|
150
|
+
lint_roller (~> 1.1)
|
|
151
|
+
rubocop (~> 1.81)
|
|
140
152
|
ruby-progressbar (1.13.0)
|
|
141
153
|
securerandom (0.4.1)
|
|
142
154
|
shellany (0.0.1)
|
|
@@ -145,9 +157,9 @@ GEM
|
|
|
145
157
|
bigdecimal (~> 3.1)
|
|
146
158
|
tzinfo (2.0.6)
|
|
147
159
|
concurrent-ruby (~> 1.0)
|
|
148
|
-
unicode-display_width (3.
|
|
149
|
-
unicode-emoji (~> 4.
|
|
150
|
-
unicode-emoji (4.0
|
|
160
|
+
unicode-display_width (3.2.0)
|
|
161
|
+
unicode-emoji (~> 4.1)
|
|
162
|
+
unicode-emoji (4.1.0)
|
|
151
163
|
zeitwerk (2.7.1)
|
|
152
164
|
|
|
153
165
|
PLATFORMS
|
|
@@ -163,7 +175,7 @@ DEPENDENCIES
|
|
|
163
175
|
guard-rspec
|
|
164
176
|
guard-rubocop
|
|
165
177
|
matrix
|
|
166
|
-
rspec (~> 3.13.
|
|
178
|
+
rspec (~> 3.13.2)
|
|
167
179
|
rubocop
|
|
168
180
|
rubocop-performance
|
|
169
181
|
rubocop-rspec
|
data/README.md
CHANGED
|
@@ -53,6 +53,22 @@ Payday::Config.default.company_name = "Awesome Corp"
|
|
|
53
53
|
Payday::Config.default.company_details = "10 This Way\nManhattan, NY 10001\n800-111-2222\nawesome@awesomecorp.com"
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
QR Code Support
|
|
57
|
+
===
|
|
58
|
+
Invoices can include QR codes for verification purposes, useful for tax compliance requirements in various countries.
|
|
59
|
+
|
|
60
|
+
Example:
|
|
61
|
+
|
|
62
|
+
``` ruby
|
|
63
|
+
invoice = Payday::Invoice.new(
|
|
64
|
+
invoice_number: 12345,
|
|
65
|
+
qr_code: 'https://verify.example.com/invoice/12345',
|
|
66
|
+
notes: 'Scan the QR code below to verify this invoice online.'
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
QR codes are automatically rendered below the notes section.
|
|
71
|
+
|
|
56
72
|
Using Payday with ActiveRecord Objects (or any other objects, for that matter)
|
|
57
73
|
===
|
|
58
74
|
|
data/lib/payday/invoice.rb
CHANGED
|
@@ -8,7 +8,8 @@ module Payday
|
|
|
8
8
|
include Payday::Invoiceable
|
|
9
9
|
|
|
10
10
|
attr_accessor :invoice_number, :bill_to, :ship_to, :notes, :line_items, :shipping_description,
|
|
11
|
-
:tax_description, :due_at, :paid_at, :refunded_at, :currency, :invoice_details, :invoice_date
|
|
11
|
+
:tax_description, :due_at, :paid_at, :refunded_at, :currency, :invoice_details, :invoice_date,
|
|
12
|
+
:qr_code
|
|
12
13
|
|
|
13
14
|
attr_reader :tax_rate, :shipping_rate
|
|
14
15
|
|
|
@@ -31,6 +32,7 @@ module Payday
|
|
|
31
32
|
self.currency = options[:currency] || nil
|
|
32
33
|
self.invoice_details = options[:invoice_details] || []
|
|
33
34
|
self.invoice_date = options[:invoice_date] || nil
|
|
35
|
+
self.qr_code = options[:qr_code] || nil
|
|
34
36
|
end
|
|
35
37
|
# rubocop:enable Metrics/AbcSize
|
|
36
38
|
# rubocop:enable Metrics/MethodLength
|
data/lib/payday/pdf_renderer.rb
CHANGED
|
@@ -36,6 +36,7 @@ module Payday
|
|
|
36
36
|
line_items_table(invoice, pdf)
|
|
37
37
|
totals_lines(invoice, pdf)
|
|
38
38
|
notes(invoice, pdf)
|
|
39
|
+
render_qr_code(invoice, pdf) unless defined?(invoice.notes) && invoice.notes
|
|
39
40
|
|
|
40
41
|
page_numbers(pdf)
|
|
41
42
|
|
|
@@ -213,7 +214,7 @@ module Payday
|
|
|
213
214
|
inline_format: true},
|
|
214
215
|
row_colors: %w[F6F9FC ffffff]) do
|
|
215
216
|
# left align the number columns
|
|
216
|
-
columns(1..3).rows(1..row_length - 1).style(align: :right)
|
|
217
|
+
columns(1..3).rows(1..(row_length - 1)).style(align: :right)
|
|
217
218
|
|
|
218
219
|
# set the column widths correctly
|
|
219
220
|
natural = natural_column_widths
|
|
@@ -268,7 +269,7 @@ module Payday
|
|
|
268
269
|
end
|
|
269
270
|
# rubocop:enable Metrics/MethodLength
|
|
270
271
|
|
|
271
|
-
def self.notes(invoice, pdf) # rubocop:todo Metrics/AbcSize
|
|
272
|
+
def self.notes(invoice, pdf) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
|
272
273
|
return unless defined?(invoice.notes) && invoice.notes
|
|
273
274
|
|
|
274
275
|
pdf.move_cursor_to(pdf.cursor - 30)
|
|
@@ -280,6 +281,20 @@ module Payday
|
|
|
280
281
|
pdf.stroke_line([0, pdf.cursor - 3, pdf.bounds.width, pdf.cursor - 3])
|
|
281
282
|
pdf.move_cursor_to(pdf.cursor - 10)
|
|
282
283
|
pdf.text(invoice.notes.to_s, inline_format: true)
|
|
284
|
+
|
|
285
|
+
render_qr_code(invoice, pdf)
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def self.render_qr_code(invoice, pdf)
|
|
289
|
+
return unless defined?(invoice.qr_code) && invoice.qr_code.to_s.strip.present?
|
|
290
|
+
|
|
291
|
+
require 'rqrcode'
|
|
292
|
+
|
|
293
|
+
pdf.move_cursor_to(pdf.cursor - 10)
|
|
294
|
+
qr = RQRCode::QRCode.new(invoice.qr_code.to_s)
|
|
295
|
+
png = qr.as_png(size: 200)
|
|
296
|
+
|
|
297
|
+
pdf.image(StringIO.new(png.to_s), width: 100, position: :left)
|
|
283
298
|
end
|
|
284
299
|
|
|
285
300
|
def self.page_numbers(pdf)
|
data/payday.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = 'webtranslateit-payday'
|
|
5
|
-
s.version = '1.
|
|
5
|
+
s.version = '1.7.0'
|
|
6
6
|
s.required_ruby_version = '>= 3.1'
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
|
8
8
|
s.authors = ['Alan Johnson', 'Edouard Briere']
|
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
|
18
18
|
s.add_dependency 'prawn', '~> 2.4', '< 3'
|
|
19
19
|
s.add_dependency 'prawn-svg', '~> 0.32', '< 1'
|
|
20
20
|
s.add_dependency 'prawn-table', '~> 0.2', '< 1'
|
|
21
|
+
s.add_dependency 'rqrcode', '~> 2.0', '< 3'
|
|
21
22
|
s.add_dependency 'zeitwerk', '~> 2.6', '< 3'
|
|
22
23
|
|
|
23
24
|
s.files = `git ls-files`.split("\n")
|
|
Binary file
|
data/spec/invoice_spec.rb
CHANGED
|
@@ -244,6 +244,111 @@ module Payday # rubocop:todo Metrics/ModuleLength
|
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
|
+
context 'with QR code' do
|
|
248
|
+
it 'renders a complete invoice with QR code correctly' do # rubocop:todo RSpec/ExampleLength
|
|
249
|
+
Payday::Config.default.company_name = 'Example Company'
|
|
250
|
+
Payday::Config.default.company_details = "123 Business St\nCity, ST 12345\ninfo@example.com"
|
|
251
|
+
|
|
252
|
+
notes = "<b>Payment Terms:</b> Net 30 days\n\n" \
|
|
253
|
+
"<b>Verification:</b> Scan the QR code below to verify this invoice online.\n\n" \
|
|
254
|
+
'Questions? Contact us at <u>billing@example.com</u>'
|
|
255
|
+
|
|
256
|
+
invoice = described_class.new(
|
|
257
|
+
invoice_number: 'INV-2024-001',
|
|
258
|
+
invoice_date: Date.civil(2024, 11, 25),
|
|
259
|
+
due_at: Date.civil(2024, 12, 25),
|
|
260
|
+
bill_to: "Customer Name\n456 Customer Ave\nTown, ST 67890",
|
|
261
|
+
tax_rate: 10.0,
|
|
262
|
+
qr_code: 'https://example.com/verify/INV-2024-001',
|
|
263
|
+
notes: notes
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
invoice.add_line_item(description: 'Consulting Services', quantity: 10, price: 150)
|
|
267
|
+
invoice.add_line_item(description: 'Software License', predefined_amount: 500)
|
|
268
|
+
|
|
269
|
+
expect(invoice.render_pdf).to match_binary_asset 'example_invoice_with_qr.pdf'
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
it 'renders invoice with QR code containing URL' do # rubocop:todo RSpec/MultipleExpectations
|
|
273
|
+
invoice = new_invoice(qr_code: 'https://example.com/verify/invoice/12345')
|
|
274
|
+
invoice.line_items << LineItem.new(price: 20, quantity: 1, description: 'Test Item')
|
|
275
|
+
|
|
276
|
+
pdf_string = invoice.render_pdf
|
|
277
|
+
expect(pdf_string).to be_a(String)
|
|
278
|
+
expect(pdf_string.bytesize).to be > 0
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
# rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
282
|
+
it 'renders invoice with QR code containing arbitrary data' do
|
|
283
|
+
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
284
|
+
qr_data = 'INVOICE:12345|DATE:2024-01-01|TOTAL:1234.56'
|
|
285
|
+
invoice = new_invoice(qr_code: qr_data)
|
|
286
|
+
invoice.line_items << LineItem.new(price: 1234.56, quantity: 1, description: 'Service')
|
|
287
|
+
|
|
288
|
+
pdf_string = invoice.render_pdf
|
|
289
|
+
expect(pdf_string).to be_a(String)
|
|
290
|
+
expect(pdf_string.bytesize).to be > 0
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
it 'renders invoice without QR code when qr_code is nil' do # rubocop:todo RSpec/MultipleExpectations
|
|
294
|
+
invoice = new_invoice(qr_code: nil)
|
|
295
|
+
invoice.line_items << LineItem.new(price: 20, quantity: 1, description: 'Test Item')
|
|
296
|
+
|
|
297
|
+
pdf_string = invoice.render_pdf
|
|
298
|
+
expect(pdf_string).to be_a(String)
|
|
299
|
+
expect(pdf_string.bytesize).to be > 0
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
it 'renders invoice without QR code when qr_code is blank' do # rubocop:todo RSpec/MultipleExpectations
|
|
303
|
+
invoice = new_invoice(qr_code: ' ')
|
|
304
|
+
invoice.line_items << LineItem.new(price: 20, quantity: 1, description: 'Test Item')
|
|
305
|
+
|
|
306
|
+
pdf_string = invoice.render_pdf
|
|
307
|
+
expect(pdf_string).to be_a(String)
|
|
308
|
+
expect(pdf_string.bytesize).to be > 0
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
312
|
+
it 'renders invoice with QR code and notes' do
|
|
313
|
+
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
314
|
+
invoice = new_invoice(
|
|
315
|
+
notes: 'Scan the QR code below to verify this invoice.',
|
|
316
|
+
qr_code: 'https://example.com/verify/12345'
|
|
317
|
+
)
|
|
318
|
+
invoice.line_items << LineItem.new(price: 100, quantity: 1, description: 'Consulting')
|
|
319
|
+
|
|
320
|
+
pdf_string = invoice.render_pdf
|
|
321
|
+
expect(pdf_string).to be_a(String)
|
|
322
|
+
expect(pdf_string.bytesize).to be > 0
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
326
|
+
it 'renders invoice with QR code but without notes' do
|
|
327
|
+
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
328
|
+
invoice = new_invoice(
|
|
329
|
+
notes: nil,
|
|
330
|
+
qr_code: 'https://example.com/verify/12345'
|
|
331
|
+
)
|
|
332
|
+
invoice.line_items << LineItem.new(price: 100, quantity: 1, description: 'Consulting')
|
|
333
|
+
|
|
334
|
+
pdf_string = invoice.render_pdf
|
|
335
|
+
expect(pdf_string).to be_a(String)
|
|
336
|
+
expect(pdf_string.bytesize).to be > 0
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
340
|
+
it 'is able to be initialized with qr_code in options hash' do
|
|
341
|
+
# rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
342
|
+
i = described_class.new(
|
|
343
|
+
invoice_number: 20,
|
|
344
|
+
qr_code: 'https://example.com/verify/20'
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
expect(i.invoice_number).to eq(20)
|
|
348
|
+
expect(i.qr_code).to eq('https://example.com/verify/20')
|
|
349
|
+
end
|
|
350
|
+
end
|
|
351
|
+
|
|
247
352
|
def new_invoice(params = {})
|
|
248
353
|
default_params = {
|
|
249
354
|
tax_rate: 0.1,
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webtranslateit-payday
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alan Johnson
|
|
8
8
|
- Edouard Briere
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -130,6 +130,26 @@ dependencies:
|
|
|
130
130
|
- - "<"
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
132
|
version: '1'
|
|
133
|
+
- !ruby/object:Gem::Dependency
|
|
134
|
+
name: rqrcode
|
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - "~>"
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: '2.0'
|
|
140
|
+
- - "<"
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '3'
|
|
143
|
+
type: :runtime
|
|
144
|
+
prerelease: false
|
|
145
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - "~>"
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '2.0'
|
|
150
|
+
- - "<"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '3'
|
|
133
153
|
- !ruby/object:Gem::Dependency
|
|
134
154
|
name: zeitwerk
|
|
135
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -193,6 +213,7 @@ files:
|
|
|
193
213
|
- lib/payday/pdf_renderer.rb
|
|
194
214
|
- payday.gemspec
|
|
195
215
|
- spec/assets/default_logo.png
|
|
216
|
+
- spec/assets/example_invoice_with_qr.pdf
|
|
196
217
|
- spec/assets/svg.pdf
|
|
197
218
|
- spec/assets/testing.pdf
|
|
198
219
|
- spec/assets/testing_es.pdf
|
|
@@ -222,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
222
243
|
- !ruby/object:Gem::Version
|
|
223
244
|
version: '0'
|
|
224
245
|
requirements: []
|
|
225
|
-
rubygems_version: 3.6.
|
|
246
|
+
rubygems_version: 3.6.9
|
|
226
247
|
specification_version: 4
|
|
227
248
|
summary: A simple library for rendering invoices.
|
|
228
249
|
test_files: []
|