invoice_printer 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a87300d4ff6a12080b758ea012b7c94a09521575c99579e300844dbfbf0e47
4
- data.tar.gz: 33446dc1314512a7793ad95b73065dfb59abef1963e5c115fab5263e2dd53ecc
3
+ metadata.gz: 2f98cb9145f19c42e95490c56afbb156408c5049c766d9ddcb1c776ee112c5fe
4
+ data.tar.gz: 77c6280ab4566b41ad6b040113f3ccf99b0c4bf5e2bccce28c3d0740644a1e57
5
5
  SHA512:
6
- metadata.gz: ef29b3e26227c6cbeba87fca78154d55a7bb103472f77991fe1a4df24f30a36efa75db3f7f724ddd17a369713870db6d20bd93ea33d0812fb55501bbba9c7ea2
7
- data.tar.gz: 6c93d97f040190c555dcbdaf742e05d904a00bd458e2f68009dd1191ec3bf190fe92e20033bb19e0ae3337f6e10686361922b05bcfcc6316e86f8bb46b7a0cbf
6
+ metadata.gz: c1be305d2988483f0912598cbcd523b3f8f020667f61cb253e7b5c3f455ed188efebcec20fe4d1f77148ce984c9866c723c3e645a9e4515b50a67aceb85d45a5
7
+ data.tar.gz: f4764ce73b9c8f696cdd8bfa975ab1f3cbd8d85bb62a3b335a321eb7fb860b08a03835cc875c3dd774b670af3baeffc48f590e53d0c763ccece20e9e22b74657
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.2.0 --no-document
29
+ RUN gem install invoice_printer_fonts --version 2.3.0 --no-document
30
30
 
31
31
  # Install the gem from RubyGems.org
32
- RUN gem install invoice_printer_server --version 2.2.0 --no-document
32
+ RUN gem install invoice_printer_server --version 2.3.0 --no-document
33
33
 
34
34
  # Clean APK cache
