invoice_printer 1.0.0 → 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +62 -5
- data/bin/invoice_printer +140 -0
- data/examples/complex_invoice.rb +11 -1
- data/examples/czech_invoice.rb +12 -0
- data/examples/international_invoice.rb +9 -0
- data/examples/long_invoice.rb +9 -1
- data/examples/promo.rb +9 -0
- data/examples/simple_invoice.rb +7 -0
- data/invoice_printer.gemspec +1 -0
- data/lib/invoice_printer/document/item.rb +37 -21
- data/lib/invoice_printer/document.rb +130 -90
- data/lib/invoice_printer/pdf_document.rb +153 -108
- data/lib/invoice_printer/version.rb +1 -1
- data/lib/invoice_printer.rb +6 -4
- data/test/cli_test.rb +76 -0
- data/test/examples_test.rb +5 -0
- data/test/inputs_test.rb +9 -0
- data/test/invoice_printer_test.rb +13 -2
- metadata +9 -5
@@ -83,68 +83,108 @@ module InvoicePrinter
|
|
83
83
|
:items,
|
84
84
|
:note
|
85
85
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
86
|
+
class << self
|
87
|
+
def from_json(json)
|
88
|
+
new(
|
89
|
+
number: json['number'],
|
90
|
+
provider_name: json['provider_name'],
|
91
|
+
provider_tax_id: json['provider_tax_id'],
|
92
|
+
provider_tax_id2: json['provider_tax_id2'],
|
93
|
+
provider_street: json['provider_street'],
|
94
|
+
provider_street_number: json['provider_street_number'],
|
95
|
+
provider_postcode: json['provider_postcode'],
|
96
|
+
provider_city: json['provider_city'],
|
97
|
+
provider_city_part: json['provider_city_part'],
|
98
|
+
provider_extra_address_line: json['provider_extra_address_line'],
|
99
|
+
purchaser_name: json['purchaser_name'],
|
100
|
+
purchaser_tax_id: json['purchaser_tax_id'],
|
101
|
+
purchaser_tax_id2: json['purchaser_tax_id2'],
|
102
|
+
purchaser_street: json['purchaser_street'],
|
103
|
+
purchaser_street_number: json['purchaser_street_number'],
|
104
|
+
purchaser_postcode: json['purchaser_postcode'],
|
105
|
+
purchaser_city: json['purchaser_city'],
|
106
|
+
purchaser_city_part: json['purchaser_city_part'],
|
107
|
+
purchaser_extra_address_line: json['purchaser_extra_address_line'],
|
108
|
+
issue_date: json['issue_date'],
|
109
|
+
due_date: json['due_date'],
|
110
|
+
subtotal: json['subtotal'],
|
111
|
+
tax: json['tax'],
|
112
|
+
tax2: json['tax2'],
|
113
|
+
tax3: json['tax3'],
|
114
|
+
total: json['total'],
|
115
|
+
bank_account_number: json['bank_account_number'],
|
116
|
+
account_iban: json['account_iban'],
|
117
|
+
account_swift: json['account_swift'],
|
118
|
+
note: json['note'],
|
119
|
+
|
120
|
+
items: (json['items'] || []).map { |item_json| Item.from_json(item_json) }
|
121
|
+
)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def initialize(number: nil,
|
126
|
+
provider_name: nil,
|
127
|
+
provider_tax_id: nil,
|
128
|
+
provider_tax_id2: nil,
|
129
|
+
provider_street: nil,
|
130
|
+
provider_street_number: nil,
|
131
|
+
provider_postcode: nil,
|
132
|
+
provider_city: nil,
|
133
|
+
provider_city_part: nil,
|
134
|
+
provider_extra_address_line: nil,
|
135
|
+
purchaser_name: nil,
|
136
|
+
purchaser_tax_id: nil,
|
137
|
+
purchaser_tax_id2: nil,
|
138
|
+
purchaser_street: nil,
|
139
|
+
purchaser_street_number: nil,
|
140
|
+
purchaser_postcode: nil,
|
141
|
+
purchaser_city: nil,
|
142
|
+
purchaser_city_part: nil,
|
104
143
|
purchaser_extra_address_line: nil,
|
105
|
-
issue_date:
|
106
|
-
due_date:
|
107
|
-
subtotal:
|
108
|
-
tax:
|
109
|
-
tax2:
|
110
|
-
tax3:
|
111
|
-
total:
|
112
|
-
bank_account_number:
|
113
|
-
account_iban:
|
114
|
-
account_swift:
|
115
|
-
items:
|
116
|
-
note:
|
117
|
-
|
118
|
-
@
|
119
|
-
@
|
120
|
-
@
|
121
|
-
@
|
122
|
-
@
|
123
|
-
@
|
124
|
-
@
|
125
|
-
@
|
126
|
-
@
|
127
|
-
@
|
128
|
-
@
|
129
|
-
@
|
130
|
-
@
|
131
|
-
@
|
132
|
-
@
|
133
|
-
@
|
134
|
-
@
|
144
|
+
issue_date: nil,
|
145
|
+
due_date: nil,
|
146
|
+
subtotal: nil,
|
147
|
+
tax: nil,
|
148
|
+
tax2: nil,
|
149
|
+
tax3: nil,
|
150
|
+
total: nil,
|
151
|
+
bank_account_number: nil,
|
152
|
+
account_iban: nil,
|
153
|
+
account_swift: nil,
|
154
|
+
items: nil,
|
155
|
+
note: nil)
|
156
|
+
|
157
|
+
@number = String(number)
|
158
|
+
@provider_name = String(provider_name)
|
159
|
+
@provider_tax_id = String(provider_tax_id)
|
160
|
+
@provider_tax_id2 = String(provider_tax_id2)
|
161
|
+
@provider_street = String(provider_street)
|
162
|
+
@provider_street_number = String(provider_street_number)
|
163
|
+
@provider_postcode = String(provider_postcode)
|
164
|
+
@provider_city = String(provider_city)
|
165
|
+
@provider_city_part = String(provider_city_part)
|
166
|
+
@provider_extra_address_line = String(provider_extra_address_line)
|
167
|
+
@purchaser_name = String(purchaser_name)
|
168
|
+
@purchaser_tax_id = String(purchaser_tax_id)
|
169
|
+
@purchaser_tax_id2 = String(purchaser_tax_id2)
|
170
|
+
@purchaser_street = String(purchaser_street)
|
171
|
+
@purchaser_street_number = String(purchaser_street_number)
|
172
|
+
@purchaser_postcode = String(purchaser_postcode)
|
173
|
+
@purchaser_city = String(purchaser_city)
|
174
|
+
@purchaser_city_part = String(purchaser_city_part)
|
135
175
|
@purchaser_extra_address_line = String(purchaser_extra_address_line)
|
136
|
-
@issue_date
|
137
|
-
@due_date
|
138
|
-
@subtotal
|
139
|
-
@tax
|
140
|
-
@tax2
|
141
|
-
@tax3
|
142
|
-
@total
|
143
|
-
@bank_account_number
|
144
|
-
@account_iban
|
145
|
-
@account_swift
|
146
|
-
@items
|
147
|
-
@note
|
176
|
+
@issue_date = String(issue_date)
|
177
|
+
@due_date = String(due_date)
|
178
|
+
@subtotal = String(subtotal)
|
179
|
+
@tax = String(tax)
|
180
|
+
@tax2 = String(tax2)
|
181
|
+
@tax3 = String(tax3)
|
182
|
+
@total = String(total)
|
183
|
+
@bank_account_number = String(bank_account_number)
|
184
|
+
@account_iban = String(account_iban)
|
185
|
+
@account_swift = String(account_swift)
|
186
|
+
@items = items
|
187
|
+
@note = String(note)
|
148
188
|
|
149
189
|
raise InvalidInput, 'items are not only a type of InvoicePrinter::Document::Item' \
|
150
190
|
unless @items.select{ |i| !i.is_a?(InvoicePrinter::Document::Item) }.empty?
|
@@ -152,37 +192,37 @@ module InvoicePrinter
|
|
152
192
|
|
153
193
|
def to_h
|
154
194
|
{
|
155
|
-
'number':
|
156
|
-
'provider_name':
|
157
|
-
'provider_tax_id':
|
158
|
-
'provider_tax_id2':
|
159
|
-
'provider_street':
|
160
|
-
'provider_street_number':
|
161
|
-
'provider_postcode':
|
162
|
-
'provider_city':
|
163
|
-
'provider_city_part':
|
164
|
-
'provider_extra_address_line':
|
165
|
-
'purchaser_name':
|
166
|
-
'purchaser_tax_id':
|
167
|
-
'purchaser_tax_id2':
|
168
|
-
'purchaser_street':
|
169
|
-
'purchaser_street_number':
|
170
|
-
'purchaser_postcode':
|
171
|
-
'purchaser_city':
|
172
|
-
'purchaser_city_part':
|
195
|
+
'number': @number,
|
196
|
+
'provider_name': @provider_name,
|
197
|
+
'provider_tax_id': @provider_tax_id,
|
198
|
+
'provider_tax_id2': @provider_tax_id2,
|
199
|
+
'provider_street': @provider_street,
|
200
|
+
'provider_street_number': @provider_street_number,
|
201
|
+
'provider_postcode': @provider_postcode,
|
202
|
+
'provider_city': @provider_city,
|
203
|
+
'provider_city_part': @provider_city_part,
|
204
|
+
'provider_extra_address_line': @provider_extra_address_line,
|
205
|
+
'purchaser_name': @purchaser_name,
|
206
|
+
'purchaser_tax_id': @purchaser_tax_id,
|
207
|
+
'purchaser_tax_id2': @purchaser_tax_id2,
|
208
|
+
'purchaser_street': @purchaser_street,
|
209
|
+
'purchaser_street_number': @purchaser_street_number,
|
210
|
+
'purchaser_postcode': @purchaser_postcode,
|
211
|
+
'purchaser_city': @purchaser_city,
|
212
|
+
'purchaser_city_part': @purchaser_city_part,
|
173
213
|
'purchaser_extra_address_line': @purchaser_extra_address_line,
|
174
|
-
'issue_date':
|
175
|
-
'due_date':
|
176
|
-
'subtotal':
|
177
|
-
'tax':
|
178
|
-
'tax2':
|
179
|
-
'tax3':
|
180
|
-
'total':
|
181
|
-
'bank_account_number':
|
182
|
-
'account_iban':
|
183
|
-
'account_swift':
|
184
|
-
'items':
|
185
|
-
'note':
|
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
|
186
226
|
}
|
187
227
|
end
|
188
228
|
|