invoice_printer 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +37 -0
- data/Dockerfile +2 -2
- data/README.md +17 -2
- data/invoice_printer.gemspec +3 -3
- data/lib/invoice_printer/pdf_document.rb +21 -27
- data/lib/invoice_printer/version.rb +1 -1
- metadata +5 -5
- data/Gemfile.lock +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b35b038445eb5790a3241093f031314db880f037dbabd1800cff2a5548081ea
|
4
|
+
data.tar.gz: bd668a85987b9c72793724ce3a6d13d37478f7a747ae0d1e75f1b8a013809b6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e16688d404cc7097f773babe821c62ddf6d06b87e23a80b1454e87bc6299549521b2e3a9bed556d8e35370a1c78843f6eca192618d4dd66da9e143b17ab60b4
|
7
|
+
data.tar.gz: 81f49267c2b967d6b3ac9596d06e330e112bbfb5b8ac51fa200f958e41c1a3a9fe6ad7624df08e069d2f697d625acf3484ca461a7523e32361122e06d23b3a85
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
name: CI
|
3
|
+
|
4
|
+
on:
|
5
|
+
- pull_request
|
6
|
+
- push
|
7
|
+
|
8
|
+
env:
|
9
|
+
TESTOPT: "-v"
|
10
|
+
|
11
|
+
concurrency:
|
12
|
+
group: ${{ github.ref_name }}
|
13
|
+
cancel-in-progress: true
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
name: Ruby
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby:
|
23
|
+
- "3.1"
|
24
|
+
- "3.2"
|
25
|
+
# - "ruby-head"
|
26
|
+
steps:
|
27
|
+
- name: Install system dependencies
|
28
|
+
run: sudo apt-get install imagemagick libmagickwand-dev
|
29
|
+
- name: Check out code
|
30
|
+
uses: actions/checkout@v4
|
31
|
+
- name: Install Ruby dependencies
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby }}
|
35
|
+
bundler-cache: true
|
36
|
+
- name: Run tests
|
37
|
+
run: bundle exec rake test
|
data/Dockerfile
CHANGED
@@ -26,10 +26,10 @@ RUN apk update && apk upgrade
|
|
26
26
|
RUN apk add build-base bash ruby ruby-etc ruby-dev
|
27
27
|
|
28
28
|
# Install builtin fonts
|
29
|
-
RUN gem install invoice_printer_fonts --version 2.
|
29
|
+
RUN gem install invoice_printer_fonts --version 2.4.0 --no-document
|
30
30
|
|
31
31
|
# Install the gem from RubyGems.org
|
32
|
-
RUN gem install invoice_printer_server --version 2.
|
32
|
+
RUN gem install invoice_printer_server --version 2.4.0 --no-document
|
33
33
|
|
34
34
|
# Clean APK cache
|
35
35
|
RUN rm -rf /var/cache/apk/*
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ See more usecases in the `examples/` directory.
|
|
26
26
|
- Payment method box showing banking details including SWIFT and IBAN fields
|
27
27
|
- Issue/due dates box
|
28
28
|
- Configurable items' table with item description, breakdown, quantity, unit, price per unit, tax and item's total amount fields
|
29
|
+
- Description above the table
|
29
30
|
- Final subtotal/tax/total info box
|
30
31
|
- Page numbers
|
31
32
|
- Configurable field labels & sublabels (optional little labels)
|
@@ -50,8 +51,22 @@ See more usecases in the `examples/` directory.
|
|
50
51
|
|
51
52
|
I am developing InvoicePrinter as a free and MIT-licensed library for several years now.
|
52
53
|
|
53
|
-
|
54
|
+
Please consider [buying my book](https://deploymentfromscratch.com/) or [my Rails starter kit](https://businessclasskit.com/) so I can work more on Open Source.
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Contributions are welcome. Make sure the tests are passing before submitting a PR:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
$ bundle && bundle exec rake test
|
62
|
+
```
|
63
|
+
|
64
|
+
You can also quickly regenerate the examples if necessary:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
$ ruby regenerate.rb
|
68
|
+
```
|
54
69
|
|
55
70
|
## Copyright
|
56
71
|
|
57
|
-
Copyright 2015-
|
72
|
+
Copyright 2015-2024 © [Josef Strzibny](http://strzibny.name/). MIT licensed.
|
data/invoice_printer.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
package_files = `git ls-files -z`.split("\x0")
|
34
34
|
.reject{ |file| ONLY_SERVER_FILES.include?(file) }
|
35
35
|
.reject{ |file| ONLY_FONTS_FILES.include?(file) }
|
36
|
-
.reject{ |file| file.match
|
37
|
-
.reject{ |file| file.match
|
36
|
+
.reject{ |file| file.match(/.*\.png/) }
|
37
|
+
.reject{ |file| file.match(/.*\.pdf/) }
|
38
38
|
|
39
39
|
spec.files = package_files
|
40
40
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -42,7 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.require_paths = ['lib']
|
43
43
|
spec.bindir = 'bin'
|
44
44
|
|
45
|
-
spec.required_ruby_version = '>=
|
45
|
+
spec.required_ruby_version = '>= 3.1'
|
46
46
|
|
47
47
|
spec.add_dependency 'json', '~> 2.1'
|
48
48
|
spec.add_dependency 'prawn', '~> 2.4'
|
@@ -297,8 +297,10 @@ module InvoicePrinter
|
|
297
297
|
# ------------------------------------------
|
298
298
|
#
|
299
299
|
def build_purchaser_box
|
300
|
+
purchaser = [@document.purchaser_name, @document.purchaser_lines].join("\n")
|
301
|
+
|
300
302
|
@pdf.text_box(
|
301
|
-
|
303
|
+
purchaser.lines.first,
|
302
304
|
size: 15,
|
303
305
|
at: [x(284), y(640) - @push_down],
|
304
306
|
width: x(240)
|
@@ -320,9 +322,9 @@ module InvoicePrinter
|
|
320
322
|
)
|
321
323
|
end
|
322
324
|
# Render purchaser_lines if present
|
323
|
-
if
|
325
|
+
if purchaser.lines.size > 1
|
324
326
|
@pdf.text_box(
|
325
|
-
|
327
|
+
purchaser.lines(chomp: true)[1..].join("\n"),
|
326
328
|
size: 10,
|
327
329
|
at: [x(284), y(618) - @push_down],
|
328
330
|
width: x(246),
|
@@ -655,7 +657,7 @@ module InvoicePrinter
|
|
655
657
|
end
|
656
658
|
end
|
657
659
|
|
658
|
-
|
660
|
+
def description_height
|
659
661
|
@description_height ||= begin
|
660
662
|
num_of_lines = @document.description.lines.count
|
661
663
|
(num_of_lines * 13)
|
@@ -692,7 +694,6 @@ module InvoicePrinter
|
|
692
694
|
|
693
695
|
options = {
|
694
696
|
header: true,
|
695
|
-
row_colors: [nil, 'ededed'],
|
696
697
|
width: x(540, 2),
|
697
698
|
cell_style: {
|
698
699
|
borders: []
|
@@ -731,10 +732,13 @@ module InvoicePrinter
|
|
731
732
|
|
732
733
|
# Include only items params with provided data
|
733
734
|
def build_items_data(items_params)
|
734
|
-
|
735
|
+
colspan = items_params.select { |k, v| v }.count
|
736
|
+
color_background = false
|
737
|
+
|
738
|
+
items = []
|
739
|
+
@document.items.each do |item|
|
735
740
|
line = []
|
736
|
-
line << { content:
|
737
|
-
#line << { content: item.name, borders: [:bottom], align: :left } if items_params[:names]
|
741
|
+
line << { content: item.name, align: :left } if items_params[:names]
|
738
742
|
line << { content: item.variable, align: :right } if items_params[:variables]
|
739
743
|
line << { content: item.quantity, align: :right } if items_params[:quantities]
|
740
744
|
line << { content: item.unit, align: :right } if items_params[:units]
|
@@ -743,29 +747,19 @@ module InvoicePrinter
|
|
743
747
|
line << { content: item.tax2, align: :right } if items_params[:taxes2]
|
744
748
|
line << { content: item.tax3, align: :right } if items_params[:taxes3]
|
745
749
|
line << { content: item.amount, align: :right } if items_params[:amounts]
|
746
|
-
line
|
747
|
-
end
|
748
|
-
end
|
749
750
|
|
750
|
-
|
751
|
-
def name_cell(item)
|
752
|
-
data = if used?(item.breakdown)
|
753
|
-
data = [
|
754
|
-
[{ content: item.name, padding: [5, 0, 0, 5] }],
|
755
|
-
[{ content: item.breakdown, size: 8, padding: [2, 0, 5, 5] }]
|
756
|
-
]
|
751
|
+
line.each {|c| c[:background_color] = 'ededed'} if color_background
|
757
752
|
|
758
|
-
|
759
|
-
cell_style: {
|
760
|
-
borders: []
|
761
|
-
},
|
762
|
-
position: :left
|
763
|
-
}
|
753
|
+
items << line
|
764
754
|
|
765
|
-
|
766
|
-
|
767
|
-
|
755
|
+
if used?(item.breakdown)
|
756
|
+
items << [{ content: item.breakdown, align: :left, size: 8, colspan: colspan, padding: [0, 0, 5, 5] }]
|
757
|
+
items.last.first[:background_color] = 'ededed' if color_background
|
758
|
+
end
|
759
|
+
|
760
|
+
color_background = !color_background
|
768
761
|
end
|
762
|
+
items
|
769
763
|
end
|
770
764
|
|
771
765
|
# Include only relevant headers
|
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.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josef Strzibny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -116,10 +116,10 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- ".github/workflows/ci.yml"
|
119
120
|
- ".gitignore"
|
120
121
|
- Dockerfile
|
121
122
|
- Gemfile
|
122
|
-
- Gemfile.lock
|
123
123
|
- LICENSE.txt
|
124
124
|
- README.md
|
125
125
|
- Rakefile
|
@@ -179,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
179
|
requirements:
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: '
|
182
|
+
version: '3.1'
|
183
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
189
|
+
rubygems_version: 3.4.10
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Super simple PDF invoicing in pure Ruby
|
data/Gemfile.lock
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
invoice_printer (2.2.0)
|
5
|
-
e2mmap
|
6
|
-
json (~> 2.1)
|
7
|
-
matrix
|
8
|
-
prawn (~> 2.4)
|
9
|
-
prawn-table (~> 0.2.2)
|
10
|
-
invoice_printer_server (2.2.0)
|
11
|
-
invoice_printer (= 2.2.0)
|
12
|
-
json (~> 2.1)
|
13
|
-
puma (>= 3.9.0)
|
14
|
-
roda (~> 3.5)
|
15
|
-
|
16
|
-
GEM
|
17
|
-
remote: https://rubygems.org/
|
18
|
-
specs:
|
19
|
-
Ascii85 (1.1.0)
|
20
|
-
afm (0.2.2)
|
21
|
-
benchmark_driver (0.15.17)
|
22
|
-
benchmark_driver-output-gruff (0.3.1)
|
23
|
-
benchmark_driver (>= 0.12.0)
|
24
|
-
gruff
|
25
|
-
e2mmap (0.1.0)
|
26
|
-
gruff (0.14.0)
|
27
|
-
histogram
|
28
|
-
rmagick
|
29
|
-
hashery (2.1.2)
|
30
|
-
histogram (0.2.4.1)
|
31
|
-
json (2.6.3)
|
32
|
-
matrix (0.1.0)
|
33
|
-
minitest (5.15.0)
|
34
|
-
nio4r (2.5.8)
|
35
|
-
pdf-core (0.9.0)
|
36
|
-
pdf-inspector (1.3.0)
|
37
|
-
pdf-reader (>= 1.0, < 3.0.a)
|
38
|
-
pdf-reader (2.11.0)
|
39
|
-
Ascii85 (~> 1.0)
|
40
|
-
afm (~> 0.2.1)
|
41
|
-
hashery (~> 2.0)
|
42
|
-
ruby-rc4
|
43
|
-
ttfunk
|
44
|
-
pkg-config (1.5.1)
|
45
|
-
prawn (2.4.0)
|
46
|
-
pdf-core (~> 0.9.0)
|
47
|
-
ttfunk (~> 1.7)
|
48
|
-
prawn-table (0.2.2)
|
49
|
-
prawn (>= 1.3.0, < 3.0.0)
|
50
|
-
puma (6.0.2)
|
51
|
-
nio4r (~> 2.0)
|
52
|
-
rack (3.0.4.1)
|
53
|
-
rack-test (2.0.2)
|
54
|
-
rack (>= 1.3)
|
55
|
-
rake (13.0.6)
|
56
|
-
rmagick (5.1.0)
|
57
|
-
pkg-config (~> 1.4)
|
58
|
-
roda (3.64.0)
|
59
|
-
rack
|
60
|
-
ruby-rc4 (0.1.5)
|
61
|
-
ttfunk (1.7.0)
|
62
|
-
|
63
|
-
PLATFORMS
|
64
|
-
x86_64-linux
|
65
|
-
|
66
|
-
DEPENDENCIES
|
67
|
-
benchmark_driver (= 0.15.17)
|
68
|
-
benchmark_driver-output-gruff
|
69
|
-
bundler (>= 1.7)
|
70
|
-
invoice_printer_server!
|
71
|
-
minitest
|
72
|
-
pdf-inspector
|
73
|
-
rack-test
|
74
|
-
rake (>= 10.0)
|
75
|
-
|
76
|
-
BUNDLED WITH
|
77
|
-
2.4.3
|