dorsale 2.1.8 → 2.1.9

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
  SHA1:
3
- metadata.gz: 7b068a002a89a6afe5adcca02b598e4191a55464
4
- data.tar.gz: a21da8e2e1ab0c5d1a4f56f871522637a2844849
3
+ metadata.gz: 1b1eb9a7c3d0da487e4546910b1452204f526021
4
+ data.tar.gz: a8263c606b005255055ca262bc895ec7e100ada4
5
5
  SHA512:
6
- metadata.gz: 4b2a577e6abea4a8ef1b6108dcf15eb26cab912d30f714e8421e744381ac7c4765bfdb17eb05f854cb2abf6c16cf654ebd469fda41735aa19277c8e26ba8868e
7
- data.tar.gz: 1fc8e1b92a9a548fb41f000c463c9fba1dc8727ab066bee6c725cb34f5603068801e765a5b9133d557498bf701dcaa327b619097de29a9b0dd90b635f8c56d38
6
+ metadata.gz: d9498941e121e321906a6c549097bca1a29952e6996ac49be08b2b39d7a8bc737472ab65d75e0dabfb9ccac9ad94be4f909d9bb3214fb3db14cc5badd64759a7
7
+ data.tar.gz: 04a3c52416fee25df4f53bb828838d10d5133b032be62558639ad4bf9bc37dd9e7a1cb6704106520bb24c94182ae730e4919eb91a6a287cbce840f9d86ecd353
Binary file
Binary file
@@ -1,212 +1,422 @@
1
+ require "prawn/measurement_extensions"
2
+
1
3
  module Dorsale
2
4
  module BillingMachine
3
5
  class InvoicePdf < Prawn::Document
4
6
  include Dorsale::Alexandrie::Prawn
7
+ include Dorsale::AllHelpers
5
8
  include ActionView::Helpers::NumberHelper
6
- attr_reader :main_document
9
+ DEBUG = false
7
10
 
8
11
  GREY = "808080"
9
12
  LIGHT_GREY = "C0C0C0"
10
13
  WHITE = "FFFFFF"
