dorsale 2.4.3 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/dorsale/billing_machine/invoice.rb +1 -1
- data/app/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf.rb +46 -42
- data/app/pdfs/dorsale/billing_machine/invoice_single_vat_pdf.rb +216 -158
- data/app/pdfs/dorsale/billing_machine/quotation_pdf_common_methods.rb +4 -3
- data/config/locales/billing_machine.en.yml +57 -62
- data/config/locales/billing_machine.fr.yml +57 -62
- data/config/locales/common.en.yml +0 -14
- data/config/locales/common.fr.yml +0 -15
- data/config/locales/{en.yml → dorsale.en.yml} +0 -0
- data/config/locales/{fr.yml → dorsale.fr.yml} +0 -0
- data/lib/dorsale/version.rb +1 -1
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +215 -0
- data/spec/dummy/log/test.log +5626 -0
- data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +10 -1
- data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +16 -215
- data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +10 -1
- data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +17 -212
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 440a037661b26b077f25466d7893487c797e4276
|
4
|
+
data.tar.gz: b29007bd7a54add8d064bbc4af228277f8511af2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c94f5122db07d75c03853d8163e90f6627aabd2461652d61aeaa69dc87ee2af3a87788e489c5d965a9e0a6b65f52fb350269476783477a19890e721bfab690db
|
7
|
+
data.tar.gz: 3d9d15f4b6ace4de92364f07449cce09acecc3f688765dd0d4a6aca12693cae464ee7299dc142e2c70b0976a70fdf13f54ec08eabce2939f8bc02cd40ce9a706
|
@@ -2,26 +2,11 @@ module Dorsale
|
|
2
2
|
module BillingMachine
|
3
3
|
class InvoiceMultipleVatPdf < ::Dorsale::BillingMachine::InvoiceSingleVatPdf
|
4
4
|
|
5
|
-
def first_column_width
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
def
|
10
|
-
2.cm
|
11
|
-
end
|
12
|
-
|
13
|
-
def third_column_width
|
14
|
-
second_column_width
|
15
|
-
end
|
16
|
-
|
17
|
-
def fourth_column_width
|
18
|
-
second_column_width
|
19
|
-
end
|
20
|
-
|
21
|
-
def fifth_column_width
|
22
|
-
2.9.cm
|
23
|
-
end
|
24
|
-
|
5
|
+
def first_column_width; 64.mm; end
|
6
|
+
def second_column_width; 22.mm; end
|
7
|
+
def third_column_width; 20.mm; end
|
8
|
+
def fourth_column_width; 20.mm; end
|
9
|
+
def fifth_column_width; 29.mm; end
|
25
10
|
def last_column_width
|
26
11
|
bounds.width - first_column_width - second_column_width - third_column_width - fourth_column_width - fifth_column_width
|
27
12
|
end
|
@@ -31,12 +16,12 @@ module Dorsale
|
|
31
16
|
top = bounds.top
|
32
17
|
width = bounds.width - left
|
33
18
|
|
34
|
-
bounding_box [left, top], width: width, height:
|
19
|
+
bounding_box [left, top], width: width, height: products_table_height do
|
35
20
|
repeat :all do
|
36
21
|
float do
|
37
22
|
table [["","","","","",""]],
|
38
23
|
:column_widths => [first_column_width, second_column_width, third_column_width, fourth_column_width, fifth_column_width, last_column_width],
|
39
|
-
:cell_style => {:
|
24
|
+
:cell_style => {height: products_table_height} do
|
40
25
|
row(0).style :text_color => BLACK
|
41
26
|
row(0).style :font_style => :bold
|
42
27
|
column(0).style :align => :left
|
@@ -46,20 +31,20 @@ module Dorsale
|
|
46
31
|
end
|
47
32
|
end
|
48
33
|
|
49
|
-
bounding_box [left, top], width: width, height:
|
34
|
+
bounding_box [left, top], width: width, height: products_table_height do
|
50
35
|
draw_bounds_debug
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
36
|
+
|
37
|
+
table_products = [[
|
38
|
+
main_document.t(:designation).mb_chars.upcase.to_s,
|
39
|
+
main_document.t(:quantity).mb_chars.upcase.to_s,
|
40
|
+
main_document.t(:unit).mb_chars.upcase.to_s,
|
41
|
+
main_document.t(:tax).mb_chars.upcase.to_s,
|
42
|
+
main_document.t(:unit_price).mb_chars.upcase.to_s,
|
43
|
+
main_document.t(:line_total).mb_chars.upcase.to_s,
|
44
|
+
]]
|
60
45
|
|
61
46
|
|
62
|
-
|
47
|
+
main_document.lines.each do |line|
|
63
48
|
table_products.push [line.label,
|
64
49
|
number(line.quantity).gsub(",00","").gsub(".00",""),
|
65
50
|
line.unit,
|
@@ -82,29 +67,48 @@ module Dorsale
|
|
82
67
|
end
|
83
68
|
|
84
69
|
def build_total
|
85
|
-
|
86
70
|
left = bounds.left
|
87
|
-
top = bounds.top -
|
71
|
+
top = bounds.top - products_table_height - 5.mm
|
88
72
|
width = bounds.width - left
|
73
|
+
height = middle_height - products_table_height
|
89
74
|
|
90
|
-
bounding_box [left, top], width: width, height:
|
75
|
+
bounding_box [left, top], width: width, height: height do
|
91
76
|
draw_bounds_debug
|
92
77
|
|
93
78
|
table_totals = [[]]
|
94
79
|
|
95
80
|
if has_discount
|
96
|
-
table_totals.push [
|
81
|
+
table_totals.push [
|
82
|
+
main_document.t(:commercial_discount).mb_chars.upcase.to_s,
|
83
|
+
euros(-main_document.commercial_discount),
|
84
|
+
]
|
97
85
|
end
|
98
86
|
|
99
|
-
table_totals.push [
|
87
|
+
table_totals.push [
|
88
|
+
main_document.t(:total_excluding_taxes).mb_chars.upcase.to_s,
|
89
|
+
euros(main_document.total_excluding_taxes),
|
90
|
+
]
|
100
91
|
|
101
|
-
table_totals.push [
|
92
|
+
table_totals.push [
|
93
|
+
main_document.t(:vat_amount).mb_chars.upcase.to_s,
|
94
|
+
euros(main_document.vat_amount),
|
95
|
+
]
|
102
96
|
|
103
97
|
if has_advance
|
104
|
-
table_totals.push [
|
105
|
-
|
98
|
+
table_totals.push [
|
99
|
+
main_document.t(:advance).mb_chars.upcase.to_s,
|
100
|
+
euros(main_document.advance),
|
101
|
+
]
|
102
|
+
|
103
|
+
table_totals.push [
|
104
|
+
main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
|
105
|
+
euros(main_document.balance),
|
106
|
+
]
|
106
107
|
else
|
107
|
-
table_totals.push [
|
108
|
+
table_totals.push [
|
109
|
+
main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
|
110
|
+
euros(main_document.total_including_taxes),
|
111
|
+
]
|
108
112
|
end
|
109
113
|
|
110
114
|
table table_totals,
|
@@ -15,31 +15,11 @@ module Dorsale
|
|
15
15
|
BLUE = "005F9E"
|
16
16
|
|
17
17
|
def has_advance
|
18
|
-
|
18
|
+
main_document.try(:advance) && main_document.advance != 0.0
|
19
19
|
end
|
20
20
|
|
21
21
|
def has_discount
|
22
|
-
|
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
|
22
|
+
main_document.try(:commercial_discount) && main_document.commercial_discount != 0.0
|
43
23
|
end
|
44
24
|
|
45
25
|
attr_reader :main_document
|
@@ -51,20 +31,22 @@ module Dorsale
|
|
51
31
|
@id_card = main_document.id_card
|
52
32
|
end
|
53
33
|
|
54
|
-
def header_height
|
55
|
-
|
56
|
-
end
|
34
|
+
def header_height; 90.mm; end
|
35
|
+
def logo_height; 32.mm; end
|
57
36
|
|
58
|
-
def
|
59
|
-
|
60
|
-
end
|
37
|
+
def footer_height; 40.mm; end
|
38
|
+
def footer_top_height; 15.mm; end
|
39
|
+
def footer_bottom_height; 15.mm; end
|
61
40
|
|
62
|
-
def
|
63
|
-
|
64
|
-
end
|
41
|
+
def middle_height; 14.cm; end
|
42
|
+
def products_table_height; 90.mm; end
|
65
43
|
|
66
|
-
def
|
67
|
-
|
44
|
+
def first_column_width; 7.6.cm; end
|
45
|
+
def second_column_width; 2.4.cm; end
|
46
|
+
def third_column_width; 2.5.cm; end
|
47
|
+
def fourth_column_width; 2.9.cm; end
|
48
|
+
def last_column_width
|
49
|
+
bounds.width - first_column_width - second_column_width - third_column_width - fourth_column_width
|
68
50
|
end
|
69
51
|
|
70
52
|
def build
|
@@ -72,6 +54,7 @@ module Dorsale
|
|
72
54
|
build_header
|
73
55
|
build_footer
|
74
56
|
end
|
57
|
+
|
75
58
|
build_middle
|
76
59
|
build_page_numbers
|
77
60
|
end
|
@@ -107,23 +90,35 @@ module Dorsale
|
|
107
90
|
height = 1.cm
|
108
91
|
bounding_box [left, top], width: width, height: height do
|
109
92
|
draw_bounds_debug
|
110
|
-
text "<b>#{main_document.t} n° #{
|
93
|
+
text "<b>#{main_document.t} n° #{main_document.tracking_id}</b>", inline_format: true, size: 20, align: :center
|
111
94
|
end
|
112
95
|
end
|
113
96
|
|
97
|
+
def logo_path
|
98
|
+
main_document.id_card.logo.path
|
99
|
+
rescue NoMethodError
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
|
114
103
|
def build_logo
|
115
|
-
|
104
|
+
return if logo_path.nil?
|
105
|
+
|
106
|
+
width = 3.2.cm
|
116
107
|
height = logo_height
|
108
|
+
|
117
109
|
bounding_box [bounds.left, bounds.top], width: width, height: height do
|
118
110
|
draw_bounds_debug
|
119
|
-
|
120
|
-
image @main_document.id_card.logo.path, width: (bounds.width - 1.cm)
|
121
|
-
end
|
111
|
+
image logo_path, width: (bounds.width - 1.cm)
|
122
112
|
end
|
123
113
|
end
|
124
114
|
|
125
|
-
def
|
126
|
-
[
|
115
|
+
def contact_address_line
|
116
|
+
[
|
117
|
+
@id_card.address1,
|
118
|
+
@id_card.address2,
|
119
|
+
@id_card.zip,
|
120
|
+
@id_card.city,
|
121
|
+
].select(&:present?).join(", ")
|
127
122
|
end
|
128
123
|
|
129
124
|
def build_contact
|
@@ -132,16 +127,20 @@ module Dorsale
|
|
132
127
|
width = bounds.width / 2 - 1.1.cm
|
133
128
|
height = 2.5.cm
|
134
129
|
|
130
|
+
contact_text = []
|
131
|
+
contact_text << "<b>#{@id_card.entity_name}</b>" if @id_card.entity_name.present?
|
132
|
+
contact_text << "<b>#{contact_address_line}</b>" if contact_address_line.present?
|
133
|
+
contact_text << " "
|
134
|
+
contact_text << "<b>#{main_document.t(:your_contact)} : #{@id_card.contact_full_name}</b>" if @id_card.contact_full_name.present?
|
135
|
+
contact_text << "<b>#{main_document.t(:contact_phone)} : </b> #{@id_card.contact_phone}" if @id_card.contact_phone.present?
|
136
|
+
contact_text << "<b>#{main_document.t(:contact_fax)} : </b> #{@id_card.contact_fax}" if @id_card.contact_fax.present?
|
137
|
+
contact_text << "<b>#{main_document.t(:contact_email)} : </b> #{@id_card.contact_email}" if @id_card.contact_email.present?
|
138
|
+
contact_text = contact_text.join("\n")
|
139
|
+
|
135
140
|
bounding_box [left, top], width: width, height: height do
|
136
141
|
draw_bounds_debug
|
137
142
|
font_size 8 do
|
138
|
-
|
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?
|
143
|
+
text contact_text, inline_format: true
|
145
144
|
end
|
146
145
|
end
|
147
146
|
end
|
@@ -155,17 +154,35 @@ module Dorsale
|
|
155
154
|
bounding_box [left, top], width: width, height: height do
|
156
155
|
draw_bounds_debug
|
157
156
|
|
158
|
-
if
|
159
|
-
text "<b>#{
|
157
|
+
if main_document.label.present?
|
158
|
+
text "<b>#{main_document.t(:label)} : </b> #{main_document.label}", inline_format: true
|
160
159
|
end
|
161
160
|
|
162
|
-
if
|
161
|
+
if main_document.date.present?
|
163
162
|
move_down 3.mm
|
164
|
-
text "<b>#{
|
163
|
+
text "<b>#{main_document.t(:date)} : </b> #{date main_document.date}", inline_format: true
|
165
164
|
end
|
166
165
|
end
|
167
166
|
end
|
168
167
|
|
168
|
+
def customer_content
|
169
|
+
return if main_document.customer.nil?
|
170
|
+
|
171
|
+
content = []
|
172
|
+
content << main_document.customer.name
|
173
|
+
content << main_document.customer.address.street
|
174
|
+
content << main_document.customer.address.street_bis
|
175
|
+
content << "#{main_document.customer.address.zip} #{main_document.customer.address.city}"
|
176
|
+
content << main_document.customer.address.country
|
177
|
+
|
178
|
+
if main_document.customer.try(:european_union_vat_number).present?
|
179
|
+
content << main_document.customer.t(:european_union_vat_number)
|
180
|
+
content << main_document.customer.european_union_vat_number
|
181
|
+
end
|
182
|
+
|
183
|
+
content.select(&:present?).join("\n")
|
184
|
+
end
|
185
|
+
|
169
186
|
def build_customer
|
170
187
|
top = bounds.top - 4.cm
|
171
188
|
left = bounds.width / 2 + 1.1.cm
|
@@ -181,22 +198,8 @@ module Dorsale
|
|
181
198
|
fill_color BLACK
|
182
199
|
end
|
183
200
|
|
184
|
-
customer_text = []
|
185
|
-
customer_text << @main_document.customer.name
|
186
|
-
customer_text << @main_document.customer.address.street
|
187
|
-
customer_text << @main_document.customer.address.street_bis
|
188
|
-
customer_text << "#{@main_document.customer.address.zip} #{@main_document.customer.address.city}"
|
189
|
-
customer_text << @main_document.customer.address.country
|
190
|
-
|
191
|
-
if @main_document.customer.try(:european_union_vat_number).present?
|
192
|
-
customer_text << @main_document.customer.t(:european_union_vat_number)
|
193
|
-
customer_text << @main_document.customer.european_union_vat_number
|
194
|
-
end
|
195
|
-
|
196
|
-
customer_text = customer_text.select(&:present?).join("\n")
|
197
|
-
|
198
201
|
bounding_box [bounds.left + padding, bounds.top - padding], height: bounds.height - padding, width: bounds.width - padding do
|
199
|
-
text
|
202
|
+
text customer_content
|
200
203
|
end
|
201
204
|
end
|
202
205
|
end # def build_customer
|
@@ -205,7 +208,9 @@ module Dorsale
|
|
205
208
|
left = bounds.left
|
206
209
|
top = bounds.top - header_height
|
207
210
|
width = bounds.width - left
|
208
|
-
|
211
|
+
height = middle_height
|
212
|
+
|
213
|
+
bounding_box [left, top], width: width, height: height do
|
209
214
|
build_table
|
210
215
|
build_total
|
211
216
|
build_payment_conditions
|
@@ -219,80 +224,115 @@ module Dorsale
|
|
219
224
|
left = bounds.left
|
220
225
|
top = bounds.top
|
221
226
|
width = bounds.width - left
|
227
|
+
height = products_table_height
|
222
228
|
|
223
|
-
|
229
|
+
# Empty table to draw lines
|
230
|
+
bounding_box [left, top], width: width, height: height do
|
224
231
|
repeat :all do
|
225
232
|
float do
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
233
|
+
table [["","","","",""]],
|
234
|
+
:column_widths => [
|
235
|
+
first_column_width,
|
236
|
+
second_column_width,
|
237
|
+
third_column_width,
|
238
|
+
fourth_column_width,
|
239
|
+
last_column_width,
|
240
|
+
],
|
241
|
+
:cell_style => {height: height} \
|
242
|
+
do
|
243
|
+
row(0).style :text_color => BLACK
|
244
|
+
row(0).style :font_style => :bold
|
245
|
+
column(0).style :align => :left
|
246
|
+
column(1..4).style :align => :right
|
247
|
+
end # table
|
248
|
+
end # float
|
249
|
+
end # repeat all
|
250
|
+
end # bounding_box
|
251
|
+
|
252
|
+
# products table
|
253
|
+
bounding_box [left, top], width: width, height: height do
|
239
254
|
draw_bounds_debug
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
255
|
+
|
256
|
+
table_products = [[
|
257
|
+
main_document.t(:designation).mb_chars.upcase.to_s,
|
258
|
+
main_document.t(:quantity).mb_chars.upcase.to_s,
|
259
|
+
main_document.t(:unit).mb_chars.upcase.to_s,
|
260
|
+
main_document.t(:unit_price).mb_chars.upcase.to_s,
|
261
|
+
main_document.t(:line_total).mb_chars.upcase.to_s,
|
262
|
+
]]
|
263
|
+
|
264
|
+
main_document.lines.each do |line|
|
265
|
+
table_products.push [
|
266
|
+
line.label,
|
267
|
+
number(line.quantity).gsub(",00","").gsub(".00",""),
|
268
|
+
line.unit,
|
269
|
+
euros(line.unit_price),
|
270
|
+
euros(line.total),
|
271
|
+
]
|
256
272
|
end
|
257
273
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
274
|
+
table table_products,
|
275
|
+
:column_widths => [
|
276
|
+
first_column_width,
|
277
|
+
second_column_width,
|
278
|
+
third_column_width,
|
279
|
+
fourth_column_width,
|
280
|
+
last_column_width,
|
281
|
+
],
|
282
|
+
:header => true,
|
283
|
+
:cell_style => {border_width: 0} \
|
284
|
+
do
|
262
285
|
row(0).font_style = :bold
|
263
286
|
row(0).border_width = 1,
|
264
|
-
cells.style
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
end
|
269
|
-
end
|
287
|
+
cells.style { |c| c.align = c.column == 0 ? :left : :right }
|
288
|
+
end # table
|
289
|
+
end # bounding_box
|
290
|
+
end # build_table
|
270
291
|
|
271
292
|
def build_total
|
272
|
-
|
273
293
|
left = bounds.left
|
274
|
-
top = bounds.top -
|
294
|
+
top = bounds.top - products_table_height - 5.mm
|
275
295
|
width = bounds.width - left
|
296
|
+
height = middle_height - products_table_height
|
276
297
|
|
277
|
-
bounding_box [left, top], width: width, height:
|
298
|
+
bounding_box [left, top], width: width, height: height do
|
278
299
|
draw_bounds_debug
|
279
300
|
|
280
301
|
table_totals = [[]]
|
281
302
|
|
282
303
|
if has_discount
|
283
|
-
table_totals.push [
|
304
|
+
table_totals.push [
|
305
|
+
main_document.t(:commercial_discount).mb_chars.upcase.to_s,
|
306
|
+
euros(-main_document.commercial_discount),
|
307
|
+
]
|
284
308
|
end
|
285
309
|
|
286
|
-
table_totals.push [
|
310
|
+
table_totals.push [
|
311
|
+
main_document.t(:total_excluding_taxes).mb_chars.upcase.to_s,
|
312
|
+
euros(main_document.total_excluding_taxes),
|
313
|
+
]
|
287
314
|
|
288
|
-
vat_rate = number(
|
289
|
-
table_totals.push [
|
315
|
+
vat_rate = number(main_document.vat_rate)
|
316
|
+
table_totals.push [
|
317
|
+
"#{main_document.t(:vat).mb_chars.upcase.to_s} #{percentage vat_rate}",
|
318
|
+
euros(main_document.vat_amount),
|
319
|
+
]
|
290
320
|
|
291
321
|
if has_advance
|
292
|
-
table_totals.push [
|
293
|
-
|
322
|
+
table_totals.push [
|
323
|
+
main_document.t(:advance).mb_chars.upcase.to_s,
|
324
|
+
euros(main_document.advance),
|
325
|
+
]
|
326
|
+
|
327
|
+
table_totals.push [
|
328
|
+
main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
|
329
|
+
euros(main_document.balance),
|
330
|
+
]
|
294
331
|
else
|
295
|
-
table_totals.push [
|
332
|
+
table_totals.push [
|
333
|
+
main_document.t(:total_including_taxes).mb_chars.upcase.to_s,
|
334
|
+
euros(main_document.total_including_taxes),
|
335
|
+
]
|
296
336
|
end
|
297
337
|
|
298
338
|
table table_totals,
|
@@ -314,13 +354,14 @@ module Dorsale
|
|
314
354
|
end
|
315
355
|
|
316
356
|
def build_comments
|
317
|
-
return if
|
318
|
-
|
319
|
-
|
357
|
+
return if main_document.comments.blank?
|
358
|
+
|
359
|
+
top = bounds.top - products_table_height - 35.mm
|
360
|
+
height = top - bounds.bottom
|
320
361
|
width = 10.cm
|
321
362
|
|
322
363
|
font_size 9 do
|
323
|
-
text_box
|
364
|
+
text_box main_document.comments,
|
324
365
|
:at => [bounds.left, top],
|
325
366
|
:height => height,
|
326
367
|
:width => width,
|
@@ -329,15 +370,15 @@ module Dorsale
|
|
329
370
|
end
|
330
371
|
|
331
372
|
def build_payment_conditions
|
332
|
-
top = bounds.top -
|
373
|
+
top = bounds.top - products_table_height - 5.mm
|
333
374
|
height = 1.cm
|
334
375
|
width = 7.5.cm
|
335
376
|
|
336
377
|
bounding_box [bounds.left, top], height: height, width: width do
|
337
378
|
draw_bounds_debug
|
338
379
|
font_size 9 do
|
339
|
-
text
|
340
|
-
text
|
380
|
+
text main_document.t(:payment_terms), style: :bold if main_document.payment_term.present?
|
381
|
+
text main_document.payment_term.try(:label)
|
341
382
|
end
|
342
383
|
end
|
343
384
|
end
|
@@ -346,61 +387,79 @@ module Dorsale
|
|
346
387
|
end
|
347
388
|
|
348
389
|
def build_bank_informations
|
349
|
-
top = bounds.top -
|
390
|
+
top = bounds.top - products_table_height - 20.mm
|
350
391
|
height = 1.cm
|
351
392
|
width = 7.5.cm
|
352
393
|
|
353
394
|
bounding_box [bounds.left, top], height: height, width: width do
|
354
395
|
draw_bounds_debug
|
355
396
|
font_size 9 do
|
356
|
-
text "#{
|
357
|
-
text "#{
|
397
|
+
text "#{main_document.t(:iban)} : #{@id_card.iban}" if @id_card.iban.present?
|
398
|
+
text "#{main_document.t(:bic_swift)} : #{@id_card.bic_swift}" if @id_card.bic_swift.present?
|
358
399
|
end
|
359
400
|
end
|
360
401
|
end
|
361
402
|
|
362
403
|
def build_footer
|
363
404
|
top = bounds.bottom + footer_height
|
364
|
-
bounding_box [0, top], width: bounds.width, height: footer_height do
|
365
|
-
|
366
|
-
builds_legals
|
367
|
-
build_line
|
368
|
-
builds_id_card_informations
|
369
405
|
|
406
|
+
bounding_box [0, top], width: bounds.width, height: footer_height do
|
407
|
+
draw_bounds_debug
|
408
|
+
build_footer_top
|
409
|
+
build_footer_line
|
410
|
+
build_footer_bottom
|
370
411
|
end
|
371
412
|
end
|
372
413
|
|
373
|
-
def
|
374
|
-
|
375
|
-
|
414
|
+
def footer_top_content
|
415
|
+
@id_card.custom_info_1.to_s
|
416
|
+
end
|
417
|
+
|
418
|
+
def build_footer_top
|
419
|
+
top = bounds.top
|
420
|
+
height = footer_top_height
|
376
421
|
width = bounds.width
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
422
|
+
|
423
|
+
font_size 9 do
|
424
|
+
text_box footer_top_content,
|
425
|
+
:at => [bounds.left, top],
|
426
|
+
:height => height,
|
427
|
+
:width => width,
|
428
|
+
:overflow => :shrink_to_fit
|
381
429
|
end
|
382
430
|
end
|
383
431
|
|
384
|
-
def
|
432
|
+
def build_footer_line
|
433
|
+
# Center line between the two footer parts
|
434
|
+
n = footer_top_height + (footer_height - footer_top_height - footer_bottom_height) / 2
|
435
|
+
move_down n
|
385
436
|
stroke do
|
386
437
|
horizontal_rule
|
387
438
|
line_width 1
|
388
439
|
end
|
389
440
|
end
|
390
441
|
|
391
|
-
def
|
392
|
-
|
393
|
-
|
442
|
+
def footer_bottom_content
|
443
|
+
infos_text = []
|
444
|
+
infos_text << @id_card.entity_name if @id_card.entity_name.present?
|
445
|
+
infos_text << "#{main_document.t(:info_phone)} : #{@id_card.contact_phone}" if @id_card.contact_phone.present?
|
446
|
+
infos_text << "#{main_document.t(:info_fax)} : #{@id_card.contact_fax}" if @id_card.contact_fax.present?
|
447
|
+
infos_text << "#{@id_card.contact_email}" if @id_card.contact_email.present?
|
448
|
+
infos_text << "#{@id_card.legal_form.to_s}" if @id_card.legal_form.present?
|
449
|
+
infos_text << "#{main_document.t(:capital)} : #{euros @id_card.capital}" if @id_card.capital.present?
|
450
|
+
infos_text << "#{main_document.t(:registration)} : #{@id_card.registration_city} #{@id_card.registration_number}" if @id_card.registration_number.present?
|
451
|
+
infos_text << "#{main_document.t(:siret)} : #{@id_card.siret}" if @id_card.siret.present?
|
452
|
+
infos_text << "#{main_document.t(:intracommunity_vat)} : #{@id_card.intracommunity_vat}" if @id_card.intracommunity_vat.present?
|
453
|
+
infos_text = infos_text.join(" - ")
|
454
|
+
end
|
455
|
+
|
456
|
+
def build_footer_bottom
|
457
|
+
height = footer_bottom_height
|
458
|
+
top = bounds.bottom + height
|
394
459
|
width = bounds.width
|
395
|
-
|
396
|
-
fax = "#{I18n.t("pdfs.info_fax")} #{@id_card.contact_fax} -" if @id_card.contact_fax.present?
|
397
|
-
email = "#{@id_card.contact_email}" if @id_card.contact_email.present?
|
398
|
-
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?
|
399
|
-
registration = I18n.t("pdfs.registration") + @id_card.registration_city.to_s + ' ' + @id_card.registration_number.to_s if @id_card.registration_number.present?
|
400
|
-
siret = I18n.t("pdfs.siret") + @id_card.siret.to_s if @id_card.siret.present?
|
401
|
-
tva = I18n.t("pdfs.vat") + @id_card.intracommunity_vat.to_s if @id_card.intracommunity_vat.present?
|
460
|
+
|
402
461
|
font_size 9 do
|
403
|
-
text_box
|
462
|
+
text_box footer_bottom_content,
|
404
463
|
:at => [bounds.left, top],
|
405
464
|
:height => height,
|
406
465
|
:width => width,
|
@@ -409,15 +468,14 @@ module Dorsale
|
|
409
468
|
end
|
410
469
|
|
411
470
|
def build_page_numbers
|
412
|
-
|
413
|
-
|
471
|
+
height = 5.mm
|
472
|
+
top = bounds.bottom + height
|
473
|
+
width = bounds.width
|
474
|
+
|
475
|
+
bounding_box [0, top], height: height, width: bounds.width do
|
414
476
|
font_size 9 do
|
415
477
|
float do
|
416
|
-
|
417
|
-
:align => :right,
|
418
|
-
:start_count_at => 1
|
419
|
-
}
|
420
|
-
number_pages "page <page>/<total>", options
|
478
|
+
number_pages "page <page>/<total>", align: :right
|
421
479
|
end
|
422
480
|
end
|
423
481
|
end
|