invoice_printer 2.0.0.beta1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
81
78
  InvoicePrinter.print(
82
79
  document: invoice,
83
80
  labels: labels,
84
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
81
+ font: 'overpass',
85
82
  logo: 'prawn.png',
86
83
  file_name: 'czech_invoice.pdf'
87
84
  )
@@ -89,7 +86,7 @@ InvoicePrinter.print(
89
86
  InvoicePrinter.print(
90
87
  document: invoice,
91
88
  labels: labels,
92
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
89
+ font: 'overpass',
93
90
  logo: 'prawn.png',
94
91
  file_name: 'czech_invoice_a4.pdf',
95
92
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -81,7 +78,7 @@ invoice = InvoicePrinter::Document.new(
81
78
  InvoicePrinter.print(
82
79
  document: invoice,
83
80
  labels: labels,
84
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
81
+ font: 'overpass',
85
82
  logo: 'prawn.png',
86
83
  file_name: 'czech_invoice_long.pdf'
87
84
  )
@@ -89,7 +86,7 @@ InvoicePrinter.print(
89
86
  InvoicePrinter.print(
90
87
  document: invoice,
91
88
  labels: labels,
92
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
89
+ font: 'overpass',
93
90
  logo: 'prawn.png',
94
91
  file_name: 'czech_invoice_long_a4.pdf',
95
92
  page_size: :a4
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a international invoice with Czech labels and English translation.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -82,16 +79,16 @@ invoice = InvoicePrinter::Document.new(
82
79
  InvoicePrinter.print(
83
80
  document: invoice,
84
81
  labels: labels,
85
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
86
- logo: 'prawn.png',
82
+ font: 'overpass',
83
+ logo: File.expand_path('../prawn.png', __FILE__),
87
84
  file_name: 'international_invoice.pdf'
88
85
  )
89
86
 
90
87
  InvoicePrinter.print(
91
88
  document: invoice,
92
89
  labels: labels,
93
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
94
- logo: 'prawn.png',
90
+ font: 'overpass',
91
+ logo: File.expand_path('../prawn.png', __FILE__),
95
92
  file_name: 'international_invoice_a4.pdf',
96
93
  page_size: :a4
97
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
  )
data/examples/picture.jpg CHANGED
Binary file
data/examples/promo.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a international invoice with Czech labels and English translation.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -49,20 +46,24 @@ second_item = InvoicePrinter::Document::Item.new(
49
46
  amount: 'Kč 9.000'
50
47
  )
51
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
+
52
60
  invoice = InvoicePrinter::Document.new(
53
61
  number: 'č. 198900000001',
54
62
  provider_name: 'Petr Nový',
63
+ provider_lines: provider_address,
55
64
  provider_tax_id: '56565656',
56
- provider_street: 'Rolnická',
57
- provider_street_number: '1',
58
- provider_postcode: '747 05',
59
- provider_city: 'Opava',
60
- provider_city_part: 'Kateřinky',
61
65
  purchaser_name: 'Adam Černý',
62
- purchaser_street: 'Ostravská',
63
- purchaser_street_number: '1',
64
- purchaser_postcode: '747 70',
65
- purchaser_city: 'Opava',
66
+ purchaser_lines: purchaser_address,
66
67
  issue_date: '05/03/2016',
67
68
  due_date: '19/03/2016',
68
69
  subtotal: 'Kč 10.000',
@@ -78,16 +79,16 @@ invoice = InvoicePrinter::Document.new(
78
79
  InvoicePrinter.print(
79
80
  document: invoice,
80
81
  labels: labels,
81
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
82
- logo: 'logo.png',
82
+ font: File.expand_path('../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
83
+ logo: File.expand_path('../logo.png', __FILE__),
83
84
  file_name: 'promo.pdf'
84
85
  )
85
86
 
86
87
  InvoicePrinter.print(
87
88
  document: invoice,
88
89
  labels: labels,
89
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
90
- logo: 'logo.png',
90
+ font: File.expand_path('../../assets/fonts/overpass/Overpass-Regular.ttf', __FILE__),
91
+ logo: File.expand_path('../logo.png', __FILE__),
91
92
  file_name: 'promo_a4.pdf',
92
93
  page_size: :a4
93
94
  )
@@ -1,8 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  # This is an example of a Czech invoice.
3
- #
4
- # Due to the special characters it requires Overpass-Regular.ttf font to be
5
- # present in this directory.
6
3
 
7
4
  lib = File.expand_path('../../lib', __FILE__)
8
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -50,7 +47,8 @@ Rolnická 1
50
47
  747 05 Opava
51
48
  Kateřinky
52
49
 
53
- fith line wont show
50
+
51
+ 6th line wont show
54
52
  ADDRESS
55
53
 
56
54
  purchaser_address = <<ADDRESS
@@ -58,8 +56,7 @@ Ostravská 1
58
56
  747 70 Opava
59
57
 
60
58
 
61
-
62
- fith line wont show
59
+ 6th line wont show
63
60
  ADDRESS
64
61
 
65
62
  invoice = InvoicePrinter::Document.new(
@@ -67,20 +64,11 @@ invoice = InvoicePrinter::Document.new(
67
64
  provider_name: 'Petr Nový',
68
65
  provider_tax_id: '56565656',
69
66
  provider_tax_id2: 'CZ56565656',
70
- provider_street: 'Rolnická',
71
- provider_street_number: '1',
72
- provider_postcode: '747 05',
73
- provider_city: 'Opava',
74
- provider_city_part: 'Kateřinky',
75
67
  provider_lines: provider_address,
76
68
  purchaser_name: 'Adam Černý',
77
- purchaser_street: 'Ostravská',
78
- purchaser_street_number: '1',
79
- purchaser_postcode: '747 70',
80
- purchaser_city: 'Opava',
81
- purchaser_lines: purchaser_address,
82
69
  purchaser_tax_id: '56565656',
83
70
  purchaser_tax_id2: 'CZ56565656',
71
+ purchaser_lines: purchaser_address,
84
72
  issue_date: '05/03/2016',
85
73
  due_date: '19/03/2016',
86
74
  subtotal: 'Kč 10.000',
@@ -96,16 +84,16 @@ invoice = InvoicePrinter::Document.new(
96
84
  InvoicePrinter.print(
97
85
  document: invoice,
98
86
  labels: labels,
99
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
100
- logo: 'prawn.png',
87
+ font: 'overpass',
88
+ logo: File.expand_path('../prawn.png', __FILE__),
101
89
  file_name: 'provider_purchaser_lines.pdf'
102
90
  )
103
91
 
104
92
  InvoicePrinter.print(
105
93
  document: invoice,
106
94
  labels: labels,
107
- font: File.expand_path('../Overpass-Regular.ttf', __FILE__),
108
- logo: 'prawn.png',
95
+ font: 'overpass',
96
+ logo: File.expand_path('../prawn.png', __FILE__),
109
97
  file_name: 'provider_purchaser_lines_a4.pdf',
110
98
  page_size: :a4
111
99
  )
@@ -5,6 +5,16 @@ lib = File.expand_path('../../lib', __FILE__)
5
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
6
  require 'invoice_printer'
7
7
 
8
+ provider_address = <<ADDRESS
9
+ 5th Avenue
10
+ 747 05 NYC
11
+ ADDRESS
12
+
13
+ purchaser_address = <<ADDRESS
14
+ 7th Avenue
15
+ 747 70 NYC
16
+ ADDRESS
17
+
8
18
  item = InvoicePrinter::Document::Item.new(
9
19
  name: 'Programming',
10
20
  quantity: '10',
@@ -16,36 +26,25 @@ item = InvoicePrinter::Document::Item.new(
16
26
  invoice = InvoicePrinter::Document.new(
17
27
  number: 'NO. 198900000001',
18
28
  provider_name: 'John White',
19
- # Deprecated 1.3 API, use provider_lines
20
- # Here for compatibility test
21
- provider_street: '5th Avenue',
22
- provider_street_number: '1',
23
- provider_postcode: '747 05',
24
- provider_city: 'NYC',
25
- purchaser_name: 'Will Black',
26
- # Deprecated 1.3 API, use purchaser_lines
27
- # Here for compatibility test
28
- purchaser_street: '7th Avenue',
29
- purchaser_street_number: '1',
30
- purchaser_postcode: '747 70',
31
- purchaser_city: 'NYC',
29
+ provider_lines: provider_address,
30
+ purchaser_lines: purchaser_address,
32
31
  issue_date: '05/03/2016',
33
32
  due_date: '19/03/2016',
34
33
  total: '$ 900',
35
34
  bank_account_number: '156546546465',
36
35
  items: [item],
37
- note: 'This is a note at the end.'
36
+ note: "This is a note at the end.\nA note with two lines."
38
37
  )
39
38
 
40
39
  InvoicePrinter.print(
41
40
  document: invoice,
42
- logo: 'prawn.png',
41
+ logo: File.expand_path('../prawn.png', __FILE__),
43
42
  file_name: 'simple_invoice.pdf'
44
43
  )
45
44
 
46
45
  InvoicePrinter.print(
47
46
  document: invoice,
48
- logo: 'prawn.png',
47
+ logo: File.expand_path('../prawn.png', __FILE__),
49
48
  file_name: 'simple_invoice_a4.pdf',
50
49
  page_size: :a4
51
50
  )
@@ -2,11 +2,22 @@ lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'invoice_printer/version'
4
4
 
5
- SERVER_FILES = [
5
+ ONLY_SERVER_FILES = [
6
6
  'bin/invoice_printer_server',
7
7
  'lib/invoice_printer/server.rb'
8
8
  ]
9
9
 
10
+ ONLY_FONTS_FILES = [
11
+ 'FONTS_LICENSE.txt',
12
+ 'assets/fonts/overpass/OFL-1.1.txt',
13
+ 'assets/fonts/overpass/Overpass-Regular.ttf',
14
+ 'assets/fonts/opensans/Apache-2.0.txt',
15
+ 'assets/fonts/opensans/OpenSans-Regular.ttf',
16
+ 'assets/fonts/roboto/Apache-2.0.txt',
17
+ 'assets/fonts/roboto/Roboto-Regular.ttf',
18
+ 'lib/invoice_printer/fonts.rb'
19
+ ]
20
+
10
21
  Gem::Specification.new do |spec|
11
22
  spec.name = 'invoice_printer'
12
23
  spec.version = InvoicePrinter::VERSION
@@ -20,7 +31,9 @@ Gem::Specification.new do |spec|
20
31
  # Remove server files
21
32
  # Remove .pdf files as they take a lot of space
22
33
  package_files = `git ls-files -z`.split("\x0")
23
- .reject{ |file| SERVER_FILES.include?(file) }
34
+ .reject{ |file| ONLY_SERVER_FILES.include?(file) }
35
+ .reject{ |file| ONLY_FONTS_FILES.include?(file) }
36
+ .reject{ |file| file.match /.*\.png/ }
24
37
  .reject{ |file| file.match /.*\.pdf/ }
25
38
 
26
39
  spec.files = package_files
@@ -32,8 +45,8 @@ Gem::Specification.new do |spec|
32
45
  spec.required_ruby_version = '>= 2.4'
33
46
 
34
47
  spec.add_dependency 'json', '~> 2.1'
35
- spec.add_dependency 'prawn', '~> 2.1.0'
36
- spec.add_dependency 'prawn-layout', '~> 0.8.4'
48
+ spec.add_dependency 'prawn', '~> 2.2'
49
+ spec.add_dependency 'prawn-table', '~> 0.2.2'
37
50
 
38
51
  spec.add_development_dependency 'bundler', '>= 1.7'
39
52
  spec.add_development_dependency 'rake', '>= 10.0'
@@ -0,0 +1,39 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'invoice_printer/version'
4
+
5
+ FONTS_FILES = [
6
+ 'LICENSE.txt',
7
+ 'FONTS_LICENSE.txt',
8
+ 'assets/fonts/overpass/OFL-1.1.txt',
9
+ 'assets/fonts/overpass/Overpass-Regular.ttf',
10
+ 'assets/fonts/opensans/Apache-2.0.txt',
11
+ 'assets/fonts/opensans/OpenSans-Regular.ttf',
12
+ 'assets/fonts/roboto/Apache-2.0.txt',
13
+ 'assets/fonts/roboto/Roboto-Regular.ttf',
14
+ 'lib/invoice_printer/fonts.rb'
15
+ ]
16
+
17
+ Gem::Specification.new do |spec|
18
+ spec.name = 'invoice_printer_fonts'
19
+ spec.version = InvoicePrinter::VERSION
20
+ spec.authors = ['Josef Strzibny']
21
+ spec.email = ['strzibny@strzibny.name']
22
+ spec.summary = 'Super simple PDF invoicing in pure Ruby'
23
+ spec.description = 'Super simple and fast PDF invoicing in pure Ruby (based on Prawn library).'
24
+ spec.homepage = 'https://github.com/strzibny/invoice_printer'
25
+ spec.licenses = ['MIT', 'OFL 1.1', 'Apache 2.0']
26
+
27
+ # Include only font files
28
+ spec.files = FONTS_FILES
29
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.required_ruby_version = '>= 2.4'
34
+
35
+ spec.add_dependency 'invoice_printer', InvoicePrinter::VERSION
36
+
37
+ spec.add_development_dependency 'bundler', '>= 1.7'
38
+ spec.add_development_dependency 'rake', '>= 10.0'
39
+ end
@@ -3,6 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'invoice_printer/version'
4
4
 
5
5
  SERVER_FILES = [
6
+ 'LICENSE.txt',
6
7
  'bin/invoice_printer_server',
7
8
  'lib/invoice_printer/server.rb',
8
9
  'lib/invoice_printer/version.rb'
@@ -39,25 +39,11 @@ module InvoicePrinter
39
39
  :provider_tax_id,
40
40
  :provider_tax_id2,
41
41
  :provider_lines,
42
- # Provider address fields
43
- :provider_street,
44
- :provider_street_number,
45
- :provider_postcode,
46
- :provider_city,
47
- :provider_city_part,
48
- :provider_extra_address_line,
49
42
  # Purchaser fields
50
43
  :purchaser_name,
51
44
  :purchaser_tax_id,
52
45
  :purchaser_tax_id2,
53
46
  :purchaser_lines,
54
- # Purchaser address fields
55
- :purchaser_street,
56
- :purchaser_street_number,
57
- :purchaser_postcode,
58
- :purchaser_city,
59
- :purchaser_city_part,
60
- :purchaser_extra_address_line,
61
47
  :issue_date,
62
48
  :due_date,
63
49
  # Account details
@@ -76,113 +62,75 @@ module InvoicePrinter
76
62
  class << self
77
63
  def from_json(json)
78
64
  new(
79
- number: json['number'],
80
- provider_name: json['provider_name'],
81
- provider_tax_id: json['provider_tax_id'],
82
- provider_tax_id2: json['provider_tax_id2'],
83
- provider_street: json['provider_street'],
84
- provider_street_number: json['provider_street_number'],
85
- provider_postcode: json['provider_postcode'],
86
- provider_city: json['provider_city'],
87
- provider_city_part: json['provider_city_part'],
88
- provider_extra_address_line: json['provider_extra_address_line'],
89
- provider_lines: json['provider_lines'],
90
- purchaser_name: json['purchaser_name'],
91
- purchaser_tax_id: json['purchaser_tax_id'],
92
- purchaser_tax_id2: json['purchaser_tax_id2'],
93
- purchaser_street: json['purchaser_street'],
94
- purchaser_street_number: json['purchaser_street_number'],
95
- purchaser_postcode: json['purchaser_postcode'],
96
- purchaser_city: json['purchaser_city'],
97
- purchaser_city_part: json['purchaser_city_part'],
98
- purchaser_extra_address_line: json['purchaser_extra_address_line'],
99
- purchaser_lines: json['purchaser_lines'],
100
- issue_date: json['issue_date'],
101
- due_date: json['due_date'],
102
- subtotal: json['subtotal'],
103
- tax: json['tax'],
104
- tax2: json['tax2'],
105
- tax3: json['tax3'],
106
- total: json['total'],
107
- bank_account_number: json['bank_account_number'],
108
- account_iban: json['account_iban'],
109
- account_swift: json['account_swift'],
110
- note: json['note'],
65
+ number: json['number'],
66
+ provider_name: json['provider_name'],
67
+ provider_tax_id: json['provider_tax_id'],
68
+ provider_tax_id2: json['provider_tax_id2'],
69
+ provider_lines: json['provider_lines'],
70
+ purchaser_name: json['purchaser_name'],
71
+ purchaser_tax_id: json['purchaser_tax_id'],
72
+ purchaser_tax_id2: json['purchaser_tax_id2'],
73
+ purchaser_lines: json['purchaser_lines'],
74
+ issue_date: json['issue_date'],
75
+ due_date: json['due_date'],
76
+ subtotal: json['subtotal'],
77
+ tax: json['tax'],
78
+ tax2: json['tax2'],
79
+ tax3: json['tax3'],
80
+ total: json['total'],
81
+ bank_account_number: json['bank_account_number'],
82
+ account_iban: json['account_iban'],
83
+ account_swift: json['account_swift'],
84
+ note: json['note'],
111
85
 
112
- items: (json['items'] || []).map { |item_json| Item.from_json(item_json) }
86
+ items: (json['items'] || []).map { |item_json| Item.from_json(item_json) }
113
87
  )
114
88
  end
115
89
  end
116
90
 
117
- def initialize(number: nil,
118
- provider_name: nil,
119
- provider_tax_id: nil,
120
- provider_tax_id2: nil,
121
- provider_street: nil,
122
- provider_street_number: nil,
123
- provider_postcode: nil,
124
- provider_city: nil,
125
- provider_city_part: nil,
126
- provider_extra_address_line: nil,
127
- provider_lines: nil,
128
- purchaser_name: nil,
129
- purchaser_tax_id: nil,
130
- purchaser_tax_id2: nil,
131
- purchaser_street: nil,
132
- purchaser_street_number: nil,
133
- purchaser_postcode: nil,
134
- purchaser_city: nil,
135
- purchaser_city_part: nil,
136
- purchaser_extra_address_line: nil,
137
- purchaser_lines: nil,
138
- issue_date: nil,
139
- due_date: nil,
140
- subtotal: nil,
141
- tax: nil,
142
- tax2: nil,
143
- tax3: nil,
144
- total: nil,
145
- bank_account_number: nil,
146
- account_iban: nil,
147
- account_swift: nil,
148
- items: nil,
149
- note: nil)
150
-
151
- @number = String(number)
152
- @provider_name = String(provider_name)
153
- @provider_tax_id = String(provider_tax_id)
154
- @provider_tax_id2 = String(provider_tax_id2)
155
- @provider_street = String(provider_street)
156
- @provider_street_number = String(provider_street_number)
157
- @provider_postcode = String(provider_postcode)
158
- @provider_city = String(provider_city)
159
- @provider_city_part = String(provider_city_part)
160
- @provider_extra_address_line = String(provider_extra_address_line)
161
- @provider_lines = String(provider_lines)
162
- @purchaser_name = String(purchaser_name)
163
- @purchaser_tax_id = String(purchaser_tax_id)
164
- @purchaser_tax_id2 = String(purchaser_tax_id2)
165
- @purchaser_street = String(purchaser_street)
166
- @purchaser_street_number = String(purchaser_street_number)
167
- @purchaser_postcode = String(purchaser_postcode)
168
- @purchaser_city = String(purchaser_city)
169
- @purchaser_city_part = String(purchaser_city_part)
170
- @purchaser_extra_address_line = String(purchaser_extra_address_line)
171
- @purchaser_lines = String(purchaser_lines)
172
- @issue_date = String(issue_date)
173
- @due_date = String(due_date)
174
- @subtotal = String(subtotal)
175
- @tax = String(tax)
176
- @tax2 = String(tax2)
177
- @tax3 = String(tax3)
178
- @total = String(total)
179
- @bank_account_number = String(bank_account_number)
180
- @account_iban = String(account_iban)
181
- @account_swift = String(account_swift)
182
- @items = items
183
- @note = String(note)
184
-
91
+ def initialize(number: nil,
92
+ provider_name: nil,
93
+ provider_tax_id: nil,
94
+ provider_tax_id2: nil,
95
+ provider_lines: nil,
96
+ purchaser_name: nil,
97
+ purchaser_tax_id: nil,
98
+ purchaser_tax_id2: nil,
99
+ purchaser_lines: nil,
100
+ issue_date: nil,
101
+ due_date: nil,
102
+ subtotal: nil,
103
+ tax: nil,
104
+ tax2: nil,
105
+ tax3: nil,
106
+ total: nil,
107
+ bank_account_number: nil,
108
+ account_iban: nil,
109
+ account_swift: nil,
110
+ items: nil,
111
+ note: nil)
185
112
 
113
+ @number = String(number)
114
+ @provider_name = String(provider_name)
115
+ @provider_tax_id = String(provider_tax_id)
116
+ @provider_tax_id2 = String(provider_tax_id2)
117
+ @provider_lines = String(provider_lines)
118
+ @purchaser_name = String(purchaser_name)
119
+ @purchaser_tax_id = String(purchaser_tax_id)
120
+ @purchaser_tax_id2 = String(purchaser_tax_id2)
121
+ @purchaser_lines = String(purchaser_lines)
122
+ @issue_date = String(issue_date)
123
+ @due_date = String(due_date)
124
+ @subtotal = String(subtotal)
125
+ @tax = String(tax)
126
+ @tax2 = String(tax2)
127
+ @tax3 = String(tax3)
128
+ @total = String(total)
129
+ @bank_account_number = String(bank_account_number)
130
+ @account_iban = String(account_iban)
131
+ @account_swift = String(account_swift)
132
+ @items = items
133
+ @note = String(note)
186
134
 
187
135
  raise InvalidInput, 'items are not only a type of InvoicePrinter::Document::Item' \
188
136
  unless @items.select{ |i| !i.is_a?(InvoicePrinter::Document::Item) }.empty?
@@ -190,39 +138,27 @@ module InvoicePrinter
190
138
 
191
139
  def to_h
192
140
  {
193
- 'number': @number,
194
- 'provider_name': @provider_name,
195
- 'provider_tax_id': @provider_tax_id,
196
- 'provider_tax_id2': @provider_tax_id2,
197
- 'provider_street': @provider_street,
198
- 'provider_street_number': @provider_street_number,
199
- 'provider_postcode': @provider_postcode,
200
- 'provider_city': @provider_city,
201
- 'provider_city_part': @provider_city_part,
202
- 'provider_extra_address_line': @provider_extra_address_line,
203
- 'provider_lines': @provider_lines,
204
- 'purchaser_name': @purchaser_name,
205
- 'purchaser_tax_id': @purchaser_tax_id,
206
- 'purchaser_tax_id2': @purchaser_tax_id2,
207
- 'purchaser_street': @purchaser_street,
208
- 'purchaser_street_number': @purchaser_street_number,
209
- 'purchaser_postcode': @purchaser_postcode,
210
- 'purchaser_city': @purchaser_city,
211
- 'purchaser_city_part': @purchaser_city_part,
212
- 'purchaser_extra_address_line': @purchaser_extra_address_line,
213
- 'purchaser_lines': @purchaser_lines,
214
- 'issue_date': @issue_date,
215
- 'due_date': @due_date,
216
- 'subtotal': @subtotal,
217
- 'tax': @tax,
218
- 'tax2': @tax2,
219
- 'tax3': @tax3,
220
- 'total': @total,
221
- 'bank_account_number': @bank_account_number,
222
- 'account_iban': @account_iban,
223
- 'account_swift': @account_swift,
224
- 'items': @items.map(&:to_h),
225
- 'note': @note
141
+ 'number': @number,
142
+ 'provider_name': @provider_name,
143
+ 'provider_tax_id': @provider_tax_id,
144
+ 'provider_tax_id2': @provider_tax_id2,
145
+ 'provider_lines': @provider_lines,
146
+ 'purchaser_name': @purchaser_name,
147
+ 'purchaser_tax_id': @purchaser_tax_id,
148
+ 'purchaser_tax_id2': @purchaser_tax_id2,
149
+ 'purchaser_lines': @purchaser_lines,
150
+ 'issue_date': @issue_date,
151
+ 'due_date': @due_date,
152
+ 'subtotal': @subtotal,
153
+ 'tax': @tax,
154
+ 'tax2': @tax2,
155
+ 'tax3': @tax3,
156
+ 'total': @total,
157
+ 'bank_account_number': @bank_account_number,
158
+ 'account_iban': @account_iban,
159
+ 'account_swift': @account_swift,
160
+ 'items': @items.map(&:to_h),
161
+ 'note': @note
226
162
  }
227
163
  end
228
164