35
35
  RUN rm -rf /var/cache/apk/*
data/Gemfile.lock CHANGED
@@ -2,8 +2,10 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  invoice_printer (2.2.0)
5
+ e2mmap
5
6
  json (~> 2.1)
6
- prawn (~> 2.2)
7
+ matrix
8
+ prawn (~> 2.4)
7
9
  prawn-table (~> 0.2.2)
8
10
  invoice_printer_server (2.2.0)
9
11
  invoice_printer (= 2.2.0)
@@ -14,48 +16,52 @@ PATH
14
16
  GEM
15
17
  remote: https://rubygems.org/
16
18
  specs:
17
- Ascii85 (1.0.3)
19
+ Ascii85 (1.1.0)
18
20
  afm (0.2.2)
19
21
  benchmark_driver (0.15.17)
20
22
  benchmark_driver-output-gruff (0.3.1)
21
23
  benchmark_driver (>= 0.12.0)
22
24
  gruff
23
- gruff (0.11.0)
25
+ e2mmap (0.1.0)
26
+ gruff (0.14.0)
24
27
  histogram
25
28
  rmagick
26
29
  hashery (2.1.2)
27
30
  histogram (0.2.4.1)
28
- json (2.5.1)
29
- minitest (5.14.2)
30
- nio4r (2.5.7)
31
+ json (2.6.3)
32
+ matrix (0.1.0)
33
+ minitest (5.15.0)
34
+ nio4r (2.5.8)
31
35
  pdf-core (0.9.0)
32
36
  pdf-inspector (1.3.0)
33
37
  pdf-reader (>= 1.0, < 3.0.a)
34
- pdf-reader (2.4.1)
35
- Ascii85 (~> 1.0.0)
38
+ pdf-reader (2.11.0)
39
+ Ascii85 (~> 1.0)
36
40
  afm (~> 0.2.1)
37
41
  hashery (~> 2.0)
38
42
  ruby-rc4
39
43
  ttfunk
44
+ pkg-config (1.5.1)
40
45
  prawn (2.4.0)
41
46
  pdf-core (~> 0.9.0)
42
47
  ttfunk (~> 1.7)
43
48
  prawn-table (0.2.2)
44
49
  prawn (>= 1.3.0, < 3.0.0)
45
- puma (5.3.2)
50
+ puma (6.0.2)
46
51
  nio4r (~> 2.0)
47
- rack (2.2.3)
48
- rack-test (1.1.0)
49
- rack (>= 1.0, < 3)
50
- rake (13.0.1)
51
- rmagick (4.1.2)
52
- roda (3.45.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)
53
59
  rack
54
60
  ruby-rc4 (0.1.5)
55
61
  ttfunk (1.7.0)
56
62
 
57
63
  PLATFORMS
58
- ruby
64
+ x86_64-linux
59
65
 
60
66
  DEPENDENCIES
61
67
  benchmark_driver (= 0.15.17)
@@ -68,4 +74,4 @@ DEPENDENCIES
68
74
  rake (>= 10.0)
69
75
 
70
76
  BUNDLED WITH
71
- 2.1.4
77
+ 2.4.3
data/docs/COMMAND_LINE.md CHANGED
@@ -49,6 +49,7 @@ JSON document with all possible fields filled:
49
49
  "bank_account_number":"156546546465",
50
50
  "account_iban":"IBAN464545645",
51
51
  "account_swift":"SWIFT5456",
52
+ "description": "We are invoicing the following items:",
52
53
  "items":[
53
54
  {
54
55
  "name":"Konzultace",
data/docs/LIBRARY.md CHANGED
@@ -65,6 +65,7 @@ invoice = InvoicePrinter::Document.new(
65
65
  bank_account_number: '156546546465',
66
66
  account_iban: 'IBAN464545645',
67
67
  account_swift: 'SWIFT5456',
68
+ description: 'We are invoicing the following items:',
68
69
  items: [item],
69
70
  note: 'A note...'
70
71
  )
@@ -27,11 +27,13 @@ invoice = InvoicePrinter::Document.new(
27
27
  number: 'NO. 198900000001',
28
28
  provider_name: 'John White',
29
29
  provider_lines: provider_address,
30
+ purchaser_name: 'Will Black',
30
31
  purchaser_lines: purchaser_address,
31
32
  issue_date: '05/03/2016',
32
33
  due_date: '19/03/2016',
33
34
  total: '$ 900',
34
35
  bank_account_number: '156546546465',
36
+ description: "You can use 20% discount for the next order with the code:\nDISCOUNT",
35
37
  items: [item],
36
38
  note: "This is a note at the end.\nA note with two lines."
37
39
  )
@@ -45,8 +45,10 @@ Gem::Specification.new do |spec|
45
45
  spec.required_ruby_version = '>= 2.4'
46
46
 
47
47
  spec.add_dependency 'json', '~> 2.1'
48
- spec.add_dependency 'prawn', '~> 2.2'
48
+ spec.add_dependency 'prawn', '~> 2.4'
49
49
  spec.add_dependency 'prawn-table', '~> 0.2.2'
50
+ spec.add_dependency 'matrix'
51
+ spec.add_dependency 'e2mmap'
50
52
 
51
53
  spec.add_development_dependency 'bundler', '>= 1.7'
52
54
  spec.add_development_dependency 'rake', '>= 10.0'
@@ -22,6 +22,7 @@ module InvoicePrinter
22
22
  # bank_account_number: '156546546465',
23
23
  # account_iban: 'IBAN464545645',
24
24
  # account_swift: 'SWIFT5456',
25
+ # description: "We are invoicing you the following items:",
25
26
  # items: [
26
27
  # InvoicePrinter::Document::Item.new,
27
28
  # InvoicePrinter::Document::Item.new
@@ -57,6 +58,7 @@ module InvoicePrinter
57
58
  :bank_account_number,
58
59
  :account_iban,
59
60
  :account_swift,
61
+ :description,
60
62
  # Collection of InvoicePrinter::Invoice::Items
61
63
  :items,
62
64
  :note
@@ -84,6 +86,7 @@ module InvoicePrinter
84
86
  bank_account_number: json['bank_account_number'],
85
87
  account_iban: json['account_iban'],
86
88
  account_swift: json['account_swift'],
89
+ description: json['description'],
87
90
  note: json['note'],
88
91
 
89
92
  items: (json['items'] || []).map { |item_json| Item.from_json(item_json) }
@@ -111,6 +114,7 @@ module InvoicePrinter
111
114
  bank_account_number: nil,
112
115
  account_iban: nil,
113
116
  account_swift: nil,
117
+ description: nil,
114
118
  items: nil,
115
119
  note: nil)
116
120
 
@@ -134,6 +138,7 @@ module InvoicePrinter
134
138
  @bank_account_number = String(bank_account_number)
135
139
  @account_iban = String(account_iban)
136
140
  @account_swift = String(account_swift)
141
+ @description = String(description)
137
142
  @items = items
138
143
  @note = String(note)
139
144
 
@@ -163,6 +168,7 @@ module InvoicePrinter
163
168
  'bank_account_number': @bank_account_number,
164
169
  'account_iban': @account_iban,
165
170
  'account_swift': @account_swift,
171
+ 'description': @description,
166
172
  'items': @items.map(&:to_h),
167
173
  'note': @note
168
174
  }
@@ -171,6 +171,7 @@ module InvoicePrinter
171
171
  build_purchaser_box
172
172
  build_payment_method_box
173
173
  build_info_box
174
+ build_description
174
175
  build_items
175
176
  build_total
176
177
  build_stamp
@@ -254,18 +255,14 @@ module InvoicePrinter
254
255
  end
255
256
  # Render provider_lines if present
256
257
  if !@document.provider_lines.empty?
257
- lines = @document.provider_lines.split("\n")
258
- line_y = 618
259
- lines.each_with_index do |line, index|
260
- next if index > 3
261
-
262
- @pdf.text_box(
263
- "#{line}",
264
- size: 10,
265
- at: [10, y(line_y - index*15) - @push_down],
266
- width: x(240)
267
- )
268
- end
258
+ @pdf.text_box(
259
+ @document.provider_lines,
260
+ size: 10,
261
+ at: [x(10), y(618) - @push_down],
262
+ width: x(246),
263
+ height: y(68),
264
+ leading: 3,
265
+ )
269
266
  end
270
267
  unless @document.provider_tax_id.empty?
271
268
  @pdf.text_box(
@@ -324,18 +321,14 @@ module InvoicePrinter
324
321
  end
325
322
  # Render purchaser_lines if present
326
323
  if !@document.purchaser_lines.empty?
327
- lines = @document.purchaser_lines.split("\n")
328
- line_y = 618
329
- lines.each_with_index do |line, index|
330
- next if index > 3
331
-
332
- @pdf.text_box(
333
- "#{line}",
334
- size: 10,
335
- at: [x(284), y(line_y - index*15) - @push_down],
336
- width: x(240)
337
- )
338
- end
324
+ @pdf.text_box(
325
+ @document.purchaser_lines,
326
+ size: 10,
327
+ at: [x(284), y(618) - @push_down],
328
+ width: x(246),
329
+ height: y(68),
330
+ leading: 3,
331
+ )
339
332
  end
340
333
  unless @document.purchaser_tax_id.empty?
341
334
  @pdf.text_box(
@@ -650,6 +643,25 @@ module InvoicePrinter
650
643
  used?(@labels[:sublabels][:variable_symbol])
651
644
  end
652
645
 
646
+ def build_description
647
+ unless @document.description.empty?
648
+ @pdf.text_box(
649
+ @document.description,
650
+ size: 11,
651
+ align: :left,
652
+ at: [0, y(450) - @push_down - 26]
653
+ )
654
+ @push_items_table += description_height + 8
655
+ end
656
+ end
657
+
658
+ def description_height
659
+ @description_height ||= begin
660
+ num_of_lines = @document.description.lines.count
661
+ (num_of_lines * 13)
662
+ end
663
+ end
664
+
653
665
  # Build the following table for document items:
654
666
  #
655
667
  # =================================================================
@@ -845,7 +857,7 @@ module InvoicePrinter
845
857
  def build_logo
846
858
  if @logo && !@logo.empty?
847
859
  bottom = @document.note.empty? ? 75 : (75 + note_height)
848
- @pdf.image(@logo, at: [0, bottom], fit: [200, 50])
860
+ @pdf.image(@logo, at: [0, bottom], fit: [x(200), y(50)])
849
861
  end
850
862
  end
851
863
 
@@ -853,7 +865,7 @@ module InvoicePrinter
853
865
  def build_stamp
854
866
  if @stamp && !@stamp.empty?
855
867
  @pdf.move_down(15)
856
- @pdf.image(@stamp, position: :right)
868
+ @pdf.image(@stamp, position: :right, fit: [x(200), y(40)])
857
869
  end
858
870
  end
859
871
 
@@ -1,3 +1,3 @@
1
1
  module InvoicePrinter
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.0'
3
3
  end
data/regenerate.rb ADDED
@@ -0,0 +1,10 @@
1
+ # Script to regenerate all examples
2
+ examples_directory = File.expand_path('../examples', __FILE__)
3
+ @examples = Dir.glob("#{examples_directory}/*.rb")
4
+
5
+ @examples.each do |example|
6
+ puts "Running #{example}"
7
+ Dir.chdir(examples_directory) do
8
+ `ruby #{example}`
9
+ end
10
+ end
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.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Strzibny
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-17 00:00:00.000000000 Z
11
+ date: 2023-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.2'
33
+ version: '2.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.2'
40
+ version: '2.4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: prawn-table
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.2.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: matrix
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: e2mmap
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: bundler
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +152,7 @@ files:
124
152
  - lib/invoice_printer/document/item.rb
125
153
  - lib/invoice_printer/pdf_document.rb
126
154
  - lib/invoice_printer/version.rb
155
+ - regenerate.rb
127
156
  - test/api_test.rb
128
157
  - test/background_test.rb
129
158
  - test/cli_test.rb
@@ -142,7 +171,7 @@ homepage: https://github.com/strzibny/invoice_printer
142
171
  licenses:
143
172
  - MIT
144
173
  metadata: {}
145
- post_install_message:
174
+ post_install_message:
146
175
  rdoc_options: []
147
176
  require_paths:
148
177
  - lib
@@ -157,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
186
  - !ruby/object:Gem::Version
158
187
  version: '0'
159
188
  requirements: []
160
- rubygems_version: 3.2.3
161
- signing_key:
189
+ rubygems_version: 3.3.3
190
+ signing_key:
162
191
  specification_version: 4
163
192
  summary: Super simple PDF invoicing in pure Ruby
164
193
  test_files: