webtranslateit-payday 1.6.8 → 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 +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +68 -51
- data/README.md +16 -0
- data/lib/payday/invoice.rb +3 -1
- data/lib/payday/pdf_renderer.rb +17 -2
- data/payday.gemspec +3 -2
- data/spec/assets/example_invoice_with_qr.pdf +0 -0
- data/spec/invoice_spec.rb +105 -0
- metadata +26 -8
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
|
@@ -14,10 +14,10 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
strategy:
|
|
16
16
|
matrix:
|
|
17
|
-
ruby-version: ['3.
|
|
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.
|
|
5
|
-
activesupport (
|
|
4
|
+
webtranslateit-payday (1.7.0)
|
|
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,27 +28,30 @@ 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
|
-
concurrent-ruby (1.3.
|
|
36
|
-
connection_pool (2.4
|
|
37
|
-
css_parser (1.
|
|
37
|
+
concurrent-ruby (1.3.5)
|
|
38
|
+
connection_pool (2.5.4)
|
|
39
|
+
css_parser (1.21.1)
|
|
38
40
|
addressable
|
|
39
|
-
diff-lcs (1.
|
|
40
|
-
drb (2.2.
|
|
41
|
-
ffi (1.17.
|
|
42
|
-
ffi (1.17.
|
|
43
|
-
ffi (1.17.
|
|
41
|
+
diff-lcs (1.6.2)
|
|
42
|
+
drb (2.2.3)
|
|
43
|
+
ffi (1.17.1-arm64-darwin)
|
|
44
|
+
ffi (1.17.1-x86_64-darwin)
|
|
45
|
+
ffi (1.17.1-x86_64-linux-gnu)
|
|
44
46
|
formatador (1.1.0)
|
|
45
|
-
guard (2.19.
|
|
47
|
+
guard (2.19.1)
|
|
46
48
|
formatador (>= 0.2.4)
|
|
47
49
|
listen (>= 2.7, < 4.0)
|
|
50
|
+
logger (~> 1.6)
|
|
48
51
|
lumberjack (>= 1.0.12, < 2.0)
|
|
49
52
|
nenv (~> 0.1)
|
|
50
53
|
notiffany (~> 0.0)
|
|
54
|
+
ostruct (~> 0.6)
|
|
51
55
|
pry (>= 0.13.0)
|
|
52
56
|
shellany (~> 0.0)
|
|
53
57
|
thor (>= 0.18.1)
|
|
@@ -59,26 +63,28 @@ GEM
|
|
|
59
63
|
guard-rubocop (1.5.0)
|
|
60
64
|
guard (~> 2.0)
|
|
61
65
|
rubocop (< 2.0)
|
|
62
|
-
i18n (1.14.
|
|
66
|
+
i18n (1.14.7)
|
|
63
67
|
concurrent-ruby (~> 1.0)
|
|
64
|
-
json (2.
|
|
65
|
-
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)
|
|
66
71
|
listen (3.9.0)
|
|
67
72
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
68
73
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
69
|
-
logger (1.
|
|
74
|
+
logger (1.7.0)
|
|
70
75
|
lumberjack (1.2.10)
|
|
71
|
-
matrix (0.4.
|
|
76
|
+
matrix (0.4.3)
|
|
72
77
|
method_source (1.1.0)
|
|
73
|
-
minitest (5.
|
|
78
|
+
minitest (5.26.0)
|
|
74
79
|
money (6.19.0)
|
|
75
80
|
i18n (>= 0.6.4, <= 2)
|
|
76
81
|
nenv (0.3.0)
|
|
77
82
|
notiffany (0.1.3)
|
|
78
83
|
nenv (~> 0.1)
|
|
79
84
|
shellany (~> 0.0)
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
ostruct (0.6.1)
|
|
86
|
+
parallel (1.27.0)
|
|
87
|
+
parser (3.3.10.0)
|
|
82
88
|
ast (~> 2.4.1)
|
|
83
89
|
racc
|
|
84
90
|
pdf-core (0.10.0)
|
|
@@ -86,63 +92,74 @@ GEM
|
|
|
86
92
|
matrix (~> 0.4)
|
|
87
93
|
pdf-core (~> 0.10.0)
|
|
88
94
|
ttfunk (~> 1.8)
|
|
89
|
-
prawn-svg (0.
|
|
95
|
+
prawn-svg (0.38.1)
|
|
90
96
|
css_parser (~> 1.6)
|
|
91
97
|
matrix (~> 0.4.2)
|
|
92
98
|
prawn (>= 0.11.1, < 3)
|
|
93
|
-
rexml (>= 3.2
|
|
99
|
+
rexml (>= 3.4.2, < 4)
|
|
94
100
|
prawn-table (0.2.2)
|
|
95
101
|
prawn (>= 1.3.0, < 3.0.0)
|
|
96
|
-
|
|
102
|
+
prism (1.6.0)
|
|
103
|
+
pry (0.15.2)
|
|
97
104
|
coderay (~> 1.1)
|
|
98
105
|
method_source (~> 1.0)
|
|
99
|
-
public_suffix (6.0.
|
|
106
|
+
public_suffix (6.0.2)
|
|
100
107
|
racc (1.8.1)
|
|
101
108
|
rainbow (3.1.1)
|
|
102
109
|
rb-fsevent (0.11.2)
|
|
103
110
|
rb-inotify (0.11.1)
|
|
104
111
|
ffi (~> 1.0)
|
|
105
|
-
regexp_parser (2.
|
|
106
|
-
rexml (3.
|
|
107
|
-
|
|
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)
|
|
108
119
|
rspec-core (~> 3.13.0)
|
|
109
120
|
rspec-expectations (~> 3.13.0)
|
|
110
121
|
rspec-mocks (~> 3.13.0)
|
|
111
|
-
rspec-core (3.13.
|
|
122
|
+
rspec-core (3.13.6)
|
|
112
123
|
rspec-support (~> 3.13.0)
|
|
113
|
-
rspec-expectations (3.13.
|
|
124
|
+
rspec-expectations (3.13.5)
|
|
114
125
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
115
126
|
rspec-support (~> 3.13.0)
|
|
116
|
-
rspec-mocks (3.13.
|
|
127
|
+
rspec-mocks (3.13.6)
|
|
117
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
118
129
|
rspec-support (~> 3.13.0)
|
|
119
|
-
rspec-support (3.13.
|
|
120
|
-
rubocop (1.
|
|
130
|
+
rspec-support (3.13.6)
|
|
131
|
+
rubocop (1.81.7)
|
|
121
132
|
json (~> 2.3)
|
|
122
|
-
language_server-protocol (
|
|
133
|
+
language_server-protocol (~> 3.17.0.2)
|
|
134
|
+
lint_roller (~> 1.1.0)
|
|
123
135
|
parallel (~> 1.10)
|
|
124
136
|
parser (>= 3.3.0.2)
|
|
125
137
|
rainbow (>= 2.2.2, < 4.0)
|
|
126
|
-
regexp_parser (>= 2.
|
|
127
|
-
rubocop-ast (>= 1.
|
|
138
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
139
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
128
140
|
ruby-progressbar (~> 1.7)
|
|
129
|
-
unicode-display_width (>= 2.4.0, <
|
|
130
|
-
rubocop-ast (1.
|
|
131
|
-
parser (>= 3.3.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
rubocop (
|
|
141
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
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)
|
|
137
152
|
ruby-progressbar (1.13.0)
|
|
138
|
-
securerandom (0.
|
|
153
|
+
securerandom (0.4.1)
|
|
139
154
|
shellany (0.0.1)
|
|
140
155
|
thor (1.3.2)
|
|
141
156
|
ttfunk (1.8.0)
|
|
142
157
|
bigdecimal (~> 3.1)
|
|
143
158
|
tzinfo (2.0.6)
|
|
144
159
|
concurrent-ruby (~> 1.0)
|
|
145
|
-
unicode-display_width (2.
|
|
160
|
+
unicode-display_width (3.2.0)
|
|
161
|
+
unicode-emoji (~> 4.1)
|
|
162
|
+
unicode-emoji (4.1.0)
|
|
146
163
|
zeitwerk (2.7.1)
|
|
147
164
|
|
|
148
165
|
PLATFORMS
|
|
@@ -158,11 +175,11 @@ DEPENDENCIES
|
|
|
158
175
|
guard-rspec
|
|
159
176
|
guard-rubocop
|
|
160
177
|
matrix
|
|
161
|
-
rspec (~> 3.13.
|
|
178
|
+
rspec (~> 3.13.2)
|
|
162
179
|
rubocop
|
|
163
180
|
rubocop-performance
|
|
164
181
|
rubocop-rspec
|
|
165
182
|
webtranslateit-payday!
|
|
166
183
|
|
|
167
184
|
BUNDLED WITH
|
|
168
|
-
2.
|
|
185
|
+
2.6.2
|
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']
|
|
@@ -12,12 +12,13 @@ Gem::Specification.new do |s|
|
|
|
12
12
|
s.description = 'Payday is a library for rendering invoices to pdf.'
|
|
13
13
|
s.license = 'MIT'
|
|
14
14
|
|
|
15
|
-
s.add_dependency 'activesupport', '
|
|
15
|
+
s.add_dependency 'activesupport', '>= 7', '< 9'
|
|
16
16
|
s.add_dependency 'i18n', '~> 1.12', '< 2'
|
|
17
17
|
s.add_dependency 'money', '~> 6.16', '< 7'
|
|
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,21 +1,20 @@
|
|
|
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
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: activesupport
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
16
|
requirements:
|
|
18
|
-
- - "
|
|
17
|
+
- - ">="
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
19
|
version: '7'
|
|
21
20
|
- - "<"
|
|
@@ -25,7 +24,7 @@ dependencies:
|
|
|
25
24
|
prerelease: false
|
|
26
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
26
|
requirements:
|
|
28
|
-
- - "
|
|
27
|
+
- - ">="
|
|
29
28
|
- !ruby/object:Gem::Version
|
|
30
29
|
version: '7'
|
|
31
30
|
- - "<"
|
|
@@ -131,6 +130,26 @@ dependencies:
|
|
|
131
130
|
- - "<"
|
|
132
131
|
- !ruby/object:Gem::Version
|
|
133
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'
|
|
134
153
|
- !ruby/object:Gem::Dependency
|
|
135
154
|
name: zeitwerk
|
|
136
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -194,6 +213,7 @@ files:
|
|
|
194
213
|
- lib/payday/pdf_renderer.rb
|
|
195
214
|
- payday.gemspec
|
|
196
215
|
- spec/assets/default_logo.png
|
|
216
|
+
- spec/assets/example_invoice_with_qr.pdf
|
|
197
217
|
- spec/assets/svg.pdf
|
|
198
218
|
- spec/assets/testing.pdf
|
|
199
219
|
- spec/assets/testing_es.pdf
|
|
@@ -209,7 +229,6 @@ licenses:
|
|
|
209
229
|
- MIT
|
|
210
230
|
metadata:
|
|
211
231
|
rubygems_mfa_required: 'true'
|
|
212
|
-
post_install_message:
|
|
213
232
|
rdoc_options: []
|
|
214
233
|
require_paths:
|
|
215
234
|
- lib
|
|
@@ -224,8 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
243
|
- !ruby/object:Gem::Version
|
|
225
244
|
version: '0'
|
|
226
245
|
requirements: []
|
|
227
|
-
rubygems_version: 3.
|
|
228
|
-
signing_key:
|
|
246
|
+
rubygems_version: 3.6.9
|
|
229
247
|
specification_version: 4
|
|
230
248
|
summary: A simple library for rendering invoices.
|
|
231
249
|
test_files: []
|