invoice_printer 2.0.0.alpha1 → 2.1.0.rc1

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: cdf5ab1be5ba608592e459feb3295450b61fb43d063adf9e250281bad74fa87e
4
- data.tar.gz: ffbe76f56621e22d5e0020ba0a285305b4ce018f5923d7240e543140fb8b9acd
3
+ metadata.gz: 926ffa0b9c6ce419a715122202dbc5e5b6489323c0daafe1da259cb86efb0acc
4
+ data.tar.gz: d0a6882d42b488d4df932f8b5981a188beb515af31ec3a0d5eb49a6b64a28882
5
5
  SHA512:
6
- metadata.gz: 9d5f1023dd14f26e190b579edf7a4def0f86530574d64024a4ebd49d82735efcd4294a0913e09c95a38ed44e8a12fe46ac56326e8e1d8db565d3a9df242a9441
7
- data.tar.gz: f768d976020dc7397241344cecf5daa164e24e51f71815105cf37d781b8d9e278a6f98af3445cbb97deb8df3d46dbc082be5999e666016735ff411ae975d1059
6
+ metadata.gz: 383e3dc9b714a1faf3a585ed9313db8d0e77031d4556643894395757de723a787b216f5af2eba8ea7aa5c183c0d5ea55bc69534bf9bc40def043767f10c9aeb3
7
+ data.tar.gz: b53666c983492ffc59668c305b4b1e1e914f78488a44ec8c048c83de847a4a3559a0092534795d985a61c0192698ab99a2f0b3ecdf8d74a91dde1ff3a7f524af
data/Dockerfile ADDED
@@ -0,0 +1,37 @@
1
+ # To build the Docker image:
2
+ #
3
+ # $ sudo systemctl start docker
4
+ # $ sudo docker build -t printer .
5
+ #
6
+ # To run it:
7
+ #
8
+ # $ sudo docker run -d -p 9393:9393 -t printer
9
+ #
10
+ # To push to repository:
11
+ #
12
+ # $ sudo docker login
13
+ # $ sudo docker tag printer docker.io/strzibnyj/invoice_printer_server:latest
14
+ # $ sudo docker push strzibnyj/invoice_printer_server:latest
15
+ FROM alpine:3.10
16
+ MAINTAINER Josef Strzibny <strzibny@strzibny.name>
17
+
18
+ ENV GEM_HOME="/usr/local/bundle"
19
+ ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
20
+
21
+ # Update system
22
+ RUN apk update && apk upgrade
23
+
24
+ # Install Ruby and build dependencies
25
+ RUN apk add build-base bash ruby ruby-etc ruby-dev
26
+
27
+ # Install support for builtin fonts
28
+ RUN gem install invoice_printer_fonts --version 2.0.0 --no-document
29
+
30
+ # Install gem from RubyGems.org
31
+ RUN gem install invoice_printer_server --version 2.0.0 --no-document
32
+
33
+ # Clean APK cache
34
+ RUN rm -rf /var/cache/apk/*
35
+
36
+ # Run the server on port 80
37
+ ENTRYPOINT ["/usr/local/bundle/bin/invoice_printer_server", "-p9393"]
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.0.0)
5
+ json (~> 2.1)
6
+ prawn (~> 2.2)
7
+ prawn-table (~> 0.2.2)
8
+ invoice_printer_server (2.0.0)
9
+ invoice_printer (= 2.0.0)
5
10
  json (~> 2.1)
6
11
  puma (>= 3.9.0)
7
12
  roda (~> 3.5)
@@ -15,31 +20,39 @@ GEM
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
@@ -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)
@@ -48,4 +48,4 @@ See more usecases in the `examples/` directory.
48
48
 
49
49
  ## Copyright
50
50
 
51
- Copyright 2015-2019 &copy; [Josef Strzibny](http://strzibny.name/). MIT licensed.
51
+ Copyright 2015-2021 &copy; [Josef Strzibny](http://strzibny.name/). MIT licensed.
@@ -8,6 +8,17 @@ prelude: |
8
8
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
9
9
  require 'invoice_printer'
10
10
 
11
+ provider_address = <<ADDRESS
12
+ Rolnická 1
13
+ 747 05 Opava
14
+ Kateřinky
15
+ ADDRESS
16
+
17
+ purchaser_address = <<ADDRESS
18
+ Ostravská 1
19
+ 747 70 Opava
20
+ ADDRESS
21
+
11
22
  item = InvoicePrinter::Document::Item.new(
12
23
  name: 'Programming',
13
24
  quantity: '10',
@@ -19,15 +30,9 @@ prelude: |
19
30
  invoice = InvoicePrinter::Document.new(
20
31
  number: 'NO. 198900000001',
21
32
  provider_name: 'John White',
22
- provider_street: '5th Avenue',
23
- provider_street_number: '1',
24
- provider_postcode: '747 05',
25
- provider_city: 'NYC',
33
+ provider_lines: provider_address,
26
34
  purchaser_name: 'Will Black',
27
- purchaser_street: '7th Avenue',
28
- purchaser_street_number: '1',
29
- purchaser_postcode: '747 70',
30
- purchaser_city: 'NYC',
35
+ purchaser_lines: purchaser_address,
31
36
  issue_date: '05/03/2016',
32
37
  due_date: '19/03/2016',
33
38
  total: '$ 900',
data/bin/invoice_printer CHANGED
@@ -5,7 +5,7 @@ require 'optparse'
5
5
  require 'invoice_printer'
6
6
 
7
7
  def show_version
8
- puts "InvoicePrinter Server v#{InvoicePrinter::VERSION}"
8
+ puts "InvoicePrinter v#{InvoicePrinter::VERSION}"
9
9
 
10
10
  exit 0
11
11
  end
@@ -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
@@ -4,10 +4,17 @@
4
4
 
5
5
  This requires Ruby to be installed.
6
6
 
7
- Then install the gem as:
7
+ Install the library and command line as:
8
8
 
9
9
  $ gem install invoice_printer
10
10
 
11
+ Or the server version as:
12
+
13
+ $ gem install invoice_printer_server
14
+
15
+ To have builtin fonts available install:
16
+
17
+ $ gem install invoice_printer_fonts
11
18
 
12
19
  ### With Bundler
13
20
 
@@ -17,6 +24,30 @@ Add this line to your application's Gemfile:
17
24
  gem 'invoice_printer'
18
25
  ```
19
26
 
27
+ For the server:
28
+
29
+ ```ruby
30
+ gem 'invoice_printer_server'
31
+ ```
32
+
33
+ To have builtin fonts available add:
34
+
35
+ ```ruby
36
+ gem 'invoice_printer_fonts'
37
+ ```
38
+
20
39
  And then execute:
21
40
 
22
- $ bundle
41
+ $ bundle
42
+
43
+ ## Using Docker
44
+
45
+ InvoicePrinter Server is available as a Docker image.
46
+
47
+ This requires Docker to be installed and running.
48
+
49
+ To get it:
50
+
51
+ ```bash
52
+ $ sudo docker pull strzibnyj/invoice_printer_server
53
+ ```
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
@@ -1,24 +1,38 @@
1
1
  # InvoicePrinter Server
2
2
 
3
- InvoicePrinter contains a built in server that can be run from a command line with `invoice_printer_server`.
3
+ InvoicePrinter comes with a server that can be run from a command line with `invoice_printer_server`. Since 2.x releases this server is packaged separately in `invoice_printer_server` gem.
4
4
 
5
5
  Apart from this you can also manually mount the server inside of your Rack application.
6
6
 
7
7
  ## Running the server
8
8
 
9
- ### From command line
9
+ ### From a command line
10
10
 
11
- Once installed, InvoicePrinter provides `invoice_printer_server` executable that starts the Puma server:
11
+ Once installed, InvoicePrinter Server provides `invoice_printer_server` executable that starts the Puma server:
12
12
 
13
13
  ```bash
14
- invoice_printer_server -h 0.0.0.0 -p 5000
14
+ $ invoice_printer_server -h 0.0.0.0 -p 5000
15
15
  ```
16
16
 
17
17
  `-h` defines a host and `-p` defines a port. For help you can run `--help`.
18
18
 
19
19
  By default server binds to `0.0.0.0:9393`.
20
20
 
21
- ### As mountable Rack app
21
+ #### As a Docker image
22
+
23
+ Get the public image and run it:
24
+
25
+ ```bash
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
+ ```
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
+
31
+ The server will then be available on `0.0.0.0:9393`.
32
+
33
+ Docker image already contains the optional `invoice_printer_fonts` gem.
34
+
35
+ ### As a mountable Rack app
22
36
 
23
37
  If you want you can always run the server from your custom program or mount it directly from a Rack app.
24
38
 
@@ -46,12 +60,14 @@ Options:
46
60
 
47
61
  - `document` - JSON representation of the document
48
62
  - `labels` - JSON for labels
49
- - `font` - path to font file
63
+ - `font` - path to font file or builtin font name
50
64
  - `stamp` - path to stamp file
51
65
  - `logo` - path to logotype file
52
66
  - `background` - path to background file
53
67
  - `page_size` - letter or A4 page size
54
68
 
69
+ These parameters are the same as for the [command line](./COMMAND_LINE.md).
70
+
55
71
  On success a `200` response is returned:
56
72
 
57
73
  ```json
@@ -86,7 +102,7 @@ Options:
86
102
 
87
103
  - `document` - JSON representation of the document
88
104
  - `labels` - JSON for labels
89
- - `font` - path to font file
105
+ - `font` - path to font file or builtin font name
90
106
  - `stamp` - path to stamp file
91
107
  - `logo` - path to logotype file
92
108
  - `background` - path to background file