invoice_printer 2.0.0.beta3 → 2.0.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: d0b5acb10995e69d8aba7d44d9e7d71ce5e9b9104cf5883fec574ada600501b0
4
- data.tar.gz: 3ccaa20f6baeee71cf879cdf74687e6da7ab6441fa5583199fa547d3e5afd34f
3
+ metadata.gz: 97ea4a809c4a18acd04d91edcef4d1950468c230a417e7df3908ecc03eb53766
4
+ data.tar.gz: ffc3a08b88914e8761fa925b6a3b6ff11e47b2e49e9c2542d566f358c378adbb
5
5
  SHA512:
6
- metadata.gz: 84cf91f9a5f2445dbe62491e7f51c05e4bfaf3d9c5d58881db035a964c2114a9d02fca485f300b15fc8cb87efea05d2c24d60822c1f9c01145dd1eeba62c22cd
7
- data.tar.gz: aa5566034f52a87d9c7ee432fc485fd233407a82f591ded208a880f0d214aea3c39cc6241add8bfffbcb3abe07311214cb47ff0daec20f1e7ea4ad5a92b131c8
6
+ metadata.gz: 45b38f99524e0a0b6b44028ec55e4cdce79fcdfcf8c9cf6a40b8cc4878a26da59cb55cf90038bbb56142cd210873f9e534cc8e5156b5a426a19d0305bf404239
7
+ data.tar.gz: d5369bc2301aaa7ae07d7196a2ccc3363fb8827776c155bf668747775699e3c6f7691a5a090f3ce2fdda325891a2e39ccb7a5c9fbf07c0619ccb13820eb8aeae
data/Dockerfile CHANGED
@@ -25,10 +25,10 @@ RUN apk update && apk upgrade
25
25
  RUN apk add build-base bash ruby ruby-etc ruby-dev
26
26
 
27
27
  # Install support for builtin fonts
28
- RUN gem install invoice_printer_fonts --no-document
28
+ RUN gem install invoice_printer_fonts --version 2.0.0 --no-document
29
29
 
30
30
  # Install gem from RubyGems.org
31
- RUN gem install invoice_printer_server --version 2.0.0.beta3 --no-document
31
+ RUN gem install invoice_printer_server --version 2.0.0 --no-document
32
32
 
33
33
  # Clean APK cache
