invoicing 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -0
- data/README.md +57 -0
- data/Rakefile +16 -37
- data/lib/invoicing.rb +20 -10
- data/lib/invoicing/cached_record.rb +9 -6
- data/lib/invoicing/class_info.rb +34 -34
- data/lib/invoicing/connection_adapter_ext.rb +4 -4
- data/lib/invoicing/countries/uk.rb +6 -6
- data/lib/invoicing/currency_value.rb +39 -32
- data/lib/invoicing/find_subclasses.rb +40 -15
- data/lib/invoicing/ledger_item.rb +166 -145
- data/lib/invoicing/ledger_item/pdf_generator.rb +108 -0
- data/lib/invoicing/ledger_item/render_html.rb +76 -73
- data/lib/invoicing/ledger_item/render_ubl.rb +37 -35
- data/lib/invoicing/line_item.rb +43 -38
- data/lib/invoicing/price.rb +1 -1
- data/lib/invoicing/tax_rate.rb +3 -6
- data/lib/invoicing/taxable.rb +37 -32
- data/lib/invoicing/time_dependent.rb +40 -40
- data/lib/invoicing/version.rb +4 -4
- data/lib/rails/generators/invoicing/invoicing_generator.rb +14 -0
- data/lib/rails/generators/invoicing/ledger_item/ledger_item_generator.rb +17 -0
- data/lib/rails/generators/invoicing/ledger_item/templates/migration.rb +25 -0
- data/lib/rails/generators/invoicing/ledger_item/templates/model.rb +5 -0
- data/lib/rails/generators/invoicing/line_item/line_item_generator.rb +17 -0
- data/lib/rails/generators/invoicing/line_item/templates/migration.rb +20 -0
- data/lib/rails/generators/invoicing/line_item/templates/model.rb +5 -0
- data/lib/rails/generators/invoicing/tax_rate/tax_rate_generator.rb +17 -0
- data/lib/rails/generators/invoicing/tax_rate/templates/migration.rb +14 -0
- data/lib/rails/generators/invoicing/tax_rate/templates/model.rb +3 -0
- metadata +110 -153
- data.tar.gz.sig +0 -1
- data/History.txt +0 -31
- data/Manifest.txt +0 -62
- data/PostInstall.txt +0 -10
- data/README.rdoc +0 -58
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/tasks/rcov.rake +0 -4
- data/test/cached_record_test.rb +0 -100
- data/test/class_info_test.rb +0 -253
- data/test/connection_adapter_ext_test.rb +0 -79
- data/test/currency_value_test.rb +0 -209
- data/test/find_subclasses_test.rb +0 -120
- data/test/fixtures/README +0 -7
- data/test/fixtures/cached_record.sql +0 -22
- data/test/fixtures/class_info.sql +0 -28
- data/test/fixtures/currency_value.sql +0 -29
- data/test/fixtures/find_subclasses.sql +0 -43
- data/test/fixtures/ledger_item.sql +0 -39
- data/test/fixtures/line_item.sql +0 -33
- data/test/fixtures/price.sql +0 -4
- data/test/fixtures/tax_rate.sql +0 -4
- data/test/fixtures/taxable.sql +0 -14
- data/test/fixtures/time_dependent.sql +0 -35
- data/test/ledger_item_test.rb +0 -444
- data/test/line_item_test.rb +0 -139
- data/test/models/README +0 -4
- data/test/models/test_subclass_in_another_file.rb +0 -3
- data/test/models/test_subclass_not_in_database.rb +0 -6
- data/test/price_test.rb +0 -9
- data/test/ref-output/creditnote3.html +0 -82
- data/test/ref-output/creditnote3.xml +0 -89
- data/test/ref-output/invoice1.html +0 -93
- data/test/ref-output/invoice1.xml +0 -111
- data/test/ref-output/invoice2.html +0 -86
- data/test/ref-output/invoice2.xml +0 -98
- data/test/ref-output/invoice_null.html +0 -36
- data/test/render_html_test.rb +0 -70
- data/test/render_ubl_test.rb +0 -44
- data/test/setup.rb +0 -37
- data/test/tax_rate_test.rb +0 -9
- data/test/taxable_test.rb +0 -180
- data/test/test_helper.rb +0 -72
- data/test/time_dependent_test.rb +0 -180
- metadata.gz.sig +0 -4
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'prawn'
|
2
|
+
|
3
|
+
# This class is responsible for generating a pdf for an invoice. It assumes that
|
4
|
+
# you have installed pdf library called prawn. Just pass an invoice, and call
|
5
|
+
# render by passing the file.
|
6
|
+
#
|
7
|
+
# generator = Invoicing::LedgerItem::PdfGenerator.new(invoice)
|
8
|
+
# generator.render('/path/to/pdf-file/to/be/generated')
|
9
|
+
#
|
10
|
+
module Invoicing
|
11
|
+
module LedgerItem
|
12
|
+
class PdfGenerator
|
13
|
+
def initialize(invoice)
|
14
|
+
@invoice = invoice
|
15
|
+
end
|
16
|
+
attr_reader :invoice
|
17
|
+
|
18
|
+
def render(file)
|
19
|
+
Prawn::Document.generate(file) do |pdf|
|
20
|
+
render_headers(pdf)
|
21
|
+
render_details(pdf)
|
22
|
+
render_summary(pdf)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def render_headers(pdf)
|
29
|
+
pdf.table([ ['Invoice Receipt'] ], width: 540, cell_style: {padding: 0}) do
|
30
|
+
row(0..10).borders = []
|
31
|
+
cells.column(0).style(size: 20, font_style: :bold, valign: :center)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Renders details about pdf. Shows recipient name, invoice date and id
|
36
|
+
def render_details(pdf)
|
37
|
+
pdf.move_down 10
|
38
|
+
pdf.stroke_horizontal_rule
|
39
|
+
pdf.move_down 15
|
40
|
+
|
41
|
+
billing_details =
|
42
|
+
pdf.make_table([ ['Billed to:'], [recipient_name] ],
|
43
|
+
width: 355, cell_style: {padding: 0}) do
|
44
|
+
row(0..10).style(size: 9, borders: [])
|
45
|
+
row(0).column(0).style(font_style: :bold)
|
46
|
+
end
|
47
|
+
|
48
|
+
invoice_date = invoice.created_at.strftime('%e %b %Y')
|
49
|
+
invoice_id = invoice.id.to_s
|
50
|
+
invoice_details =
|
51
|
+
pdf.make_table([ ['Invoice Date:', invoice_date], ['Invoice No:', invoice_id] ],
|
52
|
+
width: 185, cell_style: {padding: 5, border_width: 0.5}) do
|
53
|
+
row(0..10).style(size: 9)
|
54
|
+
row(0..10).column(0).style(font_style: :bold)
|
55
|
+
end
|
56
|
+
|
57
|
+
pdf.table([ [billing_details, invoice_details] ], cell_style: {padding: 0}) do
|
58
|
+
row(0..10).style(borders: [])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Renders details of invoice in a tabular format. Renders each line item, and
|
63
|
+
# unit price, and total amount, along with tax. It also displays summary,
|
64
|
+
# ie total amount, and total price along with tax.
|
65
|
+
def render_summary(pdf)
|
66
|
+
pdf.move_down 25
|
67
|
+
pdf.text 'Invoice Summary', size: 12, style: :bold
|
68
|
+
pdf.stroke_horizontal_rule
|
69
|
+
|
70
|
+
table_details = [ ['Sl. no.', 'Description', 'Unit price', 'Total Price'] ]
|
71
|
+
invoice.line_items.each_with_index do |line_item, index|
|
72
|
+
net_amount = line_item.net_amount_formatted
|
73
|
+
table_details <<
|
74
|
+
[index + 1, line_item.description, '10', net_amount]
|
75
|
+
end
|
76
|
+
pdf.table(table_details, column_widths: [40, 380, 60, 60], header: true,
|
77
|
+
cell_style: {padding: 5, border_width: 0.5}) do
|
78
|
+
row(0).style(size: 10, font_style: :bold)
|
79
|
+
row(0..100).style(size: 9)
|
80
|
+
|
81
|
+
cells.columns(0).align = :right
|
82
|
+
cells.columns(2).align = :right
|
83
|
+
cells.columns(3).align = :right
|
84
|
+
row(0..100).borders = [:top, :bottom]
|
85
|
+
end
|
86
|
+
|
87
|
+
summary_details = [
|
88
|
+
['Subtotal', invoice.net_amount_formatted],
|
89
|
+
['Tax', invoice.tax_amount_formatted],
|
90
|
+
['Total', invoice.total_amount_formatted]
|
91
|
+
]
|
92
|
+
pdf.table(summary_details, column_widths: [480, 60], header: true,
|
93
|
+
cell_style: {padding: 5, border_width: 0.5}) do
|
94
|
+
row(0..100).style(size: 9, font_style: :bold)
|
95
|
+
row(0..100).borders = []
|
96
|
+
cells.columns(0..100).align = :right
|
97
|
+
end
|
98
|
+
|
99
|
+
pdf.move_down 25
|
100
|
+
pdf.stroke_horizontal_rule
|
101
|
+
end
|
102
|
+
|
103
|
+
def recipient_name
|
104
|
+
invoice.recipient.respond_to?(:name) ? invoice.recipient.name : ''
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
require "active_support/concern"
|
3
4
|
require 'builder'
|
4
5
|
|
5
6
|
module Invoicing
|
6
7
|
module LedgerItem
|
7
8
|
# Included into ActiveRecord model object when +acts_as_ledger_item+ is invoked.
|
8
9
|
module RenderHTML
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
|
9
12
|
# Shortcut for rendering an invoice or a credit note into a human-readable HTML format.
|
10
13
|
# Can be called without any arguments, in which case a general-purpose representation is
|
11
14
|
# produced. Can also be given options and a block for customising the output:
|
@@ -25,14 +28,14 @@ module Invoicing
|
|
25
28
|
yield output_builder if block_given?
|
26
29
|
output_builder.build
|
27
30
|
end
|
28
|
-
|
29
|
-
|
31
|
+
|
32
|
+
|
30
33
|
class HTMLOutputBuilder #:nodoc:
|
31
|
-
|
34
|
+
|
32
35
|
HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
|
33
|
-
|
36
|
+
|
34
37
|
attr_reader :ledger_item, :current_line_item, :options, :custom_fragments, :factor
|
35
|
-
|
38
|
+
|
36
39
|
def initialize(ledger_item, options)
|
37
40
|
@ledger_item = ledger_item
|
38
41
|
@options = default_options
|
@@ -41,7 +44,7 @@ module Invoicing
|
|
41
44
|
total_amount = get(:total_amount)
|
42
45
|
@factor = (total_amount && total_amount < BigDecimal('0')) ? BigDecimal('-1') : BigDecimal('1')
|
43
46
|
end
|
44
|
-
|
47
|
+
|
45
48
|
def default_options
|
46
49
|
line_items = get(:line_items)
|
47
50
|
{
|
@@ -58,7 +61,7 @@ module Invoicing
|
|
58
61
|
def h(s)
|
59
62
|
s.to_s.gsub(/[#{HTML_ESCAPE.keys.join}]/) { |char| HTML_ESCAPE[char] }
|
60
63
|
end
|
61
|
-
|
64
|
+
|
62
65
|
# foo { block } => call block when invoking fragment foo
|
63
66
|
# foo "string" => return string when invoking fragment foo
|
64
67
|
# invoke_foo => invoke fragment foo; if none set, delegate to default_foo
|
@@ -72,7 +75,7 @@ module Invoicing
|
|
72
75
|
return send("default_#{method_id}", *args, &block)
|
73
76
|
end
|
74
77
|
end
|
75
|
-
|
78
|
+
|
76
79
|
return super unless respond_to? "default_#{method_id}"
|
77
80
|
|
78
81
|
if block_given? && args.empty?
|
@@ -83,22 +86,22 @@ module Invoicing
|
|
83
86
|
raise ArgumentError, "#{method_id} expects exactly one value or block argument"
|
84
87
|
end
|
85
88
|
end
|
86
|
-
|
89
|
+
|
87
90
|
# Returns the value of a (potentially renamed) method on the ledger item
|
88
91
|
def get(method_id)
|
89
92
|
ledger_item.send(:ledger_item_class_info).get(ledger_item, method_id)
|
90
93
|
end
|
91
|
-
|
94
|
+
|
92
95
|
# Returns the value of a (potentially renamed) method on a line item
|
93
96
|
def line_get(method_id, line_item = current_line_item)
|
94
97
|
line_item.send(:line_item_class_info).get(line_item, method_id)
|
95
98
|
end
|
96
|
-
|
99
|
+
|
97
100
|
# String for one level of indentation
|
98
101
|
def indent
|
99
102
|
' '
|
100
103
|
end
|
101
|
-
|
104
|
+
|
102
105
|
# This is quite meta. :)
|
103
106
|
#
|
104
107
|
# params_hash(:sender_label, :sender_tax_number => :tax_number_label)
|
@@ -108,13 +111,13 @@ module Invoicing
|
|
108
111
|
result = {}
|
109
112
|
param_names.flatten!
|
110
113
|
options = param_names.extract_options!
|
111
|
-
|
114
|
+
|
112
115
|
param_names.each{|param| result[param.to_sym] = send("invoke_#{param}") }
|
113
|
-
|
116
|
+
|
114
117
|
options.each_pair do |key, value|
|
115
118
|
result[key.to_sym] = send("invoke_#{key}", params_hash(value))
|
116
119
|
end
|
117
|
-
|
120
|
+
|
118
121
|
result
|
119
122
|
end
|
120
123
|
|
@@ -124,7 +127,7 @@ module Invoicing
|
|
124
127
|
:sender_tax_number => :tax_number_label,
|
125
128
|
:recipient_tax_number => :tax_number_label
|
126
129
|
}]
|
127
|
-
|
130
|
+
|
128
131
|
metadata_table_deps = [{
|
129
132
|
:identifier => :identifier_label,
|
130
133
|
:issue_date => [:date_format, :issue_date_label],
|
@@ -132,24 +135,24 @@ module Invoicing
|
|
132
135
|
:period_end => [:date_format, :period_end_label],
|
133
136
|
:due_date => [:date_format, :due_date_label]
|
134
137
|
}]
|
135
|
-
|
138
|
+
|
136
139
|
line_items_header_deps = [:line_tax_point_label, :line_quantity_label, :line_description_label,
|
137
140
|
:line_net_amount_label, :line_tax_amount_label, :line_gross_amount_label]
|
138
|
-
|
141
|
+
|
139
142
|
line_items_subtotal_deps = [:subtotal_label, :net_amount_label, :tax_amount_label,
|
140
143
|
:gross_amount_label, {
|
141
144
|
:net_amount => :net_amount_label,
|
142
145
|
:tax_amount => :tax_amount_label,
|
143
146
|
:total_amount => :gross_amount_label
|
144
147
|
}]
|
145
|
-
|
148
|
+
|
146
149
|
line_items_total_deps = [:total_label, :net_amount_label, :tax_amount_label,
|
147
150
|
:gross_amount_label, {
|
148
151
|
:net_amount => :net_amount_label,
|
149
152
|
:tax_amount => :tax_amount_label,
|
150
153
|
:total_amount => :gross_amount_label
|
151
154
|
}]
|
152
|
-
|
155
|
+
|
153
156
|
page_layout_deps = {
|
154
157
|
:title_tag => :title,
|
155
158
|
:addresses_table => addresses_table_deps,
|
@@ -161,107 +164,107 @@ module Invoicing
|
|
161
164
|
:line_items_total => line_items_total_deps
|
162
165
|
}]
|
163
166
|
}
|
164
|
-
|
167
|
+
|
165
168
|
invoke_page_layout(params_hash(page_layout_deps))
|
166
169
|
end
|
167
|
-
|
170
|
+
|
168
171
|
def default_date_format
|
169
172
|
"%Y-%m-%d"
|
170
173
|
end
|
171
|
-
|
174
|
+
|
172
175
|
def default_invoice_label
|
173
176
|
"Invoice"
|
174
177
|
end
|
175
|
-
|
178
|
+
|
176
179
|
def default_credit_note_label
|
177
180
|
"Credit Note"
|
178
181
|
end
|
179
|
-
|
182
|
+
|
180
183
|
def default_recipient_label
|
181
184
|
"Recipient"
|
182
185
|
end
|
183
|
-
|
186
|
+
|
184
187
|
def default_sender_label
|
185
188
|
"Sender"
|
186
189
|
end
|
187
|
-
|
190
|
+
|
188
191
|
def default_tax_number_label
|
189
192
|
"VAT number:<br />"
|
190
193
|
end
|
191
|
-
|
194
|
+
|
192
195
|
def default_identifier_label
|
193
196
|
label = (factor == BigDecimal('-1')) ? invoke_credit_note_label : invoke_invoice_label
|
194
197
|
"#{label} no.:"
|
195
198
|
end
|
196
|
-
|
199
|
+
|
197
200
|
def default_issue_date_label
|
198
201
|
"Issue date:"
|
199
202
|
end
|
200
|
-
|
203
|
+
|
201
204
|
def default_period_start_label
|
202
205
|
"Period from:"
|
203
206
|
end
|
204
|
-
|
207
|
+
|
205
208
|
def default_period_end_label
|
206
209
|
"Period until:"
|
207
210
|
end
|
208
|
-
|
211
|
+
|
209
212
|
def default_due_date_label
|
210
213
|
"Payment due:"
|
211
214
|
end
|
212
|
-
|
215
|
+
|
213
216
|
def default_line_tax_point_label
|
214
217
|
"Tax point"
|
215
218
|
end
|
216
|
-
|
219
|
+
|
217
220
|
def default_line_quantity_label
|
218
221
|
"Quantity"
|
219
222
|
end
|
220
|
-
|
223
|
+
|
221
224
|
def default_line_description_label
|
222
225
|
"Description"
|
223
226
|
end
|
224
|
-
|
227
|
+
|
225
228
|
def default_line_net_amount_label
|
226
229
|
"Net price"
|
227
230
|
end
|
228
|
-
|
231
|
+
|
229
232
|
def default_line_tax_amount_label
|
230
233
|
"VAT"
|
231
234
|
end
|
232
|
-
|
235
|
+
|
233
236
|
def default_line_gross_amount_label
|
234
237
|
"Gross price"
|
235
238
|
end
|
236
|
-
|
239
|
+
|
237
240
|
def default_subtotal_label
|
238
241
|
"Subtotal"
|
239
242
|
end
|
240
|
-
|
243
|
+
|
241
244
|
def default_total_label
|
242
245
|
"Total"
|
243
246
|
end
|
244
|
-
|
247
|
+
|
245
248
|
def default_net_amount_label
|
246
249
|
"Net: "
|
247
250
|
end
|
248
|
-
|
251
|
+
|
249
252
|
def default_tax_amount_label
|
250
253
|
"VAT: "
|
251
254
|
end
|
252
|
-
|
255
|
+
|
253
256
|
def default_gross_amount_label
|
254
257
|
""
|
255
258
|
end
|
256
|
-
|
259
|
+
|
257
260
|
def default_title
|
258
261
|
(factor == BigDecimal('-1')) ? invoke_credit_note_label : invoke_invoice_label
|
259
262
|
end
|
260
|
-
|
263
|
+
|
261
264
|
def default_title_tag(params)
|
262
265
|
"<h1 class=\"invoice\">#{params[:title]}</h1>\n"
|
263
266
|
end
|
264
|
-
|
267
|
+
|
265
268
|
def default_address(details)
|
266
269
|
details = details.symbolize_keys
|
267
270
|
html = "#{indent*3}<div class=\"fn org\">#{ h(details[:name]) }</div>\n"
|
@@ -274,25 +277,25 @@ module Invoicing
|
|
274
277
|
html << "#{indent*4}<span class=\"country-name\">#{h(details[:country]) }</span>\n" unless details[:country].blank?
|
275
278
|
html << "#{indent*3}</div>\n"
|
276
279
|
end
|
277
|
-
|
280
|
+
|
278
281
|
def default_sender_address
|
279
282
|
invoke_address(get(:sender_details))
|
280
283
|
end
|
281
|
-
|
284
|
+
|
282
285
|
def default_recipient_address
|
283
286
|
invoke_address(get(:recipient_details))
|
284
287
|
end
|
285
|
-
|
288
|
+
|
286
289
|
def default_sender_tax_number(params)
|
287
290
|
sender_tax_number = get(:sender_details).symbolize_keys[:tax_number]
|
288
291
|
"#{params[:tax_number_label]}<span class=\"tax-number\">#{h(sender_tax_number)}</span>"
|
289
292
|
end
|
290
|
-
|
293
|
+
|
291
294
|
def default_recipient_tax_number(params)
|
292
295
|
recipient_tax_number = get(:recipient_details).symbolize_keys[:tax_number]
|
293
296
|
"#{params[:tax_number_label]}<span class=\"tax-number\">#{h(recipient_tax_number)}</span>"
|
294
297
|
end
|
295
|
-
|
298
|
+
|
296
299
|
def default_addresses_table(params)
|
297
300
|
html = "#{indent*0}<table class=\"invoice addresses\">\n"
|
298
301
|
html << "#{indent*1}<tr>\n"
|
@@ -315,7 +318,7 @@ module Invoicing
|
|
315
318
|
html << "#{indent*1}</tr>\n"
|
316
319
|
html << "#{indent*0}</table>\n"
|
317
320
|
end
|
318
|
-
|
321
|
+
|
319
322
|
def default_metadata_item(params, key, value)
|
320
323
|
label = params["#{key}_label".to_sym]
|
321
324
|
html = "#{indent*1}<tr class=\"#{key.to_s.gsub(/_/, '-')}\">\n"
|
@@ -323,11 +326,11 @@ module Invoicing
|
|
323
326
|
html << "#{indent*2}<td>#{h(value)}</td>\n"
|
324
327
|
html << "#{indent*1}</tr>\n"
|
325
328
|
end
|
326
|
-
|
329
|
+
|
327
330
|
def default_identifier(params)
|
328
331
|
invoke_metadata_item(params, :identifier, get(:identifier))
|
329
332
|
end
|
330
|
-
|
333
|
+
|
331
334
|
def default_issue_date(params)
|
332
335
|
if issue_date = get(:issue_date)
|
333
336
|
invoke_metadata_item(params, :issue_date, issue_date.strftime(params[:date_format]))
|
@@ -335,7 +338,7 @@ module Invoicing
|
|
335
338
|
""
|
336
339
|
end
|
337
340
|
end
|
338
|
-
|
341
|
+
|
339
342
|
def default_period_start(params)
|
340
343
|
if period_start = get(:period_start)
|
341
344
|
invoke_metadata_item(params, :period_start, period_start.strftime(params[:date_format]))
|
@@ -343,7 +346,7 @@ module Invoicing
|
|
343
346
|
""
|
344
347
|
end
|
345
348
|
end
|
346
|
-
|
349
|
+
|
347
350
|
def default_period_end(params)
|
348
351
|
if period_end = get(:period_end)
|
349
352
|
invoke_metadata_item(params, :period_end, period_end.strftime(params[:date_format]))
|
@@ -351,7 +354,7 @@ module Invoicing
|
|
351
354
|
""
|
352
355
|
end
|
353
356
|
end
|
354
|
-
|
357
|
+
|
355
358
|
def default_due_date(params)
|
356
359
|
if due_date = get(:due_date)
|
357
360
|
invoke_metadata_item(params, :due_date, due_date.strftime(params[:date_format]))
|
@@ -364,15 +367,15 @@ module Invoicing
|
|
364
367
|
"<table class=\"invoice metadata\">\n" + params[:identifier] + params[:issue_date] +
|
365
368
|
params[:period_start] + params[:period_end] + params[:due_date] + "#{indent*0}</table>\n"
|
366
369
|
end
|
367
|
-
|
370
|
+
|
368
371
|
def default_description
|
369
372
|
h(get(:description))
|
370
373
|
end
|
371
|
-
|
374
|
+
|
372
375
|
def default_description_tag(params)
|
373
376
|
"<p class=\"invoice description\">#{params[:description]}</p>\n"
|
374
377
|
end
|
375
|
-
|
378
|
+
|
376
379
|
def default_line_items_header(params)
|
377
380
|
html = "#{indent*1}<tr>\n"
|
378
381
|
html << "#{indent*2}<th class=\"tax-point\">#{ params[:line_tax_point_label] }</th>\n" if options[:tax_point_column]
|
@@ -383,7 +386,7 @@ module Invoicing
|
|
383
386
|
html << "#{indent*2}<th class=\"gross-amount\">#{params[:line_gross_amount_label]}</th>\n" if options[:gross_amount_column]
|
384
387
|
html << "#{indent*1}</tr>\n"
|
385
388
|
end
|
386
|
-
|
389
|
+
|
387
390
|
def default_line_tax_point(params)
|
388
391
|
if tax_point = line_get(:tax_point)
|
389
392
|
h(tax_point.strftime(params[:date_format]))
|
@@ -391,15 +394,15 @@ module Invoicing
|
|
391
394
|
""
|
392
395
|
end
|
393
396
|
end
|
394
|
-
|
397
|
+
|
395
398
|
def default_line_quantity(params)
|
396
399
|
h(line_get(:quantity).to_s)
|
397
400
|
end
|
398
|
-
|
401
|
+
|
399
402
|
def default_line_description(params)
|
400
403
|
h(line_get(:description))
|
401
404
|
end
|
402
|
-
|
405
|
+
|
403
406
|
def default_line_net_amount(params)
|
404
407
|
if net_amount = line_get(:net_amount)
|
405
408
|
h(current_line_item.format_currency_value(net_amount*factor))
|
@@ -407,7 +410,7 @@ module Invoicing
|
|
407
410
|
"—"
|
408
411
|
end
|
409
412
|
end
|
410
|
-
|
413
|
+
|
411
414
|
def default_line_tax_amount(params)
|
412
415
|
if tax_amount = line_get(:tax_amount)
|
413
416
|
h(current_line_item.format_currency_value(tax_amount*factor))
|
@@ -415,7 +418,7 @@ module Invoicing
|
|
415
418
|
"—"
|
416
419
|
end
|
417
420
|
end
|
418
|
-
|
421
|
+
|
419
422
|
def default_line_gross_amount(params)
|
420
423
|
if gross_amount = line_get(:gross_amount)
|
421
424
|
h(current_line_item.format_currency_value(gross_amount*factor))
|
@@ -423,7 +426,7 @@ module Invoicing
|
|
423
426
|
"—"
|
424
427
|
end
|
425
428
|
end
|
426
|
-
|
429
|
+
|
427
430
|
def default_net_amount(params)
|
428
431
|
if net_amount = get(:net_amount)
|
429
432
|
h(ledger_item.format_currency_value(net_amount*factor))
|
@@ -431,7 +434,7 @@ module Invoicing
|
|
431
434
|
"—"
|
432
435
|
end
|
433
436
|
end
|
434
|
-
|
437
|
+
|
435
438
|
def default_tax_amount(params)
|
436
439
|
if tax_amount = get(:tax_amount)
|
437
440
|
h(ledger_item.format_currency_value(tax_amount*factor))
|
@@ -439,7 +442,7 @@ module Invoicing
|
|
439
442
|
"—"
|
440
443
|
end
|
441
444
|
end
|
442
|
-
|
445
|
+
|
443
446
|
def default_total_amount(params)
|
444
447
|
if total_amount = get(:total_amount)
|
445
448
|
h(ledger_item.format_currency_value(total_amount*factor))
|
@@ -447,7 +450,7 @@ module Invoicing
|
|
447
450
|
"—"
|
448
451
|
end
|
449
452
|
end
|
450
|
-
|
453
|
+
|
451
454
|
def default_line_item(params)
|
452
455
|
html = "#{indent*1}<tr>\n"
|
453
456
|
html << "#{indent*2}<td class=\"tax-point\">#{ params[:line_tax_point] }</td>\n" if options[:tax_point_column]
|
@@ -472,7 +475,7 @@ module Invoicing
|
|
472
475
|
))
|
473
476
|
end.join
|
474
477
|
end
|
475
|
-
|
478
|
+
|
476
479
|
def default_line_items_subtotal(params)
|
477
480
|
colspan = 0
|
478
481
|
colspan += 1 if options[:tax_point_column]
|
@@ -485,7 +488,7 @@ module Invoicing
|
|
485
488
|
html << "#{indent*2}<td class=\"gross-amount\"></td>\n" if options[:gross_amount_column]
|
486
489
|
html << "#{indent*1}</tr>\n"
|
487
490
|
end
|
488
|
-
|
491
|
+
|
489
492
|
def default_line_items_total(params)
|
490
493
|
colspan = -1
|
491
494
|
colspan += 1 if options[:tax_point_column]
|
@@ -506,7 +509,7 @@ module Invoicing
|
|
506
509
|
html << params[:line_items_subtotal] if options[:subtotal]
|
507
510
|
html << params[:line_items_total] + "</table>\n"
|
508
511
|
end
|
509
|
-
|
512
|
+
|
510
513
|
def default_page_layout(params)
|
511
514
|
params[:title_tag] + params[:addresses_table] + params[:metadata_table] +
|
512
515
|
params[:description_tag] + params[:line_items_table]
|