webtranslateit-payday 1.7.2 → 1.7.4
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/.github/workflows/release-drafter.yml +1 -6
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +73 -49
- data/config/locales/payday.de.yml +1 -0
- data/config/locales/payday.en.yml +1 -0
- data/config/locales/payday.es.yml +1 -0
- data/config/locales/payday.fr.yml +1 -0
- data/config/locales/payday.nl.yml +1 -0
- data/config/locales/payday.zh-CN.yml +1 -0
- data/lib/generators/payday/setup/templates/migration.rb +3 -0
- data/lib/payday/invoice.rb +11 -3
- data/lib/payday/invoiceable.rb +11 -1
- data/lib/payday/pdf_renderer.rb +23 -2
- data/payday.gemspec +2 -2
- data/spec/invoice_spec.rb +35 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 655aa13a2a0c729008a5bce34e5e8de25b5fafd1f3e571995addf916413f74f8
|
|
4
|
+
data.tar.gz: 7d78b88d6886fbfceb45377b0c25c3cdbc6b3886a33003460cc2f68490004f0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 36a5311dd8d6858c70a8b00a47bc675beb3de3c72827e0b5eb330f7113566051723dfa1f9cdbe636d745363bd02b3458e861803c2d0f481e7269805ae0c2d95e
|
|
7
|
+
data.tar.gz: 5342f87b7e7d2568bc50141463557e8929ae1f678cdbdfb7776cdeb560fdaf215bd8b4f7b4fa8588b861befe38330225777a94783af558434ab671f3440cb2f7
|
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.2', '3.3', '3.4']
|
|
17
|
+
ruby-version: ['3.2', '3.3', '3.4', '4.0']
|
|
18
18
|
|
|
19
19
|
steps:
|
|
20
|
-
- uses: actions/checkout@
|
|
20
|
+
- uses: actions/checkout@v7
|
|
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):
|
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
|
|
36
36
|
steps:
|
|
37
37
|
- name: Checkout repository
|
|
38
|
-
uses: actions/checkout@
|
|
38
|
+
uses: actions/checkout@v7
|
|
39
39
|
|
|
40
40
|
- name: Install ruby and gems
|
|
41
41
|
uses: ruby/setup-ruby@v1
|
|
@@ -5,11 +5,6 @@ on:
|
|
|
5
5
|
# branches to consider in the event; optional, defaults to all
|
|
6
6
|
branches:
|
|
7
7
|
- main
|
|
8
|
-
# pull_request event is required only for autolabeler
|
|
9
|
-
pull_request:
|
|
10
|
-
# Only following types are handled by the action, but one can default to all as well
|
|
11
|
-
types: [opened, reopened, synchronize]
|
|
12
|
-
|
|
13
8
|
jobs:
|
|
14
9
|
update_release_draft:
|
|
15
10
|
runs-on: ubuntu-latest
|
|
@@ -20,7 +15,7 @@ jobs:
|
|
|
20
15
|
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
|
|
21
16
|
|
|
22
17
|
# Drafts your next Release notes as Pull Requests are merged into "master"
|
|
23
|
-
- uses: release-drafter/release-drafter@
|
|
18
|
+
- uses: release-drafter/release-drafter@v7
|
|
24
19
|
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
|
|
25
20
|
# with:
|
|
26
21
|
# config-name: my-config.yml
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 1.7.4 (2026-08-13)
|
|
4
|
+
|
|
5
|
+
* Pass `enable_web_requests: false` when rendering SVG logos. Logos are read from local files, so nothing needs fetching over the network. This silences prawn-svg's deprecation warning and keeps behaviour stable when prawn-svg 1.0 flips the default to `false`.
|
|
6
|
+
|
|
7
|
+
## 1.7.3 (2026-02-16)
|
|
8
|
+
|
|
9
|
+
* Add retention support (e.g. Spanish IRPF). Set `retention_rate` on an invoice to apply a post-tax deduction calculated as a percentage of the subtotal. The retention amount is displayed as a negative line in the PDF and subtracted from the total. Customize the label with `retention_description` or via the `payday.invoice.retention` i18n key.
|
|
10
|
+
|
|
3
11
|
## 1.7.1 (2025-12-01)
|
|
4
12
|
|
|
5
13
|
* Relax dependency on rqrcode.
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
webtranslateit-payday (1.7.
|
|
4
|
+
webtranslateit-payday (1.7.4)
|
|
5
5
|
activesupport (>= 7, < 9)
|
|
6
6
|
i18n (~> 1.12, < 2)
|
|
7
7
|
money (>= 6.16, < 8.0)
|
|
@@ -14,44 +14,53 @@ PATH
|
|
|
14
14
|
GEM
|
|
15
15
|
remote: https://rubygems.org/
|
|
16
16
|
specs:
|
|
17
|
-
activesupport (
|
|
17
|
+
activesupport (8.1.3.1)
|
|
18
18
|
base64
|
|
19
|
-
benchmark (>= 0.3)
|
|
20
19
|
bigdecimal
|
|
21
20
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
22
21
|
connection_pool (>= 2.2.5)
|
|
23
22
|
drb
|
|
24
23
|
i18n (>= 1.6, < 2)
|
|
24
|
+
json
|
|
25
25
|
logger (>= 1.4.2)
|
|
26
26
|
minitest (>= 5.1)
|
|
27
27
|
securerandom (>= 0.3)
|
|
28
28
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
uri (>= 0.13.1)
|
|
30
|
+
addressable (2.9.0)
|
|
31
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
31
32
|
ast (2.4.3)
|
|
32
33
|
base64 (0.3.0)
|
|
33
|
-
benchmark (0.5.0)
|
|
34
34
|
bigdecimal (3.3.1)
|
|
35
35
|
chunky_png (1.4.0)
|
|
36
36
|
coderay (1.1.3)
|
|
37
|
-
concurrent-ruby (1.3.
|
|
38
|
-
connection_pool (
|
|
39
|
-
css_parser (1.
|
|
37
|
+
concurrent-ruby (1.3.8)
|
|
38
|
+
connection_pool (3.0.2)
|
|
39
|
+
css_parser (1.22.0)
|
|
40
40
|
addressable
|
|
41
41
|
diff-lcs (1.6.2)
|
|
42
42
|
drb (2.2.3)
|
|
43
|
-
ffi (1.17.
|
|
44
|
-
ffi (1.17.
|
|
45
|
-
ffi (1.17.
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
ffi (1.17.4)
|
|
44
|
+
ffi (1.17.4-aarch64-linux-gnu)
|
|
45
|
+
ffi (1.17.4-aarch64-linux-musl)
|
|
46
|
+
ffi (1.17.4-aarch64-mingw-ucrt)
|
|
47
|
+
ffi (1.17.4-arm-linux-gnu)
|
|
48
|
+
ffi (1.17.4-arm-linux-musl)
|
|
49
|
+
ffi (1.17.4-arm64-darwin)
|
|
50
|
+
ffi (1.17.4-x86-linux-gnu)
|
|
51
|
+
ffi (1.17.4-x86-linux-musl)
|
|
52
|
+
ffi (1.17.4-x86_64-darwin)
|
|
53
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
54
|
+
ffi (1.17.4-x86_64-linux-musl)
|
|
55
|
+
formatador (1.2.3)
|
|
56
|
+
reline
|
|
57
|
+
guard (2.20.2)
|
|
48
58
|
formatador (>= 0.2.4)
|
|
49
59
|
listen (>= 2.7, < 4.0)
|
|
50
60
|
logger (~> 1.6)
|
|
51
61
|
lumberjack (>= 1.0.12, < 2.0)
|
|
52
62
|
nenv (~> 0.1)
|
|
53
63
|
notiffany (~> 0.0)
|
|
54
|
-
ostruct (~> 0.6)
|
|
55
64
|
pry (>= 0.13.0)
|
|
56
65
|
shellany (~> 0.0)
|
|
57
66
|
thor (>= 0.18.1)
|
|
@@ -63,29 +72,32 @@ GEM
|
|
|
63
72
|
guard-rubocop (1.5.0)
|
|
64
73
|
guard (~> 2.0)
|
|
65
74
|
rubocop (< 2.0)
|
|
66
|
-
i18n (1.
|
|
75
|
+
i18n (1.15.2)
|
|
67
76
|
concurrent-ruby (~> 1.0)
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
io-console (0.8.2)
|
|
78
|
+
json (2.21.2)
|
|
79
|
+
language_server-protocol (3.17.0.6)
|
|
70
80
|
lint_roller (1.1.0)
|
|
71
|
-
listen (3.
|
|
81
|
+
listen (3.10.0)
|
|
82
|
+
logger
|
|
72
83
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
73
84
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
74
85
|
logger (1.7.0)
|
|
75
|
-
lumberjack (1.2
|
|
86
|
+
lumberjack (1.4.2)
|
|
76
87
|
matrix (0.4.3)
|
|
77
88
|
method_source (1.1.0)
|
|
78
|
-
minitest (
|
|
79
|
-
|
|
89
|
+
minitest (6.0.6)
|
|
90
|
+
drb (~> 2.0)
|
|
91
|
+
prism (~> 1.5)
|
|
92
|
+
money (7.1.1)
|
|
80
93
|
bigdecimal
|
|
81
94
|
i18n (~> 1.9)
|
|
82
95
|
nenv (0.3.0)
|
|
83
96
|
notiffany (0.1.3)
|
|
84
97
|
nenv (~> 0.1)
|
|
85
98
|
shellany (~> 0.0)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
parser (3.3.10.0)
|
|
99
|
+
parallel (1.28.0)
|
|
100
|
+
parser (3.3.12.0)
|
|
89
101
|
ast (~> 2.4.1)
|
|
90
102
|
racc
|
|
91
103
|
pdf-core (0.10.0)
|
|
@@ -93,29 +105,32 @@ GEM
|
|
|
93
105
|
matrix (~> 0.4)
|
|
94
106
|
pdf-core (~> 0.10.0)
|
|
95
107
|
ttfunk (~> 1.8)
|
|
96
|
-
prawn-svg (0.
|
|
97
|
-
css_parser (
|
|
108
|
+
prawn-svg (0.40.3)
|
|
109
|
+
css_parser (>= 1.17.1, < 4)
|
|
98
110
|
matrix (~> 0.4.2)
|
|
99
111
|
prawn (>= 0.11.1, < 3)
|
|
100
112
|
rexml (>= 3.4.2, < 4)
|
|
101
113
|
prawn-table (0.2.2)
|
|
102
114
|
prawn (>= 1.3.0, < 3.0.0)
|
|
103
|
-
prism (1.
|
|
104
|
-
pry (0.
|
|
115
|
+
prism (1.9.0)
|
|
116
|
+
pry (0.16.0)
|
|
105
117
|
coderay (~> 1.1)
|
|
106
118
|
method_source (~> 1.0)
|
|
107
|
-
|
|
119
|
+
reline (>= 0.6.0)
|
|
120
|
+
public_suffix (7.0.5)
|
|
108
121
|
racc (1.8.1)
|
|
109
122
|
rainbow (3.1.1)
|
|
110
123
|
rb-fsevent (0.11.2)
|
|
111
124
|
rb-inotify (0.11.1)
|
|
112
125
|
ffi (~> 1.0)
|
|
113
|
-
regexp_parser (2.
|
|
126
|
+
regexp_parser (2.12.0)
|
|
127
|
+
reline (0.6.3)
|
|
128
|
+
io-console (~> 0.5)
|
|
114
129
|
rexml (3.4.4)
|
|
115
|
-
rqrcode (3.
|
|
130
|
+
rqrcode (3.2.0)
|
|
116
131
|
chunky_png (~> 1.0)
|
|
117
132
|
rqrcode_core (~> 2.0)
|
|
118
|
-
rqrcode_core (2.0
|
|
133
|
+
rqrcode_core (2.1.0)
|
|
119
134
|
rspec (3.13.2)
|
|
120
135
|
rspec-core (~> 3.13.0)
|
|
121
136
|
rspec-expectations (~> 3.13.0)
|
|
@@ -129,47 +144,56 @@ GEM
|
|
|
129
144
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
130
145
|
rspec-support (~> 3.13.0)
|
|
131
146
|
rspec-support (3.13.6)
|
|
132
|
-
rubocop (1.
|
|
147
|
+
rubocop (1.89.0)
|
|
133
148
|
json (~> 2.3)
|
|
134
149
|
language_server-protocol (~> 3.17.0.2)
|
|
135
150
|
lint_roller (~> 1.1.0)
|
|
136
|
-
parallel (
|
|
151
|
+
parallel (>= 1.10)
|
|
137
152
|
parser (>= 3.3.0.2)
|
|
138
153
|
rainbow (>= 2.2.2, < 4.0)
|
|
139
154
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
140
|
-
rubocop-ast (>= 1.
|
|
155
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
141
156
|
ruby-progressbar (~> 1.7)
|
|
142
157
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
143
|
-
rubocop-ast (1.
|
|
158
|
+
rubocop-ast (1.50.0)
|
|
144
159
|
parser (>= 3.3.7.2)
|
|
145
|
-
prism (~> 1.
|
|
160
|
+
prism (~> 1.7)
|
|
146
161
|
rubocop-performance (1.26.1)
|
|
147
162
|
lint_roller (~> 1.1)
|
|
148
163
|
rubocop (>= 1.75.0, < 2.0)
|
|
149
164
|
rubocop-ast (>= 1.47.1, < 2.0)
|
|
150
|
-
rubocop-rspec (3.
|
|
165
|
+
rubocop-rspec (3.10.2)
|
|
151
166
|
lint_roller (~> 1.1)
|
|
152
|
-
|
|
167
|
+
regexp_parser (>= 2.0)
|
|
168
|
+
rubocop (~> 1.86, >= 1.86.2)
|
|
153
169
|
ruby-progressbar (1.13.0)
|
|
154
170
|
securerandom (0.4.1)
|
|
155
171
|
shellany (0.0.1)
|
|
156
|
-
thor (1.
|
|
172
|
+
thor (1.5.0)
|
|
157
173
|
ttfunk (1.8.0)
|
|
158
174
|
bigdecimal (~> 3.1)
|
|
159
175
|
tzinfo (2.0.6)
|
|
160
176
|
concurrent-ruby (~> 1.0)
|
|
161
177
|
unicode-display_width (3.2.0)
|
|
162
178
|
unicode-emoji (~> 4.1)
|
|
163
|
-
unicode-emoji (4.
|
|
164
|
-
|
|
179
|
+
unicode-emoji (4.2.0)
|
|
180
|
+
uri (1.1.1)
|
|
181
|
+
zeitwerk (2.8.3)
|
|
165
182
|
|
|
166
183
|
PLATFORMS
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
184
|
+
aarch64-linux-gnu
|
|
185
|
+
aarch64-linux-musl
|
|
186
|
+
aarch64-mingw-ucrt
|
|
187
|
+
arm-linux-gnu
|
|
188
|
+
arm-linux-musl
|
|
189
|
+
arm64-darwin
|
|
190
|
+
ruby
|
|
191
|
+
x86-linux-gnu
|
|
192
|
+
x86-linux-musl
|
|
193
|
+
x86_64-darwin
|
|
172
194
|
x86_64-linux
|
|
195
|
+
x86_64-linux-gnu
|
|
196
|
+
x86_64-linux-musl
|
|
173
197
|
|
|
174
198
|
DEPENDENCIES
|
|
175
199
|
guard
|
|
@@ -183,4 +207,4 @@ DEPENDENCIES
|
|
|
183
207
|
webtranslateit-payday!
|
|
184
208
|
|
|
185
209
|
BUNDLED WITH
|
|
186
|
-
|
|
210
|
+
4.0.18
|
|
@@ -4,6 +4,9 @@ class CreatePaydayTables < ActiveRecord::Migration
|
|
|
4
4
|
# invoices will work without anything but bill_to, but there are quite a few options for the fields you can save, like ship_to
|
|
5
5
|
# due_at, refunded_at, and paid_at
|
|
6
6
|
t.string :bill_to
|
|
7
|
+
t.decimal :tax_rate
|
|
8
|
+
t.decimal :shipping_rate
|
|
9
|
+
t.decimal :retention_rate
|
|
7
10
|
|
|
8
11
|
t.timestamps
|
|
9
12
|
end
|
data/lib/payday/invoice.rb
CHANGED
|
@@ -8,10 +8,10 @@ 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,
|
|
12
|
-
:qr_code
|
|
11
|
+
:tax_description, :retention_description, :due_at, :paid_at, :refunded_at, :currency,
|
|
12
|
+
:invoice_details, :invoice_date, :qr_code
|
|
13
13
|
|
|
14
|
-
attr_reader :tax_rate, :shipping_rate
|
|
14
|
+
attr_reader :tax_rate, :shipping_rate, :retention_rate
|
|
15
15
|
|
|
16
16
|
# rubocop:todo Metrics/PerceivedComplexity
|
|
17
17
|
# rubocop:todo Metrics/MethodLength
|
|
@@ -26,6 +26,8 @@ module Payday
|
|
|
26
26
|
self.shipping_description = options[:shipping_description] || nil
|
|
27
27
|
self.tax_rate = options[:tax_rate] || nil
|
|
28
28
|
self.tax_description = options[:tax_description] || nil
|
|
29
|
+
self.retention_rate = options[:retention_rate] || nil
|
|
30
|
+
self.retention_description = options[:retention_description] || nil
|
|
29
31
|
self.due_at = options[:due_at] || nil
|
|
30
32
|
self.paid_at = options[:paid_at] || nil
|
|
31
33
|
self.refunded_at = options[:refunded_at] || nil
|
|
@@ -50,6 +52,12 @@ module Payday
|
|
|
50
52
|
@shipping_rate = BigDecimal(value.to_s)
|
|
51
53
|
end
|
|
52
54
|
|
|
55
|
+
# Retention rate (e.g. IRPF). Applied as a percentage of the subtotal and deducted from the total.
|
|
56
|
+
def retention_rate=(value)
|
|
57
|
+
value = 0 if value.to_s.blank?
|
|
58
|
+
@retention_rate = BigDecimal(value.to_s)
|
|
59
|
+
end
|
|
60
|
+
|
|
53
61
|
# Adds a line item
|
|
54
62
|
def add_line_item(options = {})
|
|
55
63
|
line_items << Payday::LineItem.new(options)
|
data/lib/payday/invoiceable.rb
CHANGED
|
@@ -49,9 +49,19 @@ module Payday
|
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
+
# Calculates the retention (e.g. IRPF) as a percentage of the subtotal.
|
|
53
|
+
# This is a post-tax deduction subtracted from the total.
|
|
54
|
+
def retention
|
|
55
|
+
if defined?(retention_rate)
|
|
56
|
+
subtotal * retention_rate / 100
|
|
57
|
+
else
|
|
58
|
+
0
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
52
62
|
# Calculates the total for this invoice.
|
|
53
63
|
def total
|
|
54
|
-
subtotal + tax + shipping
|
|
64
|
+
subtotal + tax + shipping - retention
|
|
55
65
|
end
|
|
56
66
|
|
|
57
67
|
def overdue?
|
data/lib/payday/pdf_renderer.rb
CHANGED
|
@@ -80,7 +80,11 @@ module Payday
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
if File.extname(image) == '.svg'
|
|
83
|
-
|
|
83
|
+
# Logos are read from local files, so there is nothing to fetch over the network.
|
|
84
|
+
# Passing this explicitly also silences prawn-svg's deprecation warning and keeps
|
|
85
|
+
# behaviour stable when prawn-svg 1.0 flips the default to false.
|
|
86
|
+
logo_info = pdf.svg(File.read(image), at: pdf.bounds.top_left, width: width, height: height,
|
|
87
|
+
enable_web_requests: false)
|
|
84
88
|
logo_height = logo_info[:height]
|
|
85
89
|
else
|
|
86
90
|
logo_info = pdf.image(image, at: pdf.bounds.top_left, width: width, height: height)
|
|
@@ -223,8 +227,9 @@ module Payday
|
|
|
223
227
|
end
|
|
224
228
|
# rubocop:enable Metrics/MethodLength
|
|
225
229
|
|
|
230
|
+
# rubocop:todo Metrics/PerceivedComplexity
|
|
226
231
|
# rubocop:todo Metrics/MethodLength
|
|
227
|
-
def self.totals_lines(invoice, pdf) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
|
232
|
+
def self.totals_lines(invoice, pdf) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
228
233
|
table_data = []
|
|
229
234
|
table_data << [
|
|
230
235
|
bold_cell(pdf, I18n.t('payday.invoice.subtotal', default: 'Subtotal:')),
|
|
@@ -255,6 +260,21 @@ module Payday
|
|
|
255
260
|
align: :right)
|
|
256
261
|
]
|
|
257
262
|
end
|
|
263
|
+
|
|
264
|
+
if invoice.retention_rate.positive?
|
|
265
|
+
retention_description = if invoice.retention_description.nil?
|
|
266
|
+
I18n.t('payday.invoice.retention', default: 'Retention:')
|
|
267
|
+
else
|
|
268
|
+
invoice.retention_description
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
table_data << [
|
|
272
|
+
bold_cell(pdf, retention_description),
|
|
273
|
+
cell(pdf, number_to_currency(-invoice.retention, invoice),
|
|
274
|
+
align: :right)
|
|
275
|
+
]
|
|
276
|
+
end
|
|
277
|
+
|
|
258
278
|
table_data << [
|
|
259
279
|
bold_cell(pdf, I18n.t('payday.invoice.total', default: 'Total:'),
|
|
260
280
|
size: 12),
|
|
@@ -268,6 +288,7 @@ module Payday
|
|
|
268
288
|
end
|
|
269
289
|
end
|
|
270
290
|
# rubocop:enable Metrics/MethodLength
|
|
291
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
|
271
292
|
|
|
272
293
|
def self.notes(invoice, pdf) # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
|
273
294
|
return unless defined?(invoice.notes) && invoice.notes
|
data/payday.gemspec
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = 'webtranslateit-payday'
|
|
5
|
-
s.version = '1.7.
|
|
6
|
-
s.required_ruby_version = '>= 3.
|
|
5
|
+
s.version = '1.7.4'
|
|
6
|
+
s.required_ruby_version = '>= 3.2'
|
|
7
7
|
s.platform = Gem::Platform::RUBY
|
|
8
8
|
s.authors = ['Alan Johnson', 'Edouard Briere']
|
|
9
9
|
s.email = ['edouard@webtranslateit.com']
|
data/spec/invoice_spec.rb
CHANGED
|
@@ -75,6 +75,41 @@ module Payday # rubocop:todo Metrics/ModuleLength
|
|
|
75
75
|
expect(i.total).to eq(BigDecimal(1243))
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
+
it 'returns zero retention when no retention_rate is set' do
|
|
79
|
+
i = described_class.new
|
|
80
|
+
i.line_items << LineItem.new(price: 100, quantity: 1, description: 'Service')
|
|
81
|
+
|
|
82
|
+
expect(i.retention).to eq(BigDecimal(0))
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'calculates retention correctly as a percentage of the subtotal' do
|
|
86
|
+
i = described_class.new(retention_rate: 15.0)
|
|
87
|
+
i.line_items << LineItem.new(price: 200, quantity: 5, description: 'Service')
|
|
88
|
+
|
|
89
|
+
expect(i.retention).to eq(BigDecimal(150))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# rubocop:todo RSpec/MultipleExpectations
|
|
93
|
+
it 'calculates total with retention deducted (IRPF example: 500 + 21% VAT - 19% IRPF = 510)' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
|
94
|
+
# rubocop:enable RSpec/MultipleExpectations
|
|
95
|
+
i = described_class.new(tax_rate: 21.0, retention_rate: 19.0)
|
|
96
|
+
i.line_items << LineItem.new(price: 500, quantity: 1, description: 'Consulting')
|
|
97
|
+
|
|
98
|
+
expect(i.subtotal).to eq(BigDecimal(500))
|
|
99
|
+
expect(i.tax).to eq(BigDecimal(105))
|
|
100
|
+
expect(i.retention).to eq(BigDecimal(95))
|
|
101
|
+
expect(i.total).to eq(BigDecimal(510))
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'calculates total with tax, shipping, and retention combined' do
|
|
105
|
+
i = described_class.new(tax_rate: 10.0, shipping_rate: 20, retention_rate: 5.0)
|
|
106
|
+
i.line_items << LineItem.new(price: 100, quantity: 10, description: 'Widgets')
|
|
107
|
+
|
|
108
|
+
# subtotal: 1000, tax: 100, shipping: 20, retention: 50
|
|
109
|
+
# total: 1000 + 100 + 20 - 50 = 1070
|
|
110
|
+
expect(i.total).to eq(BigDecimal(1070))
|
|
111
|
+
end
|
|
112
|
+
|
|
78
113
|
it "is overdue when it's past date and unpaid" do
|
|
79
114
|
i = described_class.new(due_at: Date.today - 1)
|
|
80
115
|
expect(i.overdue?).to be(true)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: webtranslateit-payday
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.
|
|
4
|
+
version: 1.7.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alan Johnson
|
|
@@ -236,14 +236,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
236
236
|
requirements:
|
|
237
237
|
- - ">="
|
|
238
238
|
- !ruby/object:Gem::Version
|
|
239
|
-
version: '3.
|
|
239
|
+
version: '3.2'
|
|
240
240
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
241
|
requirements:
|
|
242
242
|
- - ">="
|
|
243
243
|
- !ruby/object:Gem::Version
|
|
244
244
|
version: '0'
|
|
245
245
|
requirements: []
|
|
246
|
-
rubygems_version:
|
|
246
|
+
rubygems_version: 4.0.16
|
|
247
247
|
specification_version: 4
|
|
248
248
|
summary: A simple library for rendering invoices.
|
|
249
249
|
test_files: []
|