34
34
  RUN rm -rf /var/cache/apk/*
@@ -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.beta3)
5
+ json (~> 2.1)
6
+ prawn (~> 2.2)
7
+ prawn-table (~> 0.2.2)
8
+ invoice_printer_server (2.0.0.beta3)
9
+ invoice_printer (= 2.0.0.beta3)
5
10
  json (~> 2.1)
6
11
  puma (>= 3.9.0)
7
12
  roda (~> 3.5)
@@ -20,26 +25,32 @@ GEM
20
25
  hashery (2.1.2)
21
26
  json (2.2.0)
22
27
  minitest (5.11.3)
23
- nio4r (2.3.1)
28
+ nio4r (2.5.1)
29
+ pdf-core (0.7.0)
24
30
  pdf-inspector (1.3.0)
25
31
  pdf-reader (>= 1.0, < 3.0.a)
26
- pdf-reader (2.2.0)
32
+ pdf-reader (2.2.1)
27
33
  Ascii85 (~> 1.0.0)
28
34
  afm (~> 0.2.1)
29
35
  hashery (~> 2.0)
30
36
  ruby-rc4
31
37
  ttfunk
32
- puma (4.0.0)
38
+ prawn (2.2.2)
39
+ pdf-core (~> 0.7.0)
40
+ ttfunk (~> 1.5)
41
+ prawn-table (0.2.2)
42
+ prawn (>= 1.3.0, < 3.0.0)
43
+ puma (4.1.0)
33
44
  nio4r (~> 2.0)
34
- rack (2.0.6)
45
+ rack (2.0.7)
35
46
  rack-test (1.1.0)
36
47
  rack (>= 1.0, < 3)
37
- rake (10.5.0)
48
+ rake (12.3.3)
38
49
  rmagick (2.16.0)
39
- roda (3.21.0)
50
+ roda (3.23.0)
40
51
  rack
41
52
  ruby-rc4 (0.1.5)
42
- ttfunk (1.4.0)
53
+ ttfunk (1.5.1)
43
54
 
44
55
  PLATFORMS
45
56
  ruby
@@ -80,7 +80,7 @@ InvoicePrinter.print(
80
80
  document: invoice,
81
81
  labels: labels,
82
82
  font: 'overpass',
83
- logo: 'prawn.png',
83
+ logo: File.expand_path('../prawn.png', __FILE__),
84
84
  file_name: 'international_invoice.pdf'
85
85
  )
86
86
 
@@ -88,7 +88,7 @@ InvoicePrinter.print(
88
88
  document: invoice,
89
89
  labels: labels,
90
90
  font: 'overpass',
91
- logo: 'prawn.png',
91
+ logo: File.expand_path('../prawn.png', __FILE__),
92
92
  file_name: 'international_invoice_a4.pdf',
93
93
  page_size: :a4
94
94
  )
@@ -55,16 +55,16 @@ invoice = InvoicePrinter::Document.new(
55
55
  InvoicePrinter.print(
56
56
  document: invoice,
57
57
  labels: labels,
58
- stamp: 'stamp.png',
59
- logo: 'prawn.png',
58
+ stamp: File.expand_path('../stamp.png', __FILE__),
59
+ logo: File.expand_path('../prawn.png', __FILE__),
60
60
  file_name: 'long_invoice.pdf'
61
61
  )
62
62
 
63
63
  InvoicePrinter.print(
64
64
  document: invoice,
65
65
  labels: labels,
66
- stamp: 'stamp.png',
67
- logo: 'prawn.png',
66
+ stamp: File.expand_path('../stamp.png', __FILE__),
67
+ logo: File.expand_path('../prawn.png', __FILE__),
68
68
  file_name: 'long_invoice_a4.pdf',
69
69
  page_size: :a4
70
70
  )
Binary file
@@ -46,20 +46,24 @@ second_item = InvoicePrinter::Document::Item.new(
46
46
  amount: 'Kč 9.000'
47
47
  )
48
48
 
49
+ provider_address = <<ADDRESS
50
+ Rolnická 1
51
+ 747 05 Opava
52
+ Kateřinky
53
+ ADDRESS
54
+
55
+ purchaser_address = <<ADDRESS
56
+ Ostravská 1
57
+ 747 70 Opava
58
+ ADDRESS
59
+
49
60
  invoice = InvoicePrinter::Document.new(
50
61
  number: 'č. 198900000001',
51
62
  provider_name: 'Petr Nový',
63
+ provider_lines: provider_address,
52
64
  provider_tax_id: '56565656',
53
- provider_street: 'Rolnická',
54
- provider_street_number: '1',
55
- provider_postcode: '747 05',
56
- provider_city: 'Opava',
57
- provider_city_part: 'Kateřinky',
58
65
  purchaser_name: 'Adam Černý',
59
- purchaser_street: 'Ostravská',
60
- purchaser_street_number: '1',
61
- purchaser_postcode: '747 70',
62
- purchaser_city: 'Opava',
66
+ purchaser_lines: purchaser_address,
63
67
  issue_date: '05/03/2016',
64
68
  due_date: '19/03/2016',
65
69
  subtotal: 'Kč 10.000',
@@ -75,16 +79,16 @@ invoice = InvoicePrinter::Document.new(
75
79
  InvoicePrinter.print(
76
80
  document: invoice,
77
81
  labels: labels,
78
- font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
79
- logo: 'logo.png',
82
+ font: File.expand_path('../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
83
+ logo: File.expand_path('../logo.png', __FILE__),
80
84
  file_name: 'promo.pdf'
81
85
  )
82
86
 
83
87
  InvoicePrinter.print(
84
88
  document: invoice,
85
89
  labels: labels,
86
- font: File.expand_path('../../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
87
- logo: 'logo.png',
90
+ font: File.expand_path('../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
91
+ logo: File.expand_path('../logo.png', __FILE__),
88
92
  file_name: 'promo_a4.pdf',
89
93
  page_size: :a4
90
94
  )
@@ -94,7 +94,7 @@ InvoicePrinter.print(
94
94
  document: invoice,
95
95
  labels: labels,
96
96
  font: 'overpass',
97
- logo: 'prawn.png',
97
+ logo: File.expand_path('../prawn.png', __FILE__),
98
98
  file_name: 'provider_purchaser_lines.pdf'
99
99
  )
100
100
 
@@ -102,7 +102,7 @@ InvoicePrinter.print(
102
102
  document: invoice,
103
103
  labels: labels,
104
104
  font: 'overpass',
105
- logo: 'prawn.png',
105
+ logo: File.expand_path('../prawn.png', __FILE__),
106
106
  file_name: 'provider_purchaser_lines_a4.pdf',
107
107
  page_size: :a4
108
108
  )
@@ -39,13 +39,13 @@ invoice = InvoicePrinter::Document.new(
39
39
 
40
40
  InvoicePrinter.print(
41
41
  document: invoice,
42
- logo: 'prawn.png',
42
+ logo: File.expand_path('../prawn.png', __FILE__),
43
43
  file_name: 'simple_invoice.pdf'
44
44
  )
45
45
 
46
46
  InvoicePrinter.print(
47
47
  document: invoice,
48
- logo: 'prawn.png',
48
+ logo: File.expand_path('../prawn.png', __FILE__),
49
49
  file_name: 'simple_invoice_a4.pdf',
50
50
  page_size: :a4
51
51
  )
@@ -44,8 +44,8 @@ Gem::Specification.new do |spec|
44
44
  spec.required_ruby_version = '>= 2.4'
45
45
 
46
46
  spec.add_dependency 'json', '~> 2.1'
47
- spec.add_dependency 'prawn', '~> 2.1.0'
48
- spec.add_dependency 'prawn-layout', '~> 0.8.4'
47
+ spec.add_dependency 'prawn', '~> 2.2'
48
+ spec.add_dependency 'prawn-table', '~> 0.2.2'
49
49
 
50
50
  spec.add_development_dependency 'bundler', '>= 1.7'
51
51
  spec.add_development_dependency 'rake', '>= 10.0'
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.summary = 'Super simple PDF invoicing in pure Ruby'
23
23
  spec.description = 'Super simple and fast PDF invoicing in pure Ruby (based on Prawn library).'
24
24
  spec.homepage = 'https://github.com/strzibny/invoice_printer'
25
- spec.license = 'MIT'
25
+ spec.licenses = ['MIT', 'OFL 1.1', 'Apache 2.0']
26
26
 
27
27
  # Include only font files
28
28
  spec.files = FONTS_FILES
@@ -181,6 +181,7 @@ module InvoicePrinter
181
181
  @push_down = 0
182
182
  @push_items_table = 0
183
183
  @pdf.fill_color '000000'
184
+ @pdf.stroke_color 'aaaaaa'
184
185
  build_header
185
186
  build_provider_box
186
187
  build_purchaser_box
@@ -700,26 +701,28 @@ module InvoicePrinter
700
701
  items_params = determine_items_structure
701
702
  items = build_items_data(items_params)
702
703
  headers = build_items_header(items_params)
704
+ data = items.prepend(headers)
703
705
 
704
- styles = {
705
- headers: headers,
706
- row_colors: ['F5F5F5', nil],
706
+ options = {
707
+ header: true,
708
+ row_colors: [nil, 'ededed'],
707
709
  width: x(540, 2),
708
- align: {
709
- 0 => :left,
710
- 1 => :right,
711
- 2 => :right,
712
- 3 => :right,
713
- 4 => :right,
714
- 5 => :right,
715
- 6 => :right,
716
- 7 => :right,
717
- 8 => :right
718
- },
719
- font_size: 10
710
+ cell_style: {
711
+ borders: []
712
+ }
720
713
  }
721
714
 
722
- @pdf.table(items, styles) unless items.empty?
715
+ unless items.empty?
716
+ @pdf.font_size(10) do
717
+ @pdf.table(data, options) do
718
+ row(0).background_color = 'e3e3e3'
719
+ row(0).border_color = 'aaaaaa'
720
+ row(0).borders = [:bottom]
721
+ row(items.size - 1).borders = [:bottom]
722
+ row(items.size - 1).border_color = 'd9d9d9'
723
+ end
724
+ end
725
+ end
723
726
  end
724
727
 
725
728
  # Determine sections of the items table to show based on provided data
@@ -743,15 +746,15 @@ module InvoicePrinter
743
746
  def build_items_data(items_params)
744
747
  @document.items.map do |item|
745
748
  line = []
746
- line << item.name if items_params[:names]
747
- line << item.variable if items_params[:variables]
748
- line << item.quantity if items_params[:quantities]
749
- line << item.unit if items_params[:units]
750
- line << item.price if items_params[:prices]
751
- line << item.tax if items_params[:taxes]
752
- line << item.tax2 if items_params[:taxes2]
753
- line << item.tax3 if items_params[:taxes3]
754
- line << item.amount if items_params[:amounts]
749
+ line << { content: item.name, borders: [:bottom], align: :left } if items_params[:names]
750
+ line << { content: item.variable, align: :right } if items_params[:variables]
751
+ line << { content: item.quantity, align: :right } if items_params[:quantities]
752
+ line << { content: item.unit, align: :right } if items_params[:units]
753
+ line << { content: item.price, align: :right } if items_params[:prices]
754
+ line << { content: item.tax, align: :right } if items_params[:taxes]
755
+ line << { content: item.tax2, align: :right } if items_params[:taxes2]
756
+ line << { content: item.tax3, align: :right } if items_params[:taxes3]
757
+ line << { content: item.amount, align: :right } if items_params[:amounts]
755
758
  line
756
759
  end
757
760
  end
@@ -759,15 +762,15 @@ module InvoicePrinter
759
762
  # Include only relevant headers
760
763
  def build_items_header(items_params)
761
764
  headers = []
762
- headers << { text: label_with_sublabel(:item) } if items_params[:names]
763
- headers << { text: label_with_sublabel(:variable) } if items_params[:variables]
764
- headers << { text: label_with_sublabel(:quantity) } if items_params[:quantities]
765
- headers << { text: label_with_sublabel(:unit) } if items_params[:units]
766
- headers << { text: label_with_sublabel(:price_per_item) } if items_params[:prices]
767
- headers << { text: label_with_sublabel(:tax) } if items_params[:taxes]
768
- headers << { text: label_with_sublabel(:tax2) } if items_params[:taxes2]
769
- headers << { text: label_with_sublabel(:tax3) } if items_params[:taxes3]
770
- headers << { text: label_with_sublabel(:amount) } if items_params[:amounts]
765
+ headers << { content: label_with_sublabel(:item), align: :left } if items_params[:names]
766
+ headers << { content: label_with_sublabel(:variable), align: :right } if items_params[:variables]
767
+ headers << { content: label_with_sublabel(:quantity), align: :right } if items_params[:quantities]
768
+ headers << { content: label_with_sublabel(:unit), align: :right } if items_params[:units]
769
+ headers << { content: label_with_sublabel(:price_per_item), align: :right } if items_params[:prices]
770
+ headers << { content: label_with_sublabel(:tax), align: :right } if items_params[:taxes]
771
+ headers << { content: label_with_sublabel(:tax2), align: :right } if items_params[:taxes2]
772
+ headers << { content: label_with_sublabel(:tax3), align: :right } if items_params[:taxes3]
773
+ headers << { content: label_with_sublabel(:amount), align: :right } if items_params[:amounts]
771
774
  headers
772
775
  end
773
776
 
@@ -794,13 +797,13 @@ module InvoicePrinter
794
797
  @pdf.move_down(25)
795
798
 
796
799
  items = []
797
- items << ["#{@labels[:subtotal]}:#{build_sublabel_for_total_table(:subtotal)}", @document.subtotal] \
800
+ items << [{ content: "#{@labels[:subtotal]}:#{build_sublabel_for_total_table(:subtotal)}", align: :right }, @document.subtotal] \
798
801
  unless @document.subtotal.empty?
799
- items << ["#{@labels[:tax]}:#{build_sublabel_for_total_table(:tax)}", @document.tax] \
802
+ items << [{ content: "#{@labels[:tax]}:#{build_sublabel_for_total_table(:tax)}", align: :right }, @document.tax] \
800
803
  unless @document.tax.empty?
801
- items << ["#{@labels[:tax2]}:#{build_sublabel_for_total_table(:tax2)}", @document.tax2] \
804
+ items << [{ content: "#{@labels[:tax2]}:#{build_sublabel_for_total_table(:tax2)}", align: :right }, @document.tax2] \
802
805
  unless @document.tax2.empty?
803
- items << ["#{@labels[:tax3]}:#{build_sublabel_for_total_table(:tax3)}", @document.tax3] \
806
+ items << [{ content: "#{@labels[:tax3]}:#{build_sublabel_for_total_table(:tax3)}", align: :right }, @document.tax3] \
804
807
  unless @document.tax3.empty?
805
808
 
806
809
  width = [
@@ -810,16 +813,14 @@ module InvoicePrinter
810
813
  "#{@labels[:tax3]}#{@document.tax3}".size
811
814
  ].max * 8
812
815
 
813
- styles = {
814
- border_width: 0,
815
- align: {
816
- 0 => :right,
817
- 1 => :left
816
+ options = {
817
+ cell_style: {
818
+ borders: []
818
819
  }
819
820
  }
820
821
 
821
822
  @pdf.span(x(width), position: :right) do
822
- @pdf.table(items, styles) unless items.empty?
823
+ @pdf.table(items, options) unless items.empty?
823
824
  end
824
825
 
825
826
  @pdf.move_down(15)
@@ -1,3 +1,3 @@
1
1
  module InvoicePrinter
2
- VERSION = '2.0.0.beta3'
2
+ VERSION = '2.0.0'
3
3
  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.0.0.beta3
4
+ version: 2.0.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: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2019-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.1.0
33
+ version: '2.2'
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.1.0
40
+ version: '2.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: prawn-layout
42
+ name: prawn-table
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.8.4
47
+ version: 0.2.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.8.4
54
+ version: 0.2.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -153,9 +153,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
153
  version: '2.4'
154
154
  required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  requirements:
156
- - - ">"
156
+ - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: 1.3.1
158
+ version: '0'
159
159
  requirements: []
160
160
  rubygems_version: 3.0.3
161
161
  signing_key: