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 +4 -4
- data/app/assets/fonts/BryantPro-Bold.otf +0 -0
- data/app/assets/fonts/BryantPro-Bold.ttf +0 -0
- data/app/assets/fonts/BryantPro-Regular.otf +0 -0
- data/app/assets/fonts/BryantPro-Regular.ttf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Bold.otf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Bold.ttf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Regular.otf +0 -0
- data/app/assets/fonts/fonts/BryantPro-Regular.ttf +0 -0
- data/app/pdfs/dorsale/billing_machine/invoice_pdf.rb +345 -135
- data/app/pdfs/dorsale/billing_machine/quotation_pdf.rb +23 -20
- data/config/locales/billing_machine.en.yml +30 -0
- data/config/locales/billing_machine.fr.yml +33 -0
- data/lib/dorsale/engine.rb +1 -0
- data/lib/dorsale/version.rb +1 -1
- data/spec/pdfs/dorsale/billing_machine/invoice_pdf_spec.rb +151 -171
- data/spec/pdfs/dorsale/billing_machine/quotation_pdf_spec.rb +166 -168
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b1eb9a7c3d0da487e4546910b1452204f526021
|
4
|
+
data.tar.gz: a8263c606b005255055ca262bc895ec7e100ada4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9498941e121e321906a6c549097bca1a29952e6996ac49be08b2b39d7a8bc737472ab65d75e0dabfb9ccac9ad94be4f909d9bb3214fb3db14cc5badd64759a7
|
7
|
+
data.tar.gz: 04a3c52416fee25df4f53bb828838d10d5133b032be62558639ad4bf9bc37dd9e7a1cb6704106520bb24c94182ae730e4919eb91a6a287cbce840f9d86ecd353
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
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
|
-
|
9
|
+
DEBUG = false
|
7
10
|
|
8
11
|
GREY = "808080"
|
9
12
|
LIGHT_GREY = "C0C0C0"
|
10
13
|
WHITE = "FFFFFF"
|
11
|
-
|
12
|
-
|
13
|
-
'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
|
14
|
+
BLACK = "000000"
|
15
|
+
BLUE = "005F9E"
|
14
16
|
|
15
|
-
def
|
16
|
-
|
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(:
|
48
|
+
super(page_size: 'A4', margin: 1.cm)
|
49
|
+
setup
|
21
50
|
@main_document = main_document
|
22
|
-
@id_card
|
51
|
+
@id_card = main_document.id_card
|
23
52
|
end
|
24
53
|
|
25
|
-
def
|
54
|
+
def header_height
|
55
|
+
9.cm
|
56
|
+
end
|
26
57
|
|
27
|
-
|
28
|
-
|
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
|
39
|
-
|
62
|
+
def footer_height
|
63
|
+
4.cm
|
40
64
|
end
|
41
65
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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 [
|
93
|
+
bounding_box [0, bounds.top], width: bounds.width, height: header_height do
|
60
94
|
draw_bounds_debug
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
72
|
-
|
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
|
-
|
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
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
98
|
-
|
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
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
125
|
-
|
126
|
-
|
127
|
-
|
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
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
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
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
147
|
-
|
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
|
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
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
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
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
181
|
-
|
182
|
-
|
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
|
-
|
185
|
-
text text, :align => :right, :color => GREY
|
361
|
+
end
|
186
362
|
end
|
187
363
|
|
188
|
-
def
|
189
|
-
|
190
|
-
|
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
|
194
|
-
|
195
|
-
|
375
|
+
def build_line
|
376
|
+
stroke do
|
377
|
+
horizontal_rule
|
378
|
+
line_width 1
|
379
|
+
end
|
196
380
|
end
|
197
381
|
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
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
|
207
|
-
|
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
|
-
|
211
|
-
|
212
|
-
end
|
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
|
-
|
23
|
+
Dorsale::BillingMachine::Quotation.model_name.human.humanize
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
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
|
-
|
44
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|