ruby_danfe 0.0.4 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ruby_danfe.rb +282 -647
- data/ruby_danfe.gemspec +2 -1
- metadata +18 -4
data/lib/ruby_danfe.rb
CHANGED
@@ -1,11 +1,25 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'prawn'
|
3
3
|
require 'prawn/measurement_extensions'
|
4
|
+
require 'barby'
|
5
|
+
require 'barby/barcode/code_128'
|
6
|
+
require 'barby/outputter/prawn_outputter'
|
4
7
|
require 'nokogiri'
|
5
8
|
|
9
|
+
def numerify(number, decimals = 2)
|
10
|
+
return '' if !number || number == ''
|
11
|
+
int, frac = ("%.#{decimals}f" % number).split('.')
|
12
|
+
int.gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1\.")
|
13
|
+
int + "," + frac
|
14
|
+
end
|
15
|
+
|
16
|
+
def invert(y)
|
17
|
+
28.7.cm - y
|
18
|
+
end
|
19
|
+
|
6
20
|
module RubyDanfe
|
7
21
|
|
8
|
-
version = "0.0
|
22
|
+
version = "0.9.0"
|
9
23
|
|
10
24
|
class XML
|
11
25
|
def initialize(xml)
|
@@ -18,672 +32,293 @@ module RubyDanfe
|
|
18
32
|
def render
|
19
33
|
RubyDanfe.render @xml.to_s
|
20
34
|
end
|
35
|
+
def collect(xpath, &block)
|
36
|
+
result = []
|
37
|
+
@xml.xpath(xpath).each do |det|
|
38
|
+
result << yield(det)
|
39
|
+
end
|
40
|
+
result
|
41
|
+
end
|
21
42
|
end
|
22
43
|
|
23
|
-
|
44
|
+
class Document < Prawn::Document
|
24
45
|
|
25
|
-
|
46
|
+
|
47
|
+
def ititle(h, w, x, y, title)
|
48
|
+
self.text_box title, :size => 10, :at => [x.cm, invert(y.cm) - 2], :width => w.cm, :height => h.cm, :style => :bold
|
49
|
+
end
|
50
|
+
|
51
|
+
def ibarcode(h, w, x, y, info)
|
52
|
+
Barby::Code128C.new(info).annotate_pdf(self, :x => x.cm, :y => invert(y.cm), :width => w.cm, :height => h.cm) if info != ''
|
53
|
+
end
|
54
|
+
|
55
|
+
def irectangle(h, w, x, y)
|
56
|
+
self.stroke_rectangle [x.cm, invert(y.cm)], w.cm, h.cm
|
57
|
+
end
|
58
|
+
|
59
|
+
def ibox(h, w, x, y, title = '', info = '', options = {})
|
60
|
+
box [x.cm, invert(y.cm)], w.cm, h.cm, title, info, options
|
61
|
+
end
|
62
|
+
|
63
|
+
def idate(h, w, x, y, title = '', info = '', options = {})
|
64
|
+
tt = info.split('-')
|
65
|
+
ibox h, w, x, y, title, "#{tt[2]}/#{tt[1]}/#{tt[0]}", options
|
66
|
+
end
|
67
|
+
|
68
|
+
def box(at, w, h, title = '', info = '', options = {})
|
69
|
+
options = {
|
70
|
+
:align => :left,
|
71
|
+
:size => 10,
|
72
|
+
:style => nil,
|
73
|
+
:valign => :top,
|
74
|
+
:border => 1
|
75
|
+
}.merge(options)
|
76
|
+
self.stroke_rectangle at, w, h if options[:border] == 1
|
77
|
+
self.text_box title, :size => 6, :at => [at[0] + 2, at[1] - 2], :width => w - 4, :height => 8 if title != ''
|
78
|
+
self.text_box info, :size => options[:size], :at => [at[0] + 2, at[1] - (title != '' ? 14 : 4) ], :width => w - 4, :height => h - (title != '' ? 14 : 4), :align => options[:align], :style => options[:style], :valign => options[:valign]
|
79
|
+
end
|
80
|
+
|
81
|
+
def inumeric(h, w, x, y, title = '', info = '', options = {})
|
82
|
+
numeric [x.cm, invert(y.cm)], w.cm, h.cm, title, info, options
|
83
|
+
end
|
84
|
+
|
85
|
+
def numeric(at, w, h, title = '', info = '', options = {})
|
86
|
+
options = {:decimals => 2}.merge(options)
|
87
|
+
info = numerify(info, options[:decimals]) if info != ''
|
88
|
+
box at, w, h, title, info, options.merge({:align => :right})
|
89
|
+
end
|
90
|
+
|
91
|
+
def itable(h, w, x, y, data, options = {}, &block)
|
92
|
+
self.bounding_box [x.cm, invert(y.cm)], :width => w.cm, :height => h.cm do
|
93
|
+
self.table data, options do |table|
|
94
|
+
yield(table)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.generatePDF(xml)
|
101
|
+
|
102
|
+
pdf = Document.new(
|
26
103
|
:page_size => 'A4',
|
27
104
|
:page_layout => :portrait,
|
28
|
-
:left_margin => 0
|
29
|
-
:right_margin => 0
|
30
|
-
:top_margin => 0
|
31
|
-
:botton_margin => 0
|
105
|
+
:left_margin => 0,
|
106
|
+
:right_margin => 0,
|
107
|
+
:top_margin => 0,
|
108
|
+
:botton_margin => 0
|
32
109
|
)
|
33
|
-
|
34
|
-
#
|
35
|
-
pdf.stroke_rectangle [342, 693], 222, 22
|
36
|
-
|
37
|
-
# rectangle
|
38
|
-
pdf.stroke_rectangle [342, 737], 222, 84
|
39
|
-
|
40
|
-
# rectangle
|
41
|
-
pdf.stroke_rectangle [361, 497], 96, 18
|
42
|
-
|
43
|
-
# rectangle
|
44
|
-
pdf.stroke_rectangle [457, 789], 107, 37
|
45
|
-
|
46
|
-
# rectangle
|
47
|
-
pdf.stroke_rectangle [126, 566], 63, 44
|
48
|
-
|
49
|
-
# rectangle
|
50
|
-
pdf.stroke_rectangle [63, 566], 63, 44
|
51
|
-
|
52
|
-
# rectangle
|
53
|
-
pdf.stroke_rectangle [0, 566], 63, 44
|
54
|
-
|
55
|
-
# rectangle
|
56
|
-
pdf.stroke_rectangle [443, 471], 24, 18
|
57
|
-
|
58
|
-
# rectangle
|
110
|
+
|
111
|
+
pdf.font "Times-Roman" # Official font
|
59
112
|
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
#
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
# rectangle
|
204
|
-
pdf.stroke_rectangle [74, 769], 383, 17
|
205
|
-
|
206
|
-
# rectangle
|
207
|
-
pdf.stroke_rectangle [189, 566], 63, 44
|
208
|
-
|
209
|
-
# rectangle
|
210
|
-
pdf.stroke_rectangle [252, 566], 63, 44
|
211
|
-
|
212
|
-
# rectangle
|
213
|
-
pdf.stroke_rectangle [315, 566], 63, 44
|
214
|
-
|
215
|
-
# rectangle
|
216
|
-
pdf.stroke_rectangle [378, 566], 63, 44
|
217
|
-
|
218
|
-
# rectangle
|
219
|
-
pdf.stroke_rectangle [441, 566], 63, 44
|
220
|
-
|
221
|
-
# rectangle
|
222
|
-
pdf.stroke_rectangle [504, 566], 60, 44
|
223
|
-
|
224
|
-
# rectangle
|
225
|
-
pdf.stroke_rectangle [0, 407], 564, 213
|
226
|
-
|
227
|
-
# rectangle
|
228
|
-
pdf.stroke_rectangle [0, 157], 341, 173
|
229
|
-
|
230
|
-
# rectangle
|
231
|
-
pdf.stroke_rectangle [341, 157], 223, 173
|
232
|
-
|
233
|
-
# rectangle
|
234
|
-
pdf.stroke_rectangle [0, 186], 112, 20
|
235
|
-
|
236
|
-
# rectangle
|
237
|
-
pdf.stroke_rectangle [111, 186], 145, 20
|
238
|
-
|
239
|
-
# rectangle
|
240
|
-
pdf.stroke_rectangle [255, 186], 145, 20
|
241
|
-
|
242
|
-
# rectangle
|
243
|
-
pdf.stroke_rectangle [399, 186], 165, 20
|
244
|
-
|
245
|
-
# staticText
|
246
|
-
pdf.draw_text "PROTOCOLO DE AUTORIZAÇÃO DE USO", :size => 5, :at => [346, 666], :width => 142, :height => 7
|
247
|
-
|
248
|
-
# textField xml['infProt/nProt'] + ' ' + xml['infProt/dhRecbto']
|
249
|
-
pdf.draw_text xml['infProt/nProt'] + ' ' + xml['infProt/dhRecbto'], :size => 6, :at => [347, 657], :width => 215, :height => 9
|
250
|
-
|
251
|
-
# staticText
|
252
|
-
pdf.draw_text "Consulta de autenticidade no portal nacional da NF-e www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora", :size => 6, :at => [344, 678], :width => 218, :height => 17
|
253
|
-
|
254
|
-
# staticText
|
255
|
-
pdf.draw_text "N°.", :size => 7, :at => [460, 768], :width => 9, :height => 9
|
256
|
-
|
257
|
-
# staticText
|
258
|
-
pdf.draw_text "DESTINATÁRIO / REMETENTE", :size => 5, :at => [0, 631], :width => 109, :height => 8
|
259
|
-
|
260
|
-
# staticText
|
261
|
-
pdf.draw_text "CNPJ/CPF", :size => 5, :at => [375, 622], :width => 46, :height => 7
|
262
|
-
|
263
|
-
# staticText
|
264
|
-
pdf.draw_text "DATA DA EMISSÃO", :size => 5, :at => [488, 622], :width => 49, :height => 7
|
265
|
-
|
266
|
-
# staticText
|
267
|
-
pdf.draw_text "NOME/RAZÃO SOCIAL", :size => 5, :at => [3, 622], :width => 107, :height => 7
|
268
|
-
|
269
|
-
# staticText
|
270
|
-
pdf.draw_text "ENDEREÇO", :size => 5, :at => [3, 603], :width => 107, :height => 7
|
271
|
-
|
272
|
-
# staticText
|
273
|
-
pdf.draw_text "BAIRRO / DISTRITO", :size => 5, :at => [307, 603], :width => 69, :height => 7
|
274
|
-
|
275
|
-
# staticText
|
276
|
-
pdf.draw_text "CEP", :size => 5, :at => [429, 603], :width => 30, :height => 7
|
277
|
-
|
278
|
-
# staticText
|
279
|
-
pdf.draw_text "FONE/FAX", :size => 5, :at => [231, 586], :width => 49, :height => 7
|
280
|
-
|
281
|
-
# staticText
|
282
|
-
pdf.draw_text "UF", :size => 5, :at => [340, 586], :width => 17, :height => 7
|
283
|
-
|
284
|
-
# staticText
|
285
|
-
pdf.draw_text "FATURA / DUPLICATAS", :size => 5, :at => [0, 570], :width => 109, :height => 7
|
286
|
-
|
287
|
-
# staticText
|
288
|
-
pdf.draw_text "CÁLCULO DO IMPOSTO", :size => 5, :at => [0, 519], :width => 109, :height => 7
|
289
|
-
|
290
|
-
# staticText
|
291
|
-
pdf.draw_text "BASE DE CÁLCULO DO ICMS", :size => 5, :at => [3, 510], :width => 73, :height => 7
|
292
|
-
|
293
|
-
# staticText
|
294
|
-
pdf.draw_text "VALOR DO ICMS", :size => 5, :at => [136, 510], :width => 78, :height => 7
|
295
|
-
|
296
|
-
# staticText
|
297
|
-
pdf.draw_text "BASE DE CÁLCULO DO ICMS ST", :size => 5, :at => [250, 510], :width => 80, :height => 7
|
298
|
-
|
299
|
-
# staticText
|
300
|
-
pdf.draw_text "VALOR DO ICMS ST", :size => 5, :at => [364, 510], :width => 59, :height => 7
|
301
|
-
|
302
|
-
# staticText
|
303
|
-
pdf.draw_text "VALOR TOTAL DOS PRODUTOS", :size => 5, :at => [460, 510], :width => 79, :height => 7
|
304
|
-
|
305
|
-
# staticText
|
306
|
-
pdf.draw_text "TRANSPORTADOR / VOLUMES TRANSPORTADOS DADOS DO PRODUTO / SERVIÇODADOS DO PRODUTO / SERVIÇODADOS DO PRODUTO / SERVIÇO", :size => 5, :at => [0, 475], :width => 134, :height => 8
|
307
|
-
|
308
|
-
# staticText
|
309
|
-
pdf.draw_text "RAZÃO SOCIAL", :size => 5, :at => [3, 466], :width => 64, :height => 7
|
310
|
-
|
311
|
-
# staticText
|
312
|
-
pdf.draw_text "FRETE POR CONTA", :size => 5, :at => [181, 466], :width => 49, :height => 7
|
313
|
-
|
314
|
-
# staticText
|
315
|
-
pdf.draw_text "CÓDIGO ANTT", :size => 5, :at => [241, 466], :width => 49, :height => 7
|
316
|
-
|
317
|
-
# staticText
|
318
|
-
pdf.draw_text "0-EMITENTE 1-DESTINATÁRIO", :size => 4, :at => [181, 456], :width => 44, :height => 12
|
319
|
-
|
320
|
-
# textField dest/xNome
|
321
|
-
pdf.draw_text xml['dest/xNome'], :size => 7, :at => [3, 612], :width => 366, :height => 9
|
322
|
-
|
323
|
-
# textField enderDest/xLgr enderDest/nro
|
324
|
-
pdf.draw_text xml['enderDest/xLgr'] + " " + xml['enderDest/nro'], :size => 7, :at => [3, 595], :width => 298, :height => 9
|
325
|
-
|
326
|
-
# textField dest/CNPJ
|
327
|
-
pdf.draw_text xml['dest/CNPJ'], :size => 7, :at => [375, 612], :width => 107, :height => 9
|
328
|
-
|
329
|
-
# textField ide/dEmi
|
330
|
-
pdf.draw_text xml['ide/dEmi'], :size => 7, :at => [488, 612], :width => 74, :height => 9
|
331
|
-
|
332
|
-
# textField enderDest/xBairro
|
333
|
-
pdf.draw_text xml['enderDest/xBairro'], :size => 7, :at => [307, 595], :width => 119, :height => 9
|
334
|
-
|
335
|
-
# textField enderDest/CEP
|
336
|
-
pdf.draw_text xml['enderDest/CEP'], :size => 7, :at => [429, 595], :width => 55, :height => 9
|
337
|
-
|
338
|
-
# textField enderDest/UF
|
339
|
-
pdf.draw_text xml['enderDest/UF'], :size => 7, :at => [340, 577], :width => 26, :height => 9
|
340
|
-
|
341
|
-
# textField enderDest/fone
|
342
|
-
pdf.draw_text xml['enderDest/fone'], :size => 7, :at => [231, 577], :width => 104, :height => 9
|
343
|
-
|
344
|
-
# textField total/vBC
|
345
|
-
pdf.draw_text xml['total/vBC'], :size => 7, :at => [3, 501], :width => 127, :height => 9
|
346
|
-
|
347
|
-
# textField total/vICMS
|
348
|
-
pdf.draw_text xml['total/vICMS'], :size => 7, :at => [136, 501], :width => 108, :height => 9
|
349
|
-
|
350
|
-
# textField total/vBCST
|
351
|
-
pdf.draw_text xml['total/vBCST'], :size => 7, :at => [250, 501], :width => 108, :height => 9
|
352
|
-
|
353
|
-
# textField total/vST
|
354
|
-
pdf.draw_text xml['total/vST'], :size => 7, :at => [364, 501], :width => 90, :height => 9
|
355
|
-
|
356
|
-
# textField total/vProd
|
357
|
-
pdf.draw_text xml['total/vProd'], :size => 7, :at => [460, 501], :width => 101, :height => 9
|
358
|
-
|
359
|
-
# textField transporta/xNome
|
360
|
-
pdf.draw_text xml['transporta/xNome'], :size => 7, :at => [3, 457], :width => 174, :height => 9
|
361
|
-
|
362
|
-
# textField transp/modFrete
|
363
|
-
pdf.draw_text xml['transp/modFrete'], :size => 5, :at => [228, 460], :width => 7, :height => 7
|
364
|
-
|
365
|
-
# textField veicTransp/RNTC
|
366
|
-
pdf.draw_text xml['veicTransp/RNTC'], :size => 5, :at => [241, 457], :width => 69, :height => 9
|
367
|
-
|
368
|
-
# staticText DATA DA SAÍDA/ENTRADA
|
369
|
-
pdf.draw_text "DATA DA SAÍDA/ENTRADA", :size => 5, :at => [488, 603], :width => 69, :height => 7
|
370
|
-
|
371
|
-
# staticText HORA DE SAÍDA
|
372
|
-
pdf.draw_text "HORA DE SAÍDA", :size => 5, :at => [488, 586], :width => 53, :height => 7
|
373
|
-
|
374
|
-
# staticText INSCRIÇÃO ESTADUAL
|
375
|
-
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [371, 586], :width => 79, :height => 7
|
376
|
-
|
377
|
-
# textField $F{NR_IE_DESTINO}
|
378
|
-
pdf.draw_text xml['dest/IE'], :size => 7, :at => [371, 577], :width => 111, :height => 9
|
379
|
-
|
380
|
-
# textField $F{DS_MUNICIPIO_DESTINO}
|
381
|
-
pdf.draw_text xml['enderDest/xMun'], :size => 7, :at => [3, 577], :width => 222, :height => 9
|
382
|
-
|
383
|
-
# staticText MUNICÍPIO
|
384
|
-
pdf.draw_text "MUNICÍPIO", :size => 5, :at => [3, 586], :width => 107, :height => 7
|
385
|
-
|
386
|
-
# staticText Número
|
387
|
-
pdf.draw_text "Número", :size => 5, :at => [3, 562], :width => 57, :height => 7
|
388
|
-
|
389
|
-
# staticText Vencimento
|
390
|
-
pdf.draw_text "Vencimento", :size => 5, :at => [67, 562], :width => 56, :height => 7
|
391
|
-
|
392
|
-
# staticText Valor
|
393
|
-
pdf.draw_text "Valor", :size => 5, :at => [130, 562], :width => 55, :height => 7
|
394
|
-
|
395
|
-
# textField $F{VL_OUTROS}
|
396
|
-
pdf.draw_text xml['total/vOutros'], :size => 7, :at => [272, 483], :width => 86, :height => 9
|
397
|
-
|
398
|
-
# staticText OUTRAS DESPESAS ACESSÓRIAS
|
399
|
-
pdf.draw_text "OUTRAS DESPESAS ACESSÓRIAS", :size => 5, :at => [272, 492], :width => 84, :height => 7
|
400
|
-
|
401
|
-
# textField $F{VL_SEGURO}
|
402
|
-
pdf.draw_text xml['total/vSeg'], :size => 7, :at => [93, 483], :width => 83, :height => 9
|
403
|
-
|
404
|
-
# staticText VALOR DO SEGURO
|
405
|
-
pdf.draw_text "VALOR DO SEGURO", :size => 5, :at => [93, 492], :width => 59, :height => 7
|
406
|
-
|
407
|
-
# staticText DESCONTO
|
408
|
-
pdf.draw_text "DESCONTO", :size => 5, :at => [182, 492], :width => 35, :height => 7
|
409
|
-
|
410
|
-
# textField $F{VL_DESCONTO}
|
411
|
-
pdf.draw_text xml['total/vDesc'], :size => 7, :at => [182, 483], :width => 85, :height => 9
|
412
|
-
|
413
|
-
# staticText VALOR DO FRETE
|
414
|
-
pdf.draw_text "VALOR DO FRETE", :size => 5, :at => [3, 492], :width => 50, :height => 7
|
415
|
-
|
416
|
-
# textField $F{VL_FRETE}
|
417
|
-
pdf.draw_text xml['total/vlFrete'], :size => 7, :at => [3, 483], :width => 84, :height => 9
|
418
|
-
|
419
|
-
# textField $F{VL_NF}
|
420
|
-
pdf.draw_text xml['total/vNF'], :size => 7, :at => [461, 483], :width => 99, :height => 9
|
421
|
-
|
422
|
-
# staticText VALOR TOTAL DA NOTA
|
423
|
-
pdf.draw_text "VALOR TOTAL DA NOTA", :size => 5, :at => [461, 492], :width => 61, :height => 7
|
424
|
-
|
425
|
-
# staticText PLACA DO VEÍCULO
|
426
|
-
pdf.draw_text "PLACA DO VEÍCULO", :size => 5, :at => [315, 466], :width => 69, :height => 7
|
427
|
-
|
428
|
-
# staticText CNPJ / CPF
|
429
|
-
pdf.draw_text "CNPJ / CPF", :size => 5, :at => [469, 466], :width => 69, :height => 7
|
430
|
-
|
431
|
-
# textField transporta/CNPJ
|
432
|
-
pdf.draw_text xml['transporta/CNPJ'], :size => 7, :at => [469, 457], :width => 92, :height => 9
|
433
|
-
|
434
|
-
# textField transporta/xMun
|
435
|
-
pdf.draw_text xml['transporta/xMun'], :size => 7, :at => [263, 439], :width => 177, :height => 10
|
436
|
-
|
437
|
-
# staticText
|
438
|
-
pdf.draw_text "MUNICÍPIO", :size => 5, :at => [263, 448], :width => 64, :height => 7
|
439
|
-
|
440
|
-
# textField transporta/xEnder
|
441
|
-
pdf.draw_text xml['transporta/xEnder'], :size => 7, :at => [3, 439], :width => 255, :height => 9
|
442
|
-
|
443
|
-
# staticText
|
444
|
-
pdf.draw_text "ENDEREÇO", :size => 5, :at => [3, 448], :width => 64, :height => 7
|
445
|
-
|
446
|
-
# staticText
|
447
|
-
pdf.draw_text "QUANTIDADE", :size => 5, :at => [3, 430], :width => 39, :height => 7
|
448
|
-
|
449
|
-
# textField vol/qVol
|
450
|
-
pdf.draw_text xml['vol/qVol'], :size => 7, :at => [3, 421], :width => 60, :height => 9
|
451
|
-
|
452
|
-
# textField vol/esp
|
453
|
-
pdf.draw_text xml['vol/esp'], :size => 7, :at => [70, 421], :width => 111, :height => 9
|
454
|
-
|
455
|
-
# staticText
|
456
|
-
pdf.draw_text "ESPÉCIE", :size => 5, :at => [70, 430], :width => 29, :height => 7
|
457
|
-
|
458
|
-
# staticText
|
459
|
-
pdf.draw_text "MARCA", :size => 5, :at => [187, 430], :width => 62, :height => 7
|
460
|
-
|
461
|
-
# textField vol/marca
|
462
|
-
pdf.draw_text xml['vol/marca'], :size => 7, :at => [187, 421], :width => 97, :height => 9
|
463
|
-
|
464
|
-
# staticText
|
465
|
-
pdf.draw_text "NUMERAÇÃO", :size => 5, :at => [294, 430], :width => 62, :height => 7
|
466
|
-
|
467
|
-
# textField
|
468
|
-
pdf.draw_text "", :size => 7, :at => [294, 421], :width => 103, :height => 9
|
469
|
-
|
470
|
-
# staticText UF
|
471
|
-
pdf.draw_text "UF", :size => 5, :at => [446, 448], :width => 14, :height => 7
|
472
|
-
|
473
|
-
# textField tranporta/UF
|
474
|
-
pdf.draw_text xml['tranporta/UF'], :size => 7, :at => [446, 439], :width => 19, :height => 9
|
475
|
-
|
476
|
-
# textField transporta/IE
|
477
|
-
pdf.draw_text xml['transporta/IE'], :size => 7, :at => [470, 439], :width => 91, :height => 9
|
478
|
-
|
479
|
-
# staticText
|
480
|
-
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [470, 448], :width => 69, :height => 7
|
481
|
-
|
482
|
-
# staticText
|
483
|
-
pdf.draw_text "PESO BRUTO", :size => 5, :at => [403, 430], :width => 76, :height => 7
|
484
|
-
|
485
|
-
# textField vol/pesoB
|
486
|
-
pdf.draw_text xml['vol/pesoB'], :size => 7, :at => [403, 421], :width => 76, :height => 9
|
487
|
-
|
488
|
-
# textField 'vol/pesoL'
|
489
|
-
pdf.draw_text xml['vol/pesoL'], :size => 7, :at => [484, 421], :width => 77, :height => 9
|
490
|
-
|
491
|
-
# staticText
|
492
|
-
pdf.draw_text "PESO LÍQUIDO", :size => 5, :at => [484, 430], :width => 76, :height => 7
|
493
|
-
|
494
|
-
# textField transp/pĺaca
|
495
|
-
pdf.draw_text xml['transp/pĺaca'], :size => 7, :at => [315, 457], :width => 125, :height => 9
|
496
|
-
|
497
|
-
# staticText UF
|
498
|
-
pdf.draw_text "UF", :size => 5, :at => [446, 466], :width => 8, :height => 7
|
499
|
-
|
500
|
-
# textField transp/UF
|
501
|
-
pdf.draw_text xml['transp/UF'], :size => 7, :at => [446, 457], :width => 18, :height => 9
|
502
|
-
|
503
|
-
# staticText
|
504
|
-
pdf.draw_text "VALOR DO IPI", :size => 5, :at => [364, 492], :width => 43, :height => 7
|
505
|
-
|
506
|
-
# textField total/vIPI
|
507
|
-
pdf.draw_text xml['total/vIPI'], :size => 7, :at => [364, 483], :width => 90, :height => 9
|
508
|
-
|
509
|
-
# staticText
|
510
|
-
pdf.draw_text "DANFE", :size => 10, :at => [281, 729], :width => 58, :height => 12
|
511
|
-
|
512
|
-
# staticText
|
513
|
-
pdf.draw_text "DOCUMENTO AUXILIAR DA NOTA FISCAL ELETRÔNICA", :size => 5, :at => [280, 715], :width => 60, :height => 17
|
514
|
-
|
515
|
-
# staticText
|
516
|
-
pdf.draw_text "0 - ENTRADA 1 - SAÍDA", :size => 5, :at => [286, 699], :width => 34, :height => 14
|
517
|
-
|
518
|
-
# staticText
|
519
|
-
pdf.draw_text "NATUREZA DA OPERAÇÃO", :size => 5, :at => [3, 666], :width => 107, :height => 7
|
520
|
-
|
521
|
-
# staticText
|
522
|
-
pdf.draw_text "INSCRIÇÃO ESTADUAL", :size => 5, :at => [3, 648], :width => 69, :height => 7
|
523
|
-
|
524
|
-
# staticText
|
525
|
-
pdf.draw_text "INSC.ESTADUAL DO SUBST. TRIBUTÁRIO", :size => 5, :at => [192, 648], :width => 107, :height => 7
|
526
|
-
|
527
|
-
# staticText
|
528
|
-
pdf.draw_text "CNPJ", :size => 5, :at => [381, 648], :width => 16, :height => 7
|
529
|
-
|
530
|
-
# textField ide/natOp
|
531
|
-
pdf.draw_text xml['ide/natOp'], :size => 7, :at => [3, 657], :width => 336, :height => 9
|
532
|
-
|
533
|
-
# textField emit/IE
|
534
|
-
pdf.draw_text xml['emit/IE'], :size => 7, :at => [3, 639], :width => 183, :height => 9
|
535
|
-
|
536
|
-
# textField emit/IE_ST
|
537
|
-
pdf.draw_text xml['emit/IE_ST'], :size => 7, :at => [192, 639], :width => 183, :height => 9
|
538
|
-
|
539
|
-
# textField emit/CNPJ
|
540
|
-
pdf.draw_text xml['emit/CNPJ'], :size => 7, :at => [381, 639], :width => 181, :height => 9
|
541
|
-
|
542
|
-
# textField ide/dSaiEnt
|
543
|
-
pdf.draw_text xml['ide/dSaiEnt'], :size => 5, :at => [328, 704], :width => 5, :height => 6
|
544
|
-
|
545
|
-
# textField ide/serie
|
546
|
-
pdf.draw_text xml['ide/serie'], :size => 6, :at => [301, 683], :width => 38, :height => 7
|
547
|
-
|
548
|
-
# staticText
|
549
|
-
pdf.draw_text "SÉRIE", :size => 6, :at => [282, 683], :width => 19, :height => 7
|
550
|
-
|
551
|
-
# textField ide/nNF
|
552
|
-
pdf.draw_text xml['ide/nNF'], :size => 7, :at => [291, 690], :width => 48, :height => 9
|
553
|
-
|
554
|
-
# staticText
|
555
|
-
pdf.draw_text "DATA DE RECEBIMENTO", :size => 5, :at => [3, 764], :width => 65, :height => 7
|
556
|
-
|
557
|
-
# staticText
|
558
|
-
pdf.draw_text "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR", :size => 5, :at => [77, 764], :width => 259, :height => 7
|
559
|
-
|
560
|
-
# staticText
|
561
|
-
pdf.draw_text "NF-e", :size => 9, :at => [460, 778], :width => 102, :height => 12
|
562
|
-
|
563
|
-
# textField ide/serie
|
564
|
-
pdf.draw_text xml['ide/serie'], :size => 7, :at => [486, 759], :width => 76, :height => 9
|
565
|
-
|
566
|
-
# textField ide/nNF
|
567
|
-
pdf.draw_text xml['ide/nNF'], :size => 7, :at => [469, 768], :width => 93, :height => 9
|
568
|
-
|
569
|
-
# textField
|
570
|
-
pdf.draw_text "RECEBEMOS DE " + xml['emit/xNome'] + " OS PRODUTOS CONSTANTES DA NOTA FISCAL INDICADA A BAIXO", :size => 5, :at => [3, 784], :width => 450, :height => 8
|
571
|
-
|
572
|
-
# staticText
|
573
|
-
pdf.draw_text "SÉRIE", :size => 7, :at => [460, 759], :width => 26, :height => 9
|
574
|
-
|
575
|
-
# staticText
|
576
|
-
pdf.draw_text "CHAVE DE ACESSO", :size => 5, :at => [345, 708], :width => 67, :height => 7
|
577
|
-
|
578
|
-
# staticText
|
579
|
-
pdf.draw_text "FOLHA", :size => 6, :at => [282, 676], :width => 19, :height => 7
|
580
|
-
|
581
|
-
# textField
|
582
|
-
pdf.draw_text " 1 / 1", :size => 6, :at => [301, 676], :width => 9, :height => 7
|
583
|
-
|
584
|
-
# textField chNFe
|
585
|
-
pdf.draw_text xml['chNFe'], :size => 6, :at => [345, 699], :width => 217, :height => 9
|
586
|
-
|
587
|
-
# staticText
|
588
|
-
pdf.draw_text "DADOS DO PRODUTO / SERVIÇO", :size => 5, :at => [0, 412], :width => 134, :height => 8
|
589
|
-
|
590
|
-
# staticText
|
591
|
-
pdf.draw_text "N°", :size => 7, :at => [282, 690], :width => 10, :height => 9
|
592
|
-
|
593
|
-
# textField emit/xNome
|
594
|
-
pdf.draw_text xml['emit/xNome'], :size => 7, :at => [76, 720], :width => 198, :height => 21
|
595
|
-
|
596
|
-
# textField enderEmit/xLgr enderEmit/nro
|
597
|
-
pdf.draw_text xml['enderEmit/xLgr'] + ", " + xml['enderEmit/nro'], :size => 7, :at => [76, 709], :width => 198, :height => 10
|
598
|
-
|
599
|
-
# textField enderEmit/xBairro
|
600
|
-
pdf.draw_text xml['enderEmit/xBairro'] + " - " + xml['enderEmit/CEP'], :size => 7, :at => [76, 699], :width => 198, :height => 10
|
601
|
-
|
602
|
-
# textField enderEmit/xMun enderEmit/UF
|
603
|
-
pdf.draw_text xml['enderEmit/xMun'] + "/" + xml['enderEmit/UF'], :size => 6, :at => [76, 689], :width => 198, :height => 10
|
604
|
-
|
605
|
-
# textField enderEmit/fone enderEmit/email
|
606
|
-
pdf.draw_text xml['enderEmit/fone'] + " " + xml['enderEmit/email'], :size => 6, :at => [76, 679], :width => 198, :height => 10
|
607
|
-
|
608
|
-
# textField ide/dSaiEnt
|
609
|
-
pdf.draw_text xml['ide/dSaiEnt'], :size => 7, :at => [488, 595], :width => 74, :height => 9
|
610
|
-
|
611
|
-
# textField ide/dSaiEnt
|
612
|
-
pdf.draw_text xml['ide/dSaiEnt'], :size => 7, :at => [488, 577], :width => 74, :height => 9
|
613
|
-
|
614
|
-
# staticText
|
615
|
-
pdf.draw_text "Número", :size => 5, :at => [192, 562], :width => 57, :height => 7
|
616
|
-
|
617
|
-
# staticText
|
618
|
-
pdf.draw_text "Vencimento", :size => 5, :at => [256, 562], :width => 56, :height => 7
|
619
|
-
|
620
|
-
# staticText
|
621
|
-
pdf.draw_text "Valor", :size => 5, :at => [319, 562], :width => 55, :height => 7
|
622
|
-
|
623
|
-
# staticText
|
624
|
-
pdf.draw_text "Número", :size => 5, :at => [381, 562], :width => 57, :height => 7
|
625
|
-
|
626
|
-
# staticText
|
627
|
-
pdf.draw_text "Vencimento", :size => 5, :at => [445, 562], :width => 56, :height => 7
|
628
|
-
|
629
|
-
# staticText
|
630
|
-
pdf.draw_text "Valor", :size => 5, :at => [508, 562], :width => 50, :height => 7
|
631
|
-
|
632
|
-
# textField infAdic/infCpl
|
633
|
-
pdf.draw_text xml['infAdic/infCpl'], :size => 6, :at => [-10, -50], :width => 334, :height => 161
|
634
|
-
|
635
|
-
# staticText
|
636
|
-
pdf.draw_text "DADOS ADICIONAIS", :size => 5, :at => [0, 161], :width => 134, :height => 7
|
637
|
-
|
638
|
-
# staticText
|
639
|
-
pdf.draw_text "CÁLCULO DO ISSQN", :size => 5, :at => [0, 190], :width => 134, :height => 8
|
640
|
-
|
641
|
-
# staticText
|
642
|
-
pdf.draw_text "INSCRIÇÃO MUNICIPAL", :size => 5, :at => [3, 181], :width => 83, :height => 8
|
643
|
-
|
644
|
-
# staticText
|
645
|
-
pdf.draw_text "VALOR TOTAL DOS SERVIÇOS", :size => 5, :at => [114, 181], :width => 103, :height => 8
|
646
|
-
|
647
|
-
# textField total/vServ
|
648
|
-
pdf.draw_text xml['total/vServ'], :size => 7, :at => [114, 170], :width => 138, :height => 10
|
649
|
-
|
650
|
-
# textField emit/IM
|
651
|
-
pdf.draw_text xml['emit/IM'], :size => 7, :at => [3, 170], :width => 105, :height => 10
|
652
|
-
|
653
|
-
# staticText
|
654
|
-
pdf.draw_text "BASE DE CÁLCULO DO ISSQN", :size => 5, :at => [258, 181], :width => 103, :height => 8
|
655
|
-
|
656
|
-
# textField total/vBCISS
|
657
|
-
pdf.draw_text xml['total/vBCISS'], :size => 7, :at => [258, 170], :width => 138, :height => 10
|
658
|
-
|
659
|
-
# staticText
|
660
|
-
pdf.draw_text "VALOR DO ISSQN", :size => 5, :at => [402, 181], :width => 103, :height => 8
|
661
|
-
|
662
|
-
# textField total/ISSTot
|
663
|
-
pdf.draw_text xml['total/ISSTot'], :size => 7, :at => [402, 170], :width => 159, :height => 10
|
664
|
-
|
665
|
-
# textField
|
666
|
-
pdf.draw_text "", :size => 6, :at => [331, -50], :width => 216, :height => 163
|
667
|
-
|
668
|
-
# staticText
|
669
|
-
pdf.draw_text "RESERVADO AO FISCO", :size => 5, :at => [345, 153], :width => 96, :height => 7
|
113
|
+
pdf.repeat :all do
|
114
|
+
|
115
|
+
# CANHOTO
|
116
|
+
|
117
|
+
pdf.ibox 0.85, 16.10, 0.25, 0.42, "RECEBEMOS DE " + xml['emit/xNome'] + " OS PRODUTOS CONSTANTES DA NOTA FISCAL INDICADA ABAIXO"
|
118
|
+
pdf.ibox 0.85, 4.10, 0.25, 1.27, "DATA DE RECEBIMENTO"
|
119
|
+
pdf.ibox 0.85, 12.00, 4.35, 1.27, "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR"
|
120
|
+
|
121
|
+
pdf.ibox 1.70, 4.50, 16.35, 0.42, '',
|
122
|
+
"NF-e\n" +
|
123
|
+
"N°. " + xml['ide/nNF'] + "\n" +
|
124
|
+
"SÉRIE " + xml['ide/serie'], {:align => :center, :valign => :center}
|
125
|
+
|
126
|
+
# EMITENTE
|
127
|
+
|
128
|
+
pdf.ibox 3.92, 7.46, 0.25, 2.54, '',
|
129
|
+
xml['emit/xNome'] + "\n" +
|
130
|
+
xml['enderEmit/xLgr'] + ", " + xml['enderEmit/nro'] + "\n" +
|
131
|
+
xml['enderEmit/xBairro'] + " - " + xml['enderEmit/CEP'] + "\n" +
|
132
|
+
xml['enderEmit/xMun'] + "/" + xml['enderEmit/UF'] + "\n" +
|
133
|
+
xml['enderEmit/fone'] + " " + xml['enderEmit/email'], {:align => :center, :valign => :center}
|
134
|
+
|
135
|
+
pdf.ibox 3.92, 3.08, 7.71, 2.54
|
136
|
+
|
137
|
+
pdf.ibox 0.60, 3.08, 7.71, 2.54, '', "DANFE", {:size => 12, :align => :center, :border => 0, :style => :bold}
|
138
|
+
pdf.ibox 1.20, 3.08, 7.71, 3.14, '', "DOCUMENTO AUXILIAR DA NOTA FISCAL ELETRÔNICA", {:size => 8, :align => :center, :border => 0}
|
139
|
+
pdf.ibox 0.60, 3.08, 7.71, 4.34, '', "#{xml['ide/tpNF']} - " + (xml['ide/tpNF'] == '0' ? 'ENTRADA' : 'SAÍDA'), {:size => 8, :align => :center, :border => 0}
|
140
|
+
|
141
|
+
pdf.ibox 1.00, 3.08, 7.71, 4.94, '',
|
142
|
+
"N°. " + xml['ide/nNF'] + "\n" +
|
143
|
+
"SÉRIE " + xml['ide/serie'], {:size => 8, :align => :center, :valign => :center, :border => 0, :style => :bold}
|
144
|
+
|
145
|
+
pdf.ibox 2.20, 10.02, 10.79, 2.54
|
146
|
+
pdf.ibarcode 1.50, 8.00, 10.9010, 4.44, xml['chNFe']
|
147
|
+
pdf.ibox 0.85, 10.02, 10.79, 4.74, "CHAVE DE ACESSO", xml['chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, "\\1 "), {:style => :bold, :align => :center}
|
148
|
+
pdf.ibox 0.85, 10.02, 10.79, 5.60 , '', "Consulta de autenticidade no portal nacional da NF-e www.nfe.fazenda.gov.br/portal ou no site da Sefaz Autorizadora", {:align => :center, :size => 8}
|
149
|
+
pdf.ibox 0.85, 10.54, 0.25, 6.46, "NATUREZA DA OPERAÇÃO", xml['ide/natOp']
|
150
|
+
pdf.ibox 0.85, 10.02, 10.79, 6.46, "PROTOCOLO DE AUTORIZAÇÃO DE USO", xml['infProt/nProt'] + ' ' + xml['infProt/dhRecbto'], {:align => :center}
|
151
|
+
|
152
|
+
pdf.ibox 0.85, 6.86, 0.25, 7.31, "INSCRIÇÃO ESTADUAL", xml['emit/IE']
|
153
|
+
pdf.ibox 0.85, 6.86, 7.11, 7.31, "INSC.ESTADUAL DO SUBST. TRIBUTÁRIO", xml['emit/IE_ST']
|
154
|
+
pdf.ibox 0.85, 6.84, 13.97, 7.31, "CNPJ", xml['emit/CNPJ']
|
155
|
+
|
156
|
+
# TITULO
|
157
|
+
|
158
|
+
pdf.ititle 0.42, 10.00, 0.25, 8.16, "DESTINATÁRIO / REMETENTE"
|
159
|
+
|
160
|
+
pdf.ibox 0.85, 12.32, 0.25, 8.58, "NOME/RAZÃO SOCIAL", xml['dest/xNome']
|
161
|
+
pdf.ibox 0.85, 5.33, 12.57, 8.58, "CNPJ/CPF", xml['dest/CNPJ'] if xml['dest/CNPJ'] != ''
|
162
|
+
pdf.ibox 0.85, 5.33, 12.57, 8.58, "CNPJ/CPF", xml['dest/CPF'] if xml['dest/CPF'] != ''
|
163
|
+
pdf.idate 0.85, 2.92, 17.90, 8.58, "DATA DA EMISSÃO", xml['ide/dEmi'], {:align => :right}
|
164
|
+
pdf.ibox 0.85, 10.16, 0.25, 9.43, "ENDEREÇO", xml['enderDest/xLgr'] + " " + xml['enderDest/nro']
|
165
|
+
pdf.ibox 0.85, 4.83, 10.41, 9.43, "BAIRRO", xml['enderDest/xBairro']
|
166
|
+
pdf.ibox 0.85, 2.67, 15.24, 9.43, "CEP", xml['enderDest/CEP']
|
167
|
+
pdf.idate 0.85, 2.92, 17.90, 9.43, "DATA DA SAÍDA/ENTRADA", xml['ide/dSaiEnt'], {:align => :right}
|
168
|
+
pdf.ibox 0.85, 7.11, 0.25, 10.28, "MUNICÍPIO", xml['enderDest/xMun']
|
169
|
+
pdf.ibox 0.85, 4.06, 7.36, 10.28, "FONE/FAX", xml['enderDest/fone']
|
170
|
+
pdf.ibox 0.85, 1.14, 11.42, 10.28, "UF", xml['enderDest/UF']
|
171
|
+
pdf.ibox 0.85, 5.33, 12.56, 10.28, "INSCRIÇÃO ESTADUAL", xml['dest/IE']
|
172
|
+
pdf.idate 0.85, 2.92, 17.90, 10.28, "HORA DE SAÍDA", xml['ide/dSaiEnt'], {:align => :right}
|
173
|
+
|
174
|
+
# FATURAS
|
175
|
+
|
176
|
+
pdf.ititle 0.42, 10.00, 0.25, 11.12, "FATURA / DUPLICATAS"
|
177
|
+
pdf.ibox 0.85, 20.57, 0.25, 11.51
|
178
|
+
|
179
|
+
if false
|
180
|
+
pdf.box [0, 563], 63, 44, "Número"
|
181
|
+
pdf.box [63, 563], 63, 44, "Vencimento"
|
182
|
+
pdf.box [126, 563], 63, 44, "Valor"
|
183
|
+
pdf.box [189, 563], 63, 44, "Número"
|
184
|
+
pdf.box [252, 563], 63, 44, "Vencimento"
|
185
|
+
pdf.box [315, 563], 63, 44, "Valor"
|
186
|
+
pdf.box [378, 563], 63, 44, "Número"
|
187
|
+
pdf.box [441, 563], 63, 44, "Vencimento"
|
188
|
+
pdf.box [504, 563], 60, 44, "Valor"
|
189
|
+
end
|
190
|
+
|
191
|
+
pdf.ititle 0.42, 5.60, 0.25, 12.36, "CÁLCULO DO IMPOSTO"
|
192
|
+
|
193
|
+
pdf.inumeric 0.85, 4.06, 0.25, 12.78, "BASE DE CÁLCULO DO ICMS", xml['ICMSTot/vBC']
|
194
|
+
pdf.inumeric 0.85, 4.06, 4.31, 12.78, "VALOR DO ICMS", xml['ICMSTot/vICMS']
|
195
|
+
pdf.inumeric 0.85, 4.06, 8.37, 12.78, "BASE DE CÁLCULO DO ICMS ST", xml['ICMSTot/vBCST']
|
196
|
+
pdf.inumeric 0.85, 4.06, 12.43, 12.78, "VALOR DO ICMS ST", xml['ICMSTot/vST']
|
197
|
+
pdf.inumeric 0.85, 4.32, 16.49, 12.78, "VALOR TOTAL DOS PRODUTOS", xml['ICMSTot/vProd']
|
198
|
+
pdf.inumeric 0.85, 3.46, 0.25, 13.63, "VALOR DO FRETE", xml['ICMSTot/vFrete']
|
199
|
+
pdf.inumeric 0.85, 3.46, 3.71, 13.63, "VALOR DO SEGURO", xml['ICMSTot/vSeg']
|
200
|
+
pdf.inumeric 0.85, 3.46, 7.17, 13.63, "DESCONTO", xml['ICMSTot/vDesc']
|
201
|
+
pdf.inumeric 0.85, 3.46, 10.63, 13.63, "OUTRAS DESPESAS ACESSORIAS", xml['ICMSTot/vOutro']
|
202
|
+
pdf.inumeric 0.85, 3.46, 14.09, 13.63, "VALOR DO IPI", xml['ICMSTot/vIPI']
|
203
|
+
pdf.inumeric 0.85, 3.27, 17.55, 13.63, "VALOR TOTAL DA NOTA", xml['ICMSTot/vNF'], :style => :bold
|
204
|
+
|
205
|
+
pdf.ititle 0.42, 10.00, 0.25, 14.48, "TRANSPORTADOR / VOLUMES TRANSPORTADOS"
|
206
|
+
|
207
|
+
pdf.ibox 0.85, 9.02, 0.25, 14.90, "RAZÃO SOCIAL", xml['transporta/xNome']
|
208
|
+
pdf.ibox 0.85, 2.79, 9.27, 14.90, "FRETE POR CONTA", xml['transp/modFrete'] == '0' ? ' 0 - EMITENTE' : '1 - DEST.'
|
209
|
+
pdf.ibox 0.85, 1.78, 12.06, 14.90, "CODIGO ANTT", xml['veicTransp/RNTC']
|
210
|
+
pdf.ibox 0.85, 2.29, 13.84, 14.90, "PLACA DO VEÍCULO", xml['veicTransp/placa']
|
211
|
+
pdf.ibox 0.85, 0.76, 16.13, 14.90, "UF", xml['veicTransp/UF']
|
212
|
+
pdf.ibox 0.85, 3.94, 16.89, 14.90, "CNPJ/CPF", xml['transporta/CNPJ']
|
213
|
+
pdf.ibox 0.85, 9.02, 0.25, 15.75, "ENDEREÇO", xml['transporta/xEnder']
|
214
|
+
pdf.ibox 0.85, 6.86, 9.27, 15.75, "MUNICÍPIO", xml['transporta/xMun']
|
215
|
+
pdf.ibox 0.85, 0.76, 16.13, 15.75, "UF", xml['transporta/UF']
|
216
|
+
pdf.ibox 0.85, 3.94, 16.89, 15.75, "INSCRIÇÂO ESTADUAL", xml['transporta/IE']
|
217
|
+
pdf.ibox 0.85, 2.92, 0.25, 16.60, "QUANTIDADE", xml['vol/qVol']
|
218
|
+
pdf.ibox 0.85, 3.05, 3.17, 16.60, "ESPÉCIE", xml['vol/esp']
|
219
|
+
pdf.ibox 0.85, 3.05, 6.22, 16.60, "MARCA", xml['vol/marca']
|
220
|
+
pdf.ibox 0.85, 4.83, 9.27, 16.60, "NUMERAÇÃO"
|
221
|
+
pdf.inumeric 0.85, 3.43, 14.10, 16.60, "PESO BRUTO", xml['vol/pesoB'], {:decimals => 3}
|
222
|
+
pdf.inumeric 0.85, 3.30, 17.53, 16.60, "PESO LÍQUIDO", xml['vol/pesoL'], {:decimals => 3}
|
223
|
+
|
224
|
+
pdf.ititle 0.42, 10.00, 0.25, 17.45, "DADOS DO PRODUTO / SERVIÇO"
|
225
|
+
|
226
|
+
pdf.ibox 6.77, 2.00, 0.25, 17.87, "CÓDIGO"
|
227
|
+
pdf.ibox 6.77, 4.50, 2.25, 17.87, "DESCRIÇÃO"
|
228
|
+
pdf.ibox 6.77, 1.50, 6.75, 17.87, "NCM"
|
229
|
+
pdf.ibox 6.77, 0.80, 8.25, 17.87, "CST"
|
230
|
+
pdf.ibox 6.77, 1.00, 9.05, 17.87, "CFOP"
|
231
|
+
pdf.ibox 6.77, 1.00, 10.05, 17.87, "UNID"
|
232
|
+
pdf.ibox 6.77, 1.50, 11.05, 17.87, "QUANT"
|
233
|
+
pdf.ibox 6.77, 1.50, 12.55, 17.87, "VALOR UNIT"
|
234
|
+
pdf.ibox 6.77, 1.50, 14.05, 17.87, "VALOR TOT"
|
235
|
+
pdf.ibox 6.77, 1.50, 15.55, 17.87, "BASE CÁLC"
|
236
|
+
pdf.ibox 6.77, 1.00, 17.05, 17.87, "VL ICMS"
|
237
|
+
pdf.ibox 6.77, 1.00, 18.05, 17.87, "VL IPI"
|
238
|
+
pdf.ibox 6.77, 0.90, 19.05, 17.87, "% ICMS"
|
239
|
+
pdf.ibox 6.77, 0.86, 19.95, 17.87, "% IPI"
|
240
|
+
|
241
|
+
pdf.horizontal_line 0.25.cm, 21.50.cm, :at => invert(18.17.cm)
|
242
|
+
|
243
|
+
pdf.ititle 0.42, 10.00, 0.25, 24.64, "CÁLCULO DO ISSQN"
|
244
|
+
|
245
|
+
pdf.ibox 0.85, 5.08, 0.25, 25.06, "INSCRIÇÃO MUNICIPAL", xml['emit/IM']
|
246
|
+
pdf.ibox 0.85, 5.08, 5.33, 25.06, "VALOR TOTAL DOS SERVIÇOS", xml['total/vServ']
|
247
|
+
pdf.ibox 0.85, 5.08, 10.41, 25.06, "BASE DE CÁLCULO DO ISSQN", xml['total/vBCISS']
|
248
|
+
pdf.ibox 0.85, 5.28, 15.49, 25.06, "VALOR DO ISSQN", xml['total/ISSTot']
|
249
|
+
|
250
|
+
pdf.ititle 0.42, 10.00, 0.25, 25.91, "DADOS ADICIONAIS"
|
251
|
+
|
252
|
+
pdf.ibox 3.07, 12.93, 0.25, 26.33, "INFORMAÇÕES COMPLEMENTARES", xml['infAdic/infCpl'], {:size => 8, :valign => :top}
|
253
|
+
|
254
|
+
pdf.ibox 3.07, 7.62, 13.17, 26.33, "RESERVADO AO FISCO"
|
670
255
|
|
671
|
-
|
672
|
-
pdf.draw_text "INFORMAÇÕES COMPLEMENTARES", :size => 5, :at => [3, 152], :width => 93, :height => 7
|
256
|
+
end
|
673
257
|
|
258
|
+
|
259
|
+
pdf.font_size(6) do
|
260
|
+
pdf.itable 6.37, 21.50, 0.25, 18.17,
|
261
|
+
xml.collect('//xmlns:det') { |det|
|
262
|
+
[
|
263
|
+
det.css('prod/cProd').text, #I02
|
264
|
+
det.css('prod/xProd').text, #I04
|
265
|
+
det.css('prod/NCM').text, #I05
|
266
|
+
det.css('ICMS/*/orig').text, #N11
|
267
|
+
det.css('prod/CFOP').text, #I08
|
268
|
+
det.css('prod/uCom').text, #I09
|
269
|
+
numerify(det.css('prod/qCom').text), #I10
|
270
|
+
numerify(det.css('prod/vUnCom').text), #I10a
|
271
|
+
numerify(det.css('prod/vProd').text), #I11
|
272
|
+
numerify(det.css('ICMS/*/vBC').text), #N15
|
273
|
+
numerify(det.css('ICMS/*/vICMS').text), #N17
|
274
|
+
numerify(det.css('IPI/*/vIPI').text), #O14
|
275
|
+
numerify(det.css('ICMS/*/pICMS').text), #N16
|
276
|
+
numerify(det.css('IPI/*/pIPI').text) #O13
|
277
|
+
]
|
278
|
+
},
|
279
|
+
:column_widths => {
|
280
|
+
0 => 2.00.cm,
|
281
|
+
1 => 4.50.cm,
|
282
|
+
2 => 1.50.cm,
|
283
|
+
3 => 0.80.cm,
|
284
|
+
4 => 1.00.cm,
|
285
|
+
5 => 1.00.cm,
|
286
|
+
6 => 1.50.cm,
|
287
|
+
7 => 1.50.cm,
|
288
|
+
8 => 1.50.cm,
|
289
|
+
9 => 1.50.cm,
|
290
|
+
10 => 1.00.cm,
|
291
|
+
11 => 1.00.cm,
|
292
|
+
12 => 0.90.cm,
|
293
|
+
13 => 0.86.cm
|
294
|
+
},
|
295
|
+
:cell_style => {:padding => 2, :border_width => 0} do |table|
|
296
|
+
pdf.dash(5);
|
297
|
+
table.column(6..13).style(:align => :right)
|
298
|
+
table.column(0..13).border_width = 1
|
299
|
+
table.column(0..13).borders = [:bottom]
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
pdf.page_count.times do |i|
|
304
|
+
pdf.go_to_page(i + 1)
|
305
|
+
pdf.ibox 1.00, 3.08, 7.71, 5.54, '',
|
306
|
+
"FOLHA #{i + 1} de #{pdf.page_count}", {:size => 8, :align => :center, :valign => :center, :border => 0, :style => :bold}
|
307
|
+
end
|
308
|
+
|
674
309
|
return pdf
|
675
310
|
|
676
311
|
end
|
677
312
|
|
678
313
|
def self.render(xml_string)
|
679
314
|
xml = XML.new(xml_string)
|
680
|
-
pdf =
|
315
|
+
pdf = generatePDF(xml)
|
681
316
|
return pdf.render
|
682
317
|
end
|
683
318
|
|
684
319
|
def self.generate(pdf_filename, xml_filename)
|
685
320
|
xml = XML.new(File.new(xml_filename))
|
686
|
-
pdf =
|
321
|
+
pdf = generatePDF(xml)
|
687
322
|
pdf.render_file pdf_filename
|
688
323
|
end
|
689
324
|
|
data/ruby_danfe.gemspec
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'ruby_danfe'
|
3
|
-
s.version = '0.0
|
3
|
+
s.version = '0.9.0'
|
4
4
|
s.summary = "DANFE generator for Brazilian NFE."
|
5
5
|
s.authors = ["Eduardo Rebouças"]
|
6
6
|
s.email = 'eduardo.reboucas@gmail.com'
|
7
7
|
s.files = ["ruby_danfe.gemspec", "lib/ruby_danfe.rb"]
|
8
8
|
s.add_dependency('nokogiri')
|
9
9
|
s.add_dependency('prawn')
|
10
|
+
s.add_dependency('barby')
|
10
11
|
s.homepage = 'https://github.com/taxweb/ruby_danfe'
|
11
12
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_danfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 9
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Eduardo Rebou\xC3\xA7as"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-30 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: nokogiri
|
@@ -45,6 +45,20 @@ dependencies:
|
|
45
45
|
version: "0"
|
46
46
|
type: :runtime
|
47
47
|
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: barby
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
48
62
|
description:
|
49
63
|
email: eduardo.reboucas@gmail.com
|
50
64
|
executables: []
|