invoice_printer 2.0.0.beta1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a929bb5d414cc64bf5f30a97baa8b7b39e9a3bb12eb03efe96eab827bc417b4
4
- data.tar.gz: a1ab11498fed952e4d008aa93d00e2ab2be4b73a65cb38d03e04aa226d027e5e
3
+ metadata.gz: c3af0c9fadd39c8a23600e405aa0dcf2d31945f0fef9aa4bb40a13768ea156c7
4
+ data.tar.gz: 124c1a57d4c11a99da95301ac1be5715f358bfd2654d350345f9e23afefc6035
5
5
  SHA512:
6
- metadata.gz: e93b4d97f28e264dd6385776a49852614ad454fdbe80d00e2d66d3dd98c7614a9c74953a02d30744eb5a148ce250e6418c20a7107a32d0400062e5311f79ac49
7
- data.tar.gz: 2c1907bb3b0e0fc111139f9fdf808dd869c0dc41d359cee43cd1178919670c312be30361c362e74a0a76f8771b6d925a1edaff358348bba68676e3e821ec316b
6
+ metadata.gz: f9a788d351c01c97b99bb50653bf883b363909b54d5d0d65d7b0421a6ec444b2886e6ef7bbb18bc332d59977c0f60700c60efe1ec0cc67c62b075edf3306297e
7
+ data.tar.gz: 3051327dd4011d6ca954981fdfcc05edf2af1ad242355cb029d2c40a29de0e1b18d430b77131b572fe2db975a9ff371c91317a4cf345d7510801d7b594e76257
data/Dockerfile CHANGED
@@ -11,21 +11,25 @@
11
11
  #
12
12
  # $ sudo docker login
13
13
  # $ sudo docker tag printer docker.io/strzibnyj/invoice_printer_server:latest
14
+ # $ sudo docker push strzibnyj/invoice_printer_server:$VERSION
14
15
  # $ sudo docker push strzibnyj/invoice_printer_server:latest
15
- FROM alpine:3.10
16
+ FROM alpine:3.13
16
17
  MAINTAINER Josef Strzibny <strzibny@strzibny.name>
17
18
 
18
19
  ENV GEM_HOME="/usr/local/bundle"
19
20
  ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
20
21
 
21
22
  # Update system
22
- RUN apk update && apk upgrade
23
+ RUN apk update && apk upgrade
23
24
 
24
25
  # Install Ruby and build dependencies
25
26
  RUN apk add build-base bash ruby ruby-etc ruby-dev
26
27
 
27
- # Install gem from RubyGems.org
28
- RUN gem install invoice_printer_server --version 2.0.0.beta1 --no-document
28
+ # Install builtin fonts
29
+ RUN gem install invoice_printer_fonts --version 2.1.0 --no-document
30
+
31
+ # Install the gem from RubyGems.org
32
+ RUN gem install invoice_printer_server --version 2.1.0 --no-document
29
33
 
30
34
  # Clean APK cache
31
35
  RUN rm -rf /var/cache/apk/*
data/Gemfile CHANGED
@@ -10,7 +10,7 @@ group :test do
10
10
  end
11
11
 
12
12
  group :benchmark do
13
- gem 'benchmark_driver', '0.14.11'
13
+ gem 'benchmark_driver', '0.15.17'
14
14
  # For generating benchmark reports with --output gruff
15
15
  gem 'benchmark_driver-output-gruff'
16
16
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invoice_printer_server (2.0.0.alpha1)
4
+ invoice_printer (2.1.0.rc1)
5
+ json (~> 2.1)
6
+ prawn (~> 2.2)
7
+ prawn-table (~> 0.2.2)
8
+ invoice_printer_server (2.1.0.rc1)
9
+ invoice_printer (= 2.1.0.rc1)
5
10
  json (~> 2.1)
6
11
  puma (>= 3.9.0)
7
12
  roda (~> 3.5)
@@ -11,41 +16,49 @@ GEM
11
16
  specs:
12
17
  Ascii85 (1.0.3)
13
18
  afm (0.2.2)
14
- benchmark_driver (0.14.11)
19
+ benchmark_driver (0.15.17)
15
20
  benchmark_driver-output-gruff (0.3.1)
16
21
  benchmark_driver (>= 0.12.0)
17
22
  gruff
18
- gruff (0.7.0)
19
- rmagick (~> 2.13, >= 2.13.4)
23
+ gruff (0.11.0)
24
+ histogram
25
+ rmagick
20
26
  hashery (2.1.2)
21
- json (2.2.0)
22
- minitest (5.11.3)
23
- nio4r (2.3.1)
27
+ histogram (0.2.4.1)
28
+ json (2.3.1)
29
+ minitest (5.14.2)
30
+ nio4r (2.5.4)
31
+ pdf-core (0.9.0)
24
32
  pdf-inspector (1.3.0)
25
33
  pdf-reader (>= 1.0, < 3.0.a)
26
- pdf-reader (2.2.0)
34
+ pdf-reader (2.4.1)
27
35
  Ascii85 (~> 1.0.0)
28
36
  afm (~> 0.2.1)
29
37
  hashery (~> 2.0)
30
38
  ruby-rc4
31
39
  ttfunk
32
- puma (4.0.0)
40
+ prawn (2.4.0)
41
+ pdf-core (~> 0.9.0)
42
+ ttfunk (~> 1.7)
43
+ prawn-table (0.2.2)
44
+ prawn (>= 1.3.0, < 3.0.0)
45
+ puma (5.0.2)
33
46
  nio4r (~> 2.0)
34
- rack (2.0.6)
47
+ rack (2.2.3)
35
48
  rack-test (1.1.0)
36
49
  rack (>= 1.0, < 3)
37
- rake (10.5.0)
38
- rmagick (2.16.0)
39
- roda (3.21.0)
50
+ rake (13.0.1)
51
+ rmagick (4.1.2)
52
+ roda (3.36.0)
40
53
  rack
41
54
  ruby-rc4 (0.1.5)
42
- ttfunk (1.4.0)
55
+ ttfunk (1.7.0)
43
56
 
44
57
  PLATFORMS
45
58
  ruby
46
59
 
47
60
  DEPENDENCIES
48
- benchmark_driver (= 0.14.11)
61
+ benchmark_driver (= 0.15.17)
49
62
  benchmark_driver-output-gruff
50
63
  bundler (>= 1.7)
51
64
  invoice_printer_server!
@@ -55,4 +68,4 @@ DEPENDENCIES
55
68
  rake (>= 10.0)
56
69
 
57
70
  BUNDLED WITH
58
- 1.17.2
71
+ 2.1.4
data/README.md CHANGED
@@ -28,7 +28,7 @@ See more usecases in the `examples/` directory.
28
28
  - Configurable items' table with item description, quantity, unit, price per unit, tax and item's total amount fields
29
29
  - Final subtotal/tax/total info box
30
30
  - Page numbers
31
- - Configurable labels & sublabels (optional little labels)
31
+ - Configurable field labels & sublabels (optional little labels)
32
32
  - Configurable font file
33
33
  - Logotype (as image scaled to fit 50px of height)
34
34
  - Background (as image)
@@ -46,6 +46,12 @@ See more usecases in the `examples/` directory.
46
46
  - [Server](./docs/SERVER.md)
47
47
  - [Command line](./docs/COMMAND_LINE.md)
48
48
 
49
+ ## Support
50
+
51
+ I am developing InvoicePrinter as a free and MIT-licensed library for several years now.
52
+
53
+ I would appreciate if you consider [buying my book](https://deploymentfromscratch.com/).
54
+
49
55
  ## Copyright
50
56
 
51
- Copyright 2015-2019 &copy; [Josef Strzibny](http://strzibny.name/). MIT licensed.
57
+ Copyright 2015-2021 &copy; [Josef Strzibny](http://strzibny.name/). MIT licensed.
@@ -1,13 +1,25 @@
1
1
  # Run the benchmark with benchmark_driver as:
2
2
  #
3
- # $ benchmark-driver benchmarks/render.yml --output gruff --runner ips -e '/path/to/bin/ruby;/path/to/bin/ruby-2.6.0 --jit'
4
- # $ benchmark-driver benchmarks/render.yml --output compare --runner memory -e '/path/to/bin/ruby;/path/to/bin/ruby-2.6.0 --jit--jit'
5
- loop_count: 10000
3
+ # $ benchmark-driver benchmarks/render.yml --output gruff --runner ips -e '/path/to/bin/ruby;/path/to/bin/ruby-3.0.0 --jit'
4
+ # $ benchmark-driver benchmarks/render.yml --output compare --runner memory -e '/path/to/bin/ruby;/path/to/bin/ruby-3.0.0 --jit'
5
+ # $ benchmark-driver benchmarks/render.yml -e '/home/strzibny/.rubies/ruby-2.7.0/bin/ruby;/home/strzibny/.rubies/ruby-3.0.0/bin/ruby;/home/strzibny/.rubies/ruby-3.0.0/bin/ruby --jit'
6
+ #
7
+ # Note: You need to install invoice_printer as a gem for the require to work.
8
+ loop_count: 3000
6
9
  prelude: |
7
- lib = File.expand_path('../lib', __FILE__)
8
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
9
10
  require 'invoice_printer'
10
11
 
12
+ provider_address = <<ADDRESS
13
+ Rolnicka 1
14
+ 747 05 Opava
15
+ Katerinky
16
+ ADDRESS
17
+
18
+ purchaser_address = <<ADDRESS
19
+ Ostravska 1
20
+ 747 70 Opava
21
+ ADDRESS
22
+
11
23
  item = InvoicePrinter::Document::Item.new(
12
24
  name: 'Programming',
13
25
  quantity: '10',
@@ -19,15 +31,9 @@ prelude: |
19
31
  invoice = InvoicePrinter::Document.new(
20
32
  number: 'NO. 198900000001',
21
33
  provider_name: 'John White',
22
- provider_street: '5th Avenue',
23
- provider_street_number: '1',
24
- provider_postcode: '747 05',
25
- provider_city: 'NYC',
34
+ provider_lines: provider_address,
26
35
  purchaser_name: 'Will Black',
27
- purchaser_street: '7th Avenue',
28
- purchaser_street_number: '1',
29
- purchaser_postcode: '747 70',
30
- purchaser_city: 'NYC',
36
+ purchaser_lines: purchaser_address,
31
37
  issue_date: '05/03/2016',
32
38
  due_date: '19/03/2016',
33
39
  total: '$ 900',
data/bin/invoice_printer CHANGED
@@ -18,7 +18,7 @@ def show_help
18
18
 
19
19
  -d, --document document as JSON
20
20
  -l, --labels labels as JSON
21
- --font path to font
21
+ --font path to font or builtin font name
22
22
  -s, --stamp path to stamp
23
23
  --logo path to logotype
24
24
  --background path to background image
data/docs/COMMAND_LINE.md CHANGED
@@ -12,7 +12,7 @@ Options:
12
12
 
13
13
  -d, --document document as JSON
14
14
  -l, --labels labels as JSON
15
- --font path to font
15
+ --font path to font or builtin font name
16
16
  -s, --stamp path to stamp
17
17
  --logo path to logotype
18
18
  --background path to background image
@@ -20,6 +20,125 @@ Options:
20
20
  -f, --filename output path
21
21
  -r, --render directly render PDF stream (filename option will be ignored)
22
22
  ```
23
+
24
+ ## Document
25
+
26
+ JSON document with all possible fields filled:
27
+
28
+ ```json
29
+ {
30
+ "number":"c. 198900000001",
31
+ "provider_name":"Petr Novy",
32
+ "provider_tax_id":"56565656",
33
+ "provider_tax_id2":"",
34
+ "provider_lines":"Rolnická 1\n747 05 Opava\nKateřinky",
35
+ "purchaser_name":"Adam Cerny",
36
+ "purchaser_tax_id":"",
37
+ "purchaser_tax_id2":"",
38
+ "purchaser_lines":"Ostravská 1\n747 70 Opava",
39
+ "issue_date":"05/03/2016",
40
+ "due_date":"19/03/2016",
41
+ "subtotal":"Kc 10.000",
42
+ "tax":"Kc 2.100",
43
+ "tax2":"",
44
+ "tax3":"",
45
+ "variable":"Extra column",
46
+ "total":"Kc 12.100,-",
47
+ "bank_account_number":"156546546465",
48
+ "account_iban":"IBAN464545645",
49
+ "account_swift":"SWIFT5456",
50
+ "items":[
51
+ {
52
+ "name":"Konzultace",
53
+ "variable": "",
54
+ "quantity":"2",
55
+ "unit":"hod",
56
+ "price":"Kc 500",
57
+ "tax":"",
58
+ "tax2":"",
59
+ "tax3":"",
60
+ "amount":"Kc 1.000"
61
+ },
62
+ {
63
+ "name":"Programovani",
64
+ "variable": "",
65
+ "quantity":"10",
66
+ "unit":"hod",
67
+ "price":"Kc 900",
68
+ "tax":"",
69
+ "tax2":"",
70
+ "tax3":"",
71
+ "amount":"Kc 9.000"
72
+ }
73
+ ],
74
+ "note":"Osoba je zapsána v zivnostenském rejstríku."
75
+ }
76
+ ```
77
+
78
+ **Note**: `provider_lines` and `purchaser_lines` are 4 lines of data separated by new line character`\n`. Other lines are being stripped.
79
+
80
+ **Note**: There is `variable` field that can be used for any
81
+ extra column.
82
+
83
+ ## Field labels
84
+
85
+ All labels:
86
+
87
+ ```json
88
+ {
89
+ "name":"Invoice",
90
+ "provider":"Provider",
91
+ "purchaser":"Purchaser",
92
+ "tax_id":"Identification number",
93
+ "tax_id2":"Identification number",
94
+ "payment":"Payment",
95
+ "payment_by_transfer":"Payment by bank transfer on the account below:",
96
+ "payment_in_cash":"Payment in cash",
97
+ "account_number":"Account NO",
98
+ "swift":"SWIFT",
99
+ "iban":"IBAN",
100
+ "issue_date":"Issue date",
101
+ "due_date": "Due date",
102
+ "item":"Item",
103
+ "variable":"",
104
+ "quantity":"Quantity",
105
+ "unit": "Unit",
106
+ "price_per_item":"Price per item",
107
+ "amount":"Amount",
108
+ "tax":"Tax",
109
+ "tax2":"Tax 2",
110
+ "tax3":"Tax 3",
111
+ "subtotal":"Subtotal",
112
+ "total":"Total",
113
+ "sublabels":{
114
+ "name":"Faktura",
115
+ "provider":"Prodejce",
116
+ "purchaser":"Kupující",
117
+ "tax_id":"IČ",
118
+ "tax_id2":"DIČ",
119
+ "payment":"Forma úhrady",
120
+ "payment_by_transfer":"Platba na následující účet:",
121
+ "account_number":"Číslo účtu",
122
+ "issue_date":"Datum vydání",
123
+ "due_date":"Datum splatnosti",
124
+ "item":"Položka",
125
+ "variable:":"",
126
+ "quantity":"Počet",
127
+ "unit":"MJ",
128
+ "price_per_item":"Cena za položku",
129
+ "amount":"Celkem bez daně",
130
+ "subtota":"Cena bez daně",
131
+ "tax":"DPH 21 %",
132
+ "total":"Celkem"
133
+ }
134
+ }
135
+ ```
136
+ **Note**: Notice the `sublabels` which you might not want to necessary include.
137
+
138
+ ## Built-in fonts
139
+
140
+ Supported builtin fonts are: `overpass`, `opensans`, and `roboto`.
141
+
23
142
  ## Examples
24
143
 
25
144
  ```
data/docs/INSTALLATION.md CHANGED
@@ -12,6 +12,10 @@ Or the server version as:
12
12
 
13
13
  $ gem install invoice_printer_server
14
14
 
15
+ To have builtin fonts available install:
16
+
17
+ $ gem install invoice_printer_fonts
18
+
15
19
  ### With Bundler
16
20
 
17
21
  Add this line to your application's Gemfile:
@@ -26,6 +30,12 @@ For the server:
26
30
  gem 'invoice_printer_server'
27
31
  ```
28
32
 
33
+ To have builtin fonts available add:
34
+
35
+ ```ruby
36
+ gem 'invoice_printer_fonts'
37
+ ```
38
+
29
39
  And then execute:
30
40
 
31
41
  $ bundle
data/docs/LIBRARY.md CHANGED
@@ -72,13 +72,11 @@ invoice = InvoicePrinter::Document.new(
72
72
  **Note**: `provider_lines` and `purchaser_lines` are 4 lines of data separated by new line character`\n`. Other lines are being stripped.
73
73
 
74
74
  **Note**: There is `variable` field that can be used for any
75
- extra column. `tax2` and `tax3` for more complex taxes are
76
- available as well.
75
+ extra column.
77
76
 
78
77
  ### Ruby on Rails
79
78
 
80
- If you want to use InvoicePrinter for printing PDF documents directly from Rails
81
- actions, you can:
79
+ If you want to use InvoicePrinter for printing PDF documents directly from Rails actions, you can:
82
80
 
83
81
  ```ruby
84
82
  # GET /invoices/1
@@ -109,11 +107,8 @@ InvoicePrinter.print(
109
107
  document: document,
110
108
  ...
111
109
  )
112
-
113
110
  ```
114
111
 
115
-
116
-
117
112
  ## Customization
118
113
 
119
114
  ### Page size
@@ -153,8 +148,7 @@ InvoicePrinter.print(
153
148
  )
154
149
  ```
155
150
 
156
- Here is the full list of labels to configure. You can paste and edit this block
157
- to `initializers/invoice_printer.rb` if you are using Rails.
151
+ Here is the full list of labels to configure. You can paste and edit this block to `initializers/invoice_printer.rb` if you are using Rails.
158
152
 
159
153
  ```ruby
160
154
  InvoicePrinter.labels = {
@@ -226,14 +220,23 @@ Now the document will have little sublabels next to the original labels in Czech
226
220
 
227
221
  To support specific characters you might need to specify a TTF font to be used:
228
222
 
229
- ``` ruby
223
+ ```ruby
230
224
  InvoicePrinter.print(
231
225
  ...
232
226
  font: File.expand_path('../Overpass-Regular.ttf', __FILE__)
233
227
  )
234
228
  ```
235
229
 
236
- We recommend you DejaVuSans and Overpass fonts.
230
+ If you don't have a font around, you can install `invoice_printer_fonts` gem and specify the supported font name instead:
231
+
232
+ ```ruby
233
+ InvoicePrinter.print(
234
+ document: invoice,
235
+ font: "roboto"
236
+ )
237
+ ```
238
+
239
+ Supported builtin fonts are: `overpass`, `opensans`, and `roboto`. Note that searching the path takes preference.
237
240
 
238
241
  ### Background
239
242
 
data/docs/SERVER.md CHANGED
@@ -23,11 +23,15 @@ By default server binds to `0.0.0.0:9393`.
23
23
  Get the public image and run it:
24
24
 
25
25
  ```bash
26
- $ sudo docker pull strzibnyj/invoice_printer_server:latest
27
- $ sudo docker run -d -p 9393:9393 -t docker.io/strzibnyj/invoice_printer_server
26
+ $ sudo docker pull strzibnyj/invoice_printer_server:$VERSION
27
+ $ sudo docker run -d -p 9393:9393 -v ~/path/to/invocies:/data:Z -t docker.io/strzibnyj/invoice_printer_server
28
28
  ```
29
+ You can use `latest` as a `$VERSION`. Specifying the `-v` option is only required when using the `/print` action to create the documents at certain path. It will allow you to provide the desired filename as "/data/invoice-name.pdf".
30
+
29
31
  The server will then be available on `0.0.0.0:9393`.
30
32
 
33
+ Docker image already contains the optional `invoice_printer_fonts` gem.
34
+
31
35
  ### As a mountable Rack app
32
36
 
33
37
  If you want you can always run the server from your custom program or mount it directly from a Rack app.
@@ -56,12 +60,14 @@ Options:
56
60
 
57
61
  - `document` - JSON representation of the document
58
62
  - `labels` - JSON for labels
59
- - `font` - path to font file
63
+ - `font` - path to font file or builtin font name
60
64
  - `stamp` - path to stamp file
61
65
  - `logo` - path to logotype file
62
66
  - `background` - path to background file
63
67
  - `page_size` - letter or A4 page size
64
68
 
69
+ These parameters are the same as for the [command line](./COMMAND_LINE.md).
70
+
65
71
  On success a `200` response is returned:
66
72
 
67
73
  ```json
@@ -96,7 +102,7 @@ Options:
96
102
 
97
103
  - `document` - JSON representation of the document
98
104
  - `labels` - JSON for labels
99
- - `font` - path to font file
105
+ - `font` - path to font file or builtin font name
100
106
  - `stamp` - path to stamp file
101
107
  - `logo` - path to logotype file
102
108
  - `background` - path to background file