11
- DEBUG = false
12
- FRENCH_MONTH_NAMES = [nil, 'janvier', 'février', 'mars', 'avril', 'mai',
13
- 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
14
+ BLACK = "000000"
15
+ BLUE = "005F9E"
14
16
 
15
- def main_document_type
16
- "Facture"
17
+ def has_advance
18
+ @main_document.try(:advance) && @main_document.advance != 0.0
19
+ end
20
+
21
+ def has_discount
22
+ @main_document.try(:commercial_discount) && @main_document.commercial_discount != 0.0
23
+ end
24
+
25
+ def first_column_width
26
+ 7.6.cm
27
+ end
28
+
29
+ def second_column_width
30
+ 2.4.cm
31
+ end
32
+
33
+ def third_column_width
34
+ second_column_width
35
+ end
36
+
37
+ def fourth_column_width
38
+ 2.9.cm
39
+ end
40
+
41
+ def last_column_width
42
+ bounds.width - first_column_width - second_column_width - third_column_width - fourth_column_width
17
43
  end
18
44
 
45
+ attr_reader :main_document
46
+
19
47
  def initialize(main_document)
20
- super(:page_size => 'A4')
48
+ super(page_size: 'A4', margin: 1.cm)
49
+ setup
21
50
  @main_document = main_document
22
- @id_card = @main_document.id_card
51
+ @id_card = main_document.id_card
23
52
  end
24
53
 
25
- def build
54
+ def header_height
55
+ 9.cm
56
+ end
26
57
 
27
- build_logo
28
- build_legal_infos
29
- build_header
30
- build_contact_infos
31
- build_customer_infos
32
- build_label
33
- build_table
34
- build_comments
35
- build_footer
58
+ def middle_height
59
+ 15.cm
36
60
  end
37
61
 
38
- def build_logo
39
- image @main_document.id_card.logo.path , at: [45, 765], :width => 150 if @main_document.id_card.logo.present?
62
+ def footer_height
63
+ 4.cm
40
64
  end
41
65
 
42
- def build_legal_infos
43
- bounding_box [235, 735], :width => 235, :height => 110 do
44
- draw_bounds_debug
45
- font_size 8
46
- text @id_card.entity_name, align: :right, style: :bold
47
- write_legal_line 'SIRET ' + @id_card.siret.to_s + ' APE ' + @id_card.ape_naf.to_s
48
- write_legal_line @id_card.legal_form.to_s + ' au capital de ' + number_with_delimiter(@id_card.capital, :delimiter => '.').to_s + ' euros'
49
- write_legal_line @id_card.registration_city.to_s + ' ' + @id_card.registration_number.to_s
50
- move_down 5
51
- write_legal_line 'N° TVA ' + @id_card.intracommunity_vat.to_s
52
- move_down 15
53
- write_legal_line @id_card.address1.to_s
54
- write_legal_line @id_card.zip.to_s + " " + @id_card.city.to_s
66
+ def logo_height
67
+ 3.2.cm
68
+ end
69
+
70
+ def build
71
+ repeat :all do
72
+ build_header
73
+ build_footer
55
74
  end
75
+ build_middle
76
+ build_page_numbers
77
+ end
78
+
79
+ def setup
80
+ font_root = ::Dorsale::Engine.root.join("app/assets/fonts")
81
+ font_families.update(
82
+ "BryantPro" => {
83
+ normal: "#{font_root}/BryantPro-Regular.ttf",
84
+ bold: "#{font_root}/BryantPro-Bold.ttf",
85
+ }
86
+ )
87
+
88
+ font("BryantPro")
89
+ font_size 10
56
90
  end
57
91
 
58
92
  def build_header
59
- bounding_box [300, 585], :width => 170, :height => 50 do
93
+ bounding_box [0, bounds.top], width: bounds.width, height: header_height do
60
94
  draw_bounds_debug
61
- font_size 10
62
- document_type = main_document_type
63
- text "<font size='16'><b>#{document_type}</b></font> N°" + @main_document.tracking_id,
64
- :inline_format => true,
65
- :align => :right
66
- font_size 11.5
67
- text @id_card.city.to_s + ' le ' + french_date(@main_document.date), :align => :right
95
+ build_title
96
+ build_logo
97
+ build_contact
98
+ build_subject
99
+ build_customer
68
100
  end
69
101
  end
70
102
 
71
- def build_contact_infos
72
- bounding_box [50, 585], :width => 235, :height => 50 do
103
+ def build_title
104
+ top = bounds.top - 1.5.cm
105
+ left = bounds.left
106
+ width = bounds.width
107
+ height = 1.cm
108
+ bounding_box [left, top], width: width, height: height do
73
109
  draw_bounds_debug
74
- font_size 10
75
- text '<b>Contact :</b> ' + @id_card.contact_full_name.to_s, :inline_format => true
76
- text '<b>Tél :</b> ' + @id_card.contact_phone.to_s, :inline_format => true
77
- text '<b>Fax:</b> ' + @id_card.contact_fax.to_s, :inline_format => true
78
- text '<b>Email:</b> ' + @id_card.contact_email.to_s, :inline_format => true
110
+ text "<b>#{main_document_type}", inline_format: true, size: 20, align: :center
79
111
  end
80
112
  end
81
113
 
82
- def build_customer_infos
83
- unless @main_document.customer.nil?
84
- bounding_box [50, 530], :width => 420, :height => 105 do
85
- draw_bounds_debug
86
- font_size 11.5
87
- text 'A l’attention de :', :style => :bold
88
- text @main_document.customer.name
89
- text @main_document.customer.address.street
90
- text @main_document.customer.address.street_bis
91
- text @main_document.customer.address.zip.to_s + ' ' + @main_document.customer.address.city.to_s
92
- text @main_document.customer.address.country
114
+ def build_logo
115
+ width = 3.2.cm
116
+ height = logo_height
117
+ bounding_box [bounds.left, bounds.top], width: width, height: height do
118
+ draw_bounds_debug
119
+ if @main_document.id_card.logo.present?
120
+ image @main_document.id_card.logo.path, width: (bounds.width - 1.cm)
93
121
  end
94
122
  end
95
123
  end
96
124
 
97
- def build_label
98
- bounding_box [50, 425], :width => 350, :height => 30 do
99
- draw_bounds_debug
100
- font_size 11
101
- text '<b>Objet :</b> ' + @main_document.label, :inline_format => true
102
- end
125
+ def address_line
126
+ [@id_card.address1,@id_card.address2, @id_card.zip, @id_card.city].select(&:present?).join(", ")
103
127
  end
104
128
 
105
- def build_table
106
- bounding_box [50, 400], :width => 450 do
107
- @table_matrix = [['Prestation', 'Prix unitaire', 'Quantité', 'Total HT']]
108
- build_lines
109
- build_synthesis
110
- build_expiry
111
- build_payment_terms
112
- build_bank_infos
129
+ def build_contact
130
+ top = bounds.top - 4.cm
131
+ left = bounds.left
132
+ width = bounds.width / 2 - 1.1.cm
133
+ height = 2.5.cm
134
+
135
+ bounding_box [left, top], width: width, height: height do
136
+ draw_bounds_debug
137
+ font_size 8 do
138
+ text "<b>#{@id_card.entity_name}</b>", inline_format: true if @id_card.entity_name.present?
139
+ text "<b>#{address_line} </b>", inline_format: true
140
+ text " "
141
+ text "<b>#{I18n.t("pdfs.your_contact")} : #{@id_card.contact_full_name}</b>", inline_format: true if @id_card.contact_full_name.present?
142
+ text "<b>#{I18n.t("pdfs.contact_phone")}</b> #{@id_card.contact_phone}", inline_format: true if @id_card.contact_phone.present?
143
+ text "<b>#{I18n.t("pdfs.contact_fax")}</b> #{@id_card.contact_fax}", inline_format: true if @id_card.contact_fax.present?
144
+ text "<b>#{I18n.t("pdfs.contact_email")}</b> #{@id_card.contact_email}", inline_format: true if @id_card.contact_email.present?
145
+ end
113
146
  end
114
147
  end
115
148
 
116
- def build_lines
117
- @main_document.lines.each do |line|
118
- @table_matrix.push [line.label, french_number(euros(line.unit_price), 2),
119
- french_number(line.quantity),
120
- french_number(euros(line.total), 2)]
149
+ def build_subject
150
+ top = bounds.top - 7.5.cm
151
+ left = bounds.left
152
+ width = bounds.width / 2 - 1.1.cm
153
+ height = 1.cm
154
+
155
+ bounding_box [left, top], width: width, height: height do
156
+ draw_bounds_debug
157
+ text "<b>#{I18n.t("pdfs.subject")}</b> #{@main_document.label}", inline_format: true if @main_document.label.present?
121
158
  end
122
159
  end
123
160
 
124
- def build_synthesis
125
- font_size 10
126
- if (@main_document.commercial_discount && @main_document.commercial_discount != 0.0)
127
- @table_matrix.push ['Remise commerciale', '', '', euros(@main_document.commercial_discount)]
161
+ def build_customer
162
+ top = bounds.top - 4.cm
163
+ left = bounds.width / 2 + 1.1.cm
164
+ width = bounds.width / 2 - 1.1.cm
165
+ height = 4.5.cm
166
+
167
+ bounding_box [left, top], width: width, height: height do
168
+ draw_bounds_debug
169
+ stroke do
170
+ fill_color LIGHT_GREY
171
+ fill_rounded_rectangle [cursor-bounds.height,cursor], bounds.width, bounds.height, 0
172
+ fill_color BLACK
128
173
  end
129
- @table_matrix.push ['Net HT', '', '', euros(@main_document.total_duty)]
130
- vat_rate = french_number(@main_document.vat_rate)
131
- @table_matrix.push ["TVA #{vat_rate} %", '', '', euros(@main_document.vat_amount)]
132
- @table_matrix.push ['Total TTC', '', '', euros(@main_document.total_all_taxes)]
133
- if (@main_document.advance && @main_document.advance != 0.0)
134
- @table_matrix.push ['Acompte reçu sur commande', '', '', euros(@main_document.advance)]
135
- @table_matrix.push ['Solde à payer', '', '', euros(@main_document.balance)]
174
+
175
+ table_customer = []
176
+
177
+ if @main_document.tracking_id.present?
178
+ table_customer << [I18n.t("pdfs.tracking_number") , @main_document.tracking_id.to_s]
179
+ end
180
+ if @main_document.date.present?
181
+ table_customer << [I18n.t("pdfs.date") , date(@main_document.date)]
182
+ end
183
+ if @main_document.customer.present?
184
+ name = "#{@main_document.customer.name}\n" if @main_document.customer.name.present?
185
+ street = "#{@main_document.customer.address.street}\n" if @main_document.customer.address.street?
186
+ street_bis = "#{@main_document.customer.address.street_bis}\n" if @main_document.customer.address.street_bis.present?
187
+ zip_country = "#{@main_document.customer.address.zip} #{@main_document.customer.address.city}" if @main_document.customer.address.city.present?
188
+ table_customer << [I18n.t("pdfs.customer") , "#{name} #{street} #{street_bis} #{zip_country}" ] if @main_document.customer.name.present?
189
+ end
190
+
191
+ table table_customer,
192
+ :column_widths => [ width / 3 , width - (width / 3)],
193
+ :cell_style => {border_width: [0, 0, 0.5, 0], padding: [2.mm, 2.mm]} do
194
+ row(2).border_width = 0
195
+ column(0).font_style = :bold
196
+ column(1).row(2).valign = :center
136
197
  end
137
- write_table_from_matrix(@table_matrix)
138
198
  end
199
+ end
139
200
 
140
- def build_payment_terms
141
- move_down 15
142
- text 'Conditions de paiement :'
143
- text @main_document.payment_term.try(:label)
201
+ def build_middle
202
+ left = bounds.left
203
+ top = bounds.top - header_height
204
+ width = bounds.width - left
205
+ bounding_box [left, top], width: width, height: middle_height do
206
+ build_table
207
+ build_total
208
+ build_payment_conditions
209
+ build_bank_informations
210
+ build_expiry
211
+ build_comments
212
+ end
144
213
  end
145
214
 
146
- def build_bank_infos
147
- move_down 10
148
- text 'Coordonnées bancaires :'
149
- text 'IBAN : ' + @id_card.iban.to_s
150
- text 'BIC / SWIFT : ' + @id_card.bic_swift.to_s
215
+ def main_document_type
216
+ Dorsale::BillingMachine::Invoice.model_name.human.humanize
151
217
  end
152
218
 
153
- def build_expiry
219
+ def build_table
220
+ left = bounds.left
221
+ top = bounds.top
222
+ width = bounds.width - left
223
+
224
+ bounding_box [left, top], width: width, height: 9.5.cm do
225
+ repeat :all do
226
+ float do
227
+ table [["","","","",""]],
228
+ :column_widths => [first_column_width, second_column_width, third_column_width, fourth_column_width, last_column_width],
229
+ :cell_style => {:height => 9.5.cm} do
230
+ row(0).style :text_color => BLACK
231
+ row(0).style :font_style => :bold
232
+ column(0).style :align => :left
233
+ column(1..4).style :align => :right
234
+ end
235
+ end
236
+ end
237
+ end
238
+
239
+ bounding_box [left, top], width: width, height: 8.8.cm do
240
+ draw_bounds_debug
241
+ repeat :all do
242
+ build_line
243
+ end
244
+ table_products = [[I18n.t("pdfs.designation"),
245
+ I18n.t("pdfs.quantity"),
246
+ I18n.t("pdfs.unity"),
247
+ I18n.t("pdfs.unit_price"),
248
+ I18n.t("pdfs.line_total")]]
249
+
250
+
251
+ @main_document.lines.each do |line|
252
+ table_products.push [line.label,
253
+ number(line.quantity).gsub(",00","").gsub(".00",""),
254
+ line.unit,
255
+ euros(line.unit_price),
256
+ euros(line.total),]
257
+ end
258
+
259
+ table table_products,
260
+ :column_widths => [first_column_width, second_column_width, third_column_width, fourth_column_width, last_column_width],
261
+ :header => true,
262
+ :cell_style => {border_width: 0} do
263
+ row(0).font_style = :bold
264
+ row(0).border_width = 1,
265
+ cells.style do |c|
266
+ c.align = c.column == 0 ? :left : :right
267
+ end
268
+ end
269
+ end
270
+ end
271
+
272
+ def build_total
273
+
274
+ left = bounds.left
275
+ top = bounds.top - 10.3.cm
276
+ width = bounds.width - left
277
+
278
+ bounding_box [left, top], width: width, height: middle_height - 9.5.cm do
279
+ draw_bounds_debug
280
+
281
+ table_totals = [[]]
282
+
283
+ if has_discount
284
+ table_totals.push ["#{I18n.t("pdfs.commercial_discount")}", "\- #{euros(@main_document.commercial_discount)}"]
285
+ end
286
+
287
+ table_totals.push ["#{I18n.t("pdfs.total_duty")}", euros(@main_document.total_duty)]
288
+
289
+ vat_rate = number(@main_document.vat_rate)
290
+ table_totals.push ["#{I18n.t("pdfs.vat")}#{vat_rate} %", euros(@main_document.vat_amount)]
291
+
292
+ if has_advance
293
+ table_totals.push ["#{I18n.t("pdfs.advance")}", euros(@main_document.advance)]
294
+ table_totals.push ["#{I18n.t("pdfs.total_all_taxes")}", euros(@main_document.balance)]
295
+ else
296
+ table_totals.push ["#{I18n.t("pdfs.total_all_taxes")}", euros(@main_document.total_all_taxes)]
297
+ end
298
+
299
+ table table_totals,
300
+ :column_widths => [fourth_column_width, last_column_width],
301
+ :cell_style => {border_width: [0, 1, 0 ,0]},
302
+ :position => :right do
303
+ row(-1).style :font_style => :bold
304
+ column(0).padding_right = 0.2.cm
305
+ row(-1).borders = [:top, :right]
306
+ row(-1).border_width = 1
307
+ cells.style do |c|
308
+ c.align = :right
309
+ end
310
+ end
311
+ stroke do
312
+ rectangle [(bounds.right - fourth_column_width - last_column_width), bounds.top], (fourth_column_width + last_column_width), (bounds.top-cursor)
313
+ end
314
+ end
154
315
  end
155
316
 
156
317
  def build_comments
157
318
  end
158
319
 
159
- def build_footer
160
- bounding_box [50, 37], :width => 425 do
161
- font "Times-Roman"
162
- font_size 8.5
163
- text @id_card.custom_info_1, :color => GREY
320
+
321
+
322
+ def build_payment_conditions
323
+ top = bounds.top - 10.3.cm
324
+ height = 1.cm
325
+ width = 7.5.cm
326
+
327
+ bounding_box [bounds.left, top], height: height, width: width do
328
+ draw_bounds_debug
329
+ font_size 9 do
330
+ text I18n.t("pdfs.payment_terms"), style: :bold if @main_document.payment_term.present?
331
+ text @main_document.payment_term.try(:label)
332
+ end
164
333
  end
165
334
  end
166
335
 
336
+ def build_expiry
337
+ end
338
+
339
+ def build_bank_informations
340
+ top = bounds.top - 11.5.cm
341
+ height = 1.cm
342
+ width = 7.5.cm
167
343
 
168
- def write_table_from_matrix matrix
169
- table matrix,
170
- :column_widths => [215, 65, 60, 80],
171
- :cell_style => {:align => :right, :border_width => 0.5} do
172
- row(0).style :background_color => LIGHT_GREY # make first row grey
173
- row(0).style :size => 11
174
- # reduce font size of invoice lines
175
- invoice_lines_range = Range.new(1,(matrix.length - 6))
176
- row(invoice_lines_range).style :size => 9
344
+ bounding_box [bounds.left, top], height: height, width: width do
345
+ draw_bounds_debug
346
+ font_size 9 do
347
+ text "#{I18n.t("pdfs.iban")} #{@id_card.iban}" if @id_card.iban.present?
348
+ text "#{I18n.t("pdfs.bic_swift")} #{@id_card.bic_swift}" if @id_card.bic_swift.present?
349
+ end
177
350
  end
178
351
  end
179
352
 
180
- def draw_bounds_debug
181
- transparent(0.5) { stroke_bounds } if DEBUG
182
- end
353
+ def build_footer
354
+ top = bounds.bottom + footer_height
355
+ bounding_box [0, top], width: bounds.width, height: footer_height do
356
+
357
+ builds_legals
358
+ build_line
359
+ builds_id_card_informations
183
360
 
184
- def write_legal_line text
185
- text text, :align => :right, :color => GREY
361
+ end
186
362
  end
187
363
 
188
- def french_date date
189
- french_month = FRENCH_MONTH_NAMES[date.month]
190
- return date.day.to_s + ' ' + french_month + ' ' + date.year.to_s
364
+ def builds_legals
365
+ top = bounds.top
366
+ height = 1.5.cm
367
+ width = bounds.width
368
+ bounding_box [bounds.left, top], height: height, width: width do
369
+ font_size 9 do
370
+ text @id_card.custom_info_1, inline_format: true
371
+ end
372
+ end
191
373
  end
192
374
 
193
- def euros amount
194
- amount ||= 0
195
- french_number(amount, 2).to_s + " €"
375
+ def build_line
376
+ stroke do
377
+ horizontal_rule
378
+ line_width 1
379
+ end
196
380
  end
197
381
 
198
- def french_number amount, precision = -1
199
- if precision >= 0
200
- number_with_precision(amount, :precision => precision, :delimiter => '.', :separator => ",")
201
- else
202
- number_with_delimiter(amount, :delimiter => '.', :separator => ",")
382
+ def builds_id_card_informations
383
+ top = bounds.top - 1.8.cm
384
+ height = 1.1.cm
385
+ width = bounds.width
386
+ tel = "#{I18n.t("pdfs.info_phone")} #{@id_card.contact_phone} - " if @id_card.contact_phone.present?
387
+ fax = "#{I18n.t("pdfs.info_fax")} #{@id_card.contact_fax} -" if @id_card.contact_fax.present?
388
+ email = "#{@id_card.contact_email}" if @id_card.contact_email.present?
389
+ capital = "#{ @id_card.legal_form.to_s} #{I18n.t("pdfs.capital")} " + number_with_delimiter(@id_card.capital, :delimiter => '.').to_s + " €" if @id_card.legal_form.present? && @id_card.capital.present?
390
+ registration = I18n.t("pdfs.registration") + @id_card.registration_city.to_s + ' ' + @id_card.registration_number.to_s if @id_card.registration_number.present?
391
+ siret = I18n.t("pdfs.siret") + @id_card.siret.to_s if @id_card.siret.present?
392
+ tva = I18n.t("pdfs.vat") + @id_card.intracommunity_vat.to_s if @id_card.intracommunity_vat.present?
393
+ font_size 9 do
394
+ text_box "#{@id_card.entity_name} #{address_line}\n#{tel} #{fax} #{email}\n#{capital} #{registration} #{siret} #{tva}",
395
+ :at => [bounds.left, top],
396
+ :height => height,
397
+ :width => width,
398
+ :overflow => :shrink_to_fit
203
399
  end
204
400
  end
205
401
 
206
- def number_without_trailling_zero number
207
- return ("%g" % number)
402
+ def build_page_numbers
403
+ top = bounds.bottom + footer_height - 1.8.cm
404
+ bounding_box [0, top], height: footer_height, width: bounds.width do
405
+ font_size 9 do
406
+ float do
407
+ options = {
408
+ :align => :right,
409
+ :start_count_at => 1
410
+ }
411
+ number_pages "page <page>/<total>", options
412
+ end
413
+ end
414
+ end
208
415
  end
209
416
 
210
- end # InvoicePdf
211
- end # BillingMachine
212
- end # Dorsale
417
+ def draw_bounds_debug
418
+ transparent(0.5) { stroke_bounds } if DEBUG
419
+ end
420
+ end
421
+ end
422
+ end
@@ -20,35 +20,38 @@ module Dorsale
20
20
  end
21
21
 
22
22
  def main_document_type
23
- "Devis"
23
+ Dorsale::BillingMachine::Quotation.model_name.human.humanize
24
24
  end
25
25
 
26
- def build_bank_infos
27
- end
28
-
29
- def build_synthesis
30
- font_size 10
31
- if (@main_document.commercial_discount && @main_document.commercial_discount != 0.0)
32
- @table_matrix.push ['Remise commerciale', '', '', euros(@main_document.commercial_discount)]
33
- end
34
- @table_matrix.push ['Net HT', '', '', euros(@main_document.total_duty)]
35
- vat_rate = french_number(@main_document.vat_rate)
36
- @table_matrix.push ["TVA #{vat_rate} %", '', '', euros(@main_document.vat_amount)]
37
- @table_matrix.push ['Total TTC', '', '', euros(@main_document.total_all_taxes)]
38
- write_table_from_matrix(@table_matrix)
26
+ def build_bank_informations
39
27
  end
40
28
 
41
29
  def build_expiry
42
30
  return if @main_document.expires_at.nil?
43
- move_down 15
44
- text "Date d'expiration : " + I18n.l(@main_document.expires_at)
31
+ top = bounds.top - 11.5.cm
32
+ height = 0.5.cm
33
+ width = 7.5.cm
34
+
35
+ bounding_box [bounds.left, top], height: height, width: width do
36
+ draw_bounds_debug
37
+ font_size 9 do
38
+ text "<b>#{I18n.t("pdfs.expires_at")}</b> #{I18n.l(@main_document.expires_at)}", inline_format: true
39
+ end
40
+ end
45
41
  end
46
42
 
47
43
  def build_comments
48
- bounding_box [50, 140], :width => 445, :height => 50 do
49
- draw_bounds_debug
50
- font_size 9
51
- text @main_document.comments
44
+ return if @main_document.comments.blank?
45
+ top = bounds.top - 12.cm
46
+ height = 1.5.cm
47
+ width = 10.cm
48
+
49
+ font_size 9 do
50
+ text_box @main_document.comments,
51
+ :at => [bounds.left, top],
52
+ :height => height,
53
+ :width => width,
54
+ :overflow => :shrink_to_fit
52
55
  end
53
56
  end
54
57
  end