br_danfe 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +11 -29
- data/Rakefile +7 -0
- data/br_danfe.gemspec +1 -0
- data/config/locales/pt-BR.yml +1 -1
- data/lib/br_danfe/danfe.rb +64 -0
- data/lib/br_danfe/dest.rb +65 -16
- data/lib/br_danfe/det_body.rb +68 -0
- data/lib/br_danfe/det_header.rb +34 -0
- data/lib/br_danfe/document.rb +12 -6
- data/lib/br_danfe/dup.rb +37 -16
- data/lib/br_danfe/emit.rb +96 -32
- data/lib/br_danfe/helper.rb +1 -1
- data/lib/br_danfe/ie.rb +9 -57
- data/lib/br_danfe/ie_masks.rb +75 -0
- data/lib/br_danfe/infadic.rb +51 -31
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe/vol.rb +18 -12
- data/lib/br_danfe/xprod.rb +32 -27
- data/spec/features/{ruby_danfe_spec.rb → br_danfe_spec.rb} +29 -5
- data/spec/fixtures/nfe_with_cpf.xml +1 -0
- data/spec/fixtures/nfe_with_logo.xml +1 -0
- data/spec/fixtures/nfe_with_logo.xml.logo.png +0 -0
- data/spec/lib/helper_spec.rb +4 -4
- data/spec/lib/xprod_spec.rb +86 -78
- data/spec/spec_helper.rb +2 -0
- metadata +48 -25
- data/lib/br_danfe/danfe_generator.rb +0 -54
- data/lib/br_danfe/det.rb +0 -69
- data/lib/br_danfe/ruby_danfe.rb +0 -42
- data/spec/lib/ruby_danfe_spec.rb +0 -40
data/lib/br_danfe/emit.rb
CHANGED
@@ -1,45 +1,109 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Emit
|
3
|
-
def
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def initialize(pdf, xml, logo_path)
|
4
|
+
@pdf = pdf
|
5
|
+
@xml = xml
|
6
|
+
@logo_path = logo_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def render
|
10
|
+
address_box
|
11
|
+
danfe_box
|
12
|
+
access_key_box
|
13
|
+
sefaz_box
|
14
|
+
operationkind_box
|
15
|
+
protocol_box
|
16
|
+
ie_box
|
17
|
+
ie_st_box
|
18
|
+
cnpj_box
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def address_box
|
23
|
+
@pdf.ibox 3.92, 8.46, 0.25, 2.54
|
24
|
+
|
25
|
+
@pdf.ibox 3.92, 8.46, 0.25, 2.80, "", @xml["emit/xNome"],
|
26
|
+
{ size: 12, align: :center, border: 0, style: :bold }
|
27
|
+
|
28
|
+
if @logo_path.empty?
|
29
|
+
@pdf.ibox 3.92, 8.46, 0.75, 4, "", address, { align: :left, border: 0 }
|
7
30
|
else
|
8
|
-
pdf.ibox 3.92, 8.46,
|
9
|
-
|
10
|
-
|
11
|
-
pdf.image
|
31
|
+
@pdf.ibox 3.92, 8.46, 2.75, 4, "", address,
|
32
|
+
{ size: 8, align: :left, border: 0 }
|
33
|
+
|
34
|
+
@pdf.image @logo_path, at: [0.5.cm, Helper.invert(4.cm)],
|
35
|
+
width: 2.cm
|
12
36
|
end
|
37
|
+
end
|
13
38
|
|
14
|
-
|
39
|
+
def address
|
40
|
+
formatted = @xml["enderEmit/xLgr"] + ", " + @xml["enderEmit/nro"] + "\n"
|
41
|
+
formatted += @xml["enderEmit/xBairro"] + " - " + cep + "\n"
|
42
|
+
formatted += @xml["enderEmit/xMun"] + "/" + @xml["enderEmit/UF"] + "\n"
|
43
|
+
formatted += phone + " " + @xml["enderEmit/email"]
|
15
44
|
|
16
|
-
|
17
|
-
|
18
|
-
|
45
|
+
formatted
|
46
|
+
end
|
47
|
+
|
48
|
+
def phone
|
49
|
+
Phone.format(@xml["enderEmit/fone"])
|
50
|
+
end
|
51
|
+
|
52
|
+
def cep
|
53
|
+
Cep.format(@xml["enderEmit/CEP"])
|
54
|
+
end
|
55
|
+
|
56
|
+
def danfe_box
|
57
|
+
@pdf.ibox 3.92, 2.08, 8.71, 2.54
|
19
58
|
|
20
|
-
pdf.ibox
|
21
|
-
|
59
|
+
@pdf.ibox 0.60, 2.08, 8.71, 2.54, "", "DANFE",
|
60
|
+
{ size: 12, align: :center, border: 0, style: :bold }
|
22
61
|
|
23
|
-
pdf.ibox
|
24
|
-
|
25
|
-
pdf.ibox 0.85, 10.02, 10.79, 4.74, I18n.t("danfe.chNFe"), xml["chNFe"].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, "\\1 "), {style: :bold, align: :center}
|
26
|
-
pdf.ibox 0.85, 10.02, 10.79, 5.60 , "", I18n.t("danfe.others.sefaz"), {align: :center, size: 8}
|
27
|
-
pdf.lbox 0.85, 10.54, 0.25, 6.46, xml, "ide/natOp"
|
28
|
-
pdf.ibox 0.85, 10.02, 10.79, 6.46, I18n.t("danfe.infProt"), xml["infProt/nProt"] + " " + Helper.format_date(xml["infProt/dhRecbto"]) , {align: :center}
|
62
|
+
@pdf.ibox 1.20, 2.08, 8.71, 3.14, "", I18n.t("danfe.others.danfe"),
|
63
|
+
{ size: 8, align: :center, border: 0 }
|
29
64
|
|
30
|
-
pdf.ibox 0.
|
31
|
-
|
32
|
-
|
65
|
+
@pdf.ibox 0.60, 2.08, 8.71, 4.34, "", "#{@xml['ide/tpNF']} - " + (@xml["ide/tpNF"] == "0" ? I18n.t("danfe.ide.tpNF.entry") : I18n.t("danfe.ide.tpNF.departure")),
|
66
|
+
{ size: 8, align: :center, border: 0 }
|
67
|
+
|
68
|
+
@pdf.ibox 1.00, 2.08, 8.71, 4.94, "",
|
69
|
+
I18n.t("danfe.ide.document", nNF: @xml["ide/nNF"], serie: @xml["ide/serie"]),
|
70
|
+
{ size: 8, align: :center, valign: :center, border: 0, style: :bold }
|
33
71
|
end
|
34
72
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
73
|
+
def access_key_box
|
74
|
+
@pdf.ibox 2.20, 10.02, 10.79, 2.54
|
75
|
+
@pdf.ibarcode 1.50, 8.00, 10.9010, 4.44, @xml["chNFe"]
|
76
|
+
@pdf.ibox 0.85, 10.02, 10.79, 4.74, I18n.t("danfe.chNFe"), @xml["chNFe"].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, "\\1 "),
|
77
|
+
{ style: :bold, align: :center }
|
78
|
+
end
|
79
|
+
|
80
|
+
def sefaz_box
|
81
|
+
@pdf.ibox 0.85, 10.02, 10.79, 5.60 , "", I18n.t("danfe.others.sefaz"),
|
82
|
+
{ align: :center, size: 8 }
|
83
|
+
end
|
84
|
+
|
85
|
+
def operationkind_box
|
86
|
+
@pdf.lbox 0.85, 10.54, 0.25, 6.46, @xml, "ide/natOp"
|
87
|
+
end
|
88
|
+
|
89
|
+
def protocol_box
|
90
|
+
@pdf.ibox 0.85, 10.02, 10.79, 6.46, I18n.t("danfe.infProt"), @xml["infProt/nProt"] + " " + Helper.format_date(@xml["infProt/dhRecbto"]), { align: :center }
|
91
|
+
end
|
92
|
+
|
93
|
+
def ie_box
|
94
|
+
ie(0.25, "IE")
|
95
|
+
end
|
96
|
+
|
97
|
+
def ie_st_box
|
98
|
+
ie(7.11, "IE_ST")
|
99
|
+
end
|
100
|
+
|
101
|
+
def ie(x, field)
|
102
|
+
@pdf.ibox 0.85, 6.86, x, 7.31, I18n.t("danfe.emit.#{field}"), Ie.format(@xml["emit/#{field}"], @xml["enderEmit/UF"])
|
103
|
+
end
|
104
|
+
|
105
|
+
def cnpj_box
|
106
|
+
@pdf.ibox 0.85, 6.84, 13.97, 7.31, I18n.t("danfe.emit.CNPJ"), Cnpj.format(@xml["emit/CNPJ"])
|
107
|
+
end
|
44
108
|
end
|
45
109
|
end
|
data/lib/br_danfe/helper.rb
CHANGED
data/lib/br_danfe/ie.rb
CHANGED
@@ -4,65 +4,17 @@ module BrDanfe
|
|
4
4
|
uf = uf.upcase
|
5
5
|
|
6
6
|
if ["AL", "AP", "MA", "ES", "MS", "PI", "TO"].include?(uf)
|
7
|
-
|
7
|
+
formatted = ie
|
8
|
+
elsif ["CE", "PB", "RR", "SE"].include?(uf)
|
9
|
+
formatted = ie.sub(/(\d{8})(\d{1})/, "\\1-\\2")
|
10
|
+
elsif ["AM", "GO"].include?(uf)
|
11
|
+
formatted = ie.sub(/(\d{2})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3-\\4")
|
12
|
+
else
|
13
|
+
masks = IeMasks.new
|
14
|
+
formatted = masks.send("apply_mask_for_#{uf.downcase}", ie)
|
8
15
|
end
|
9
16
|
|
10
|
-
|
11
|
-
formated_ie = ie.sub(/(\d{8})(\d{1})/, "\\1-\\2")
|
12
|
-
end
|
13
|
-
|
14
|
-
if ["AM", "GO"].include?(uf)
|
15
|
-
formated_ie = ie.sub(/(\d{2})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3-\\4")
|
16
|
-
end
|
17
|
-
|
18
|
-
case uf
|
19
|
-
when "SP"
|
20
|
-
if ie.length == 12
|
21
|
-
formated_ie = ie.sub(/(\d{3})(\d{3})(\d{3})(\d{3})/, "\\1.\\2.\\3.\\4")
|
22
|
-
else
|
23
|
-
formated_ie = ie.sub(/(\w{1})(\d{8})(\d{1})(\d{3})/, "\\1-\\2.\\3/\\4")
|
24
|
-
end
|
25
|
-
when "BA"
|
26
|
-
if ie.length == 8
|
27
|
-
formated_ie = ie.sub(/(\d{6})(\d{2})/, "\\1-\\2")
|
28
|
-
else
|
29
|
-
formated_ie = ie.sub(/(\d{7})(\d{2})/, "\\1-\\2")
|
30
|
-
end
|
31
|
-
when "RO"
|
32
|
-
if ie.length == 9
|
33
|
-
formated_ie = ie.sub(/(\d{3})(\d{5})(\d{1})/, "\\1.\\2-\\3")
|
34
|
-
else
|
35
|
-
formated_ie = ie.sub(/(\d{13})(\d{1})/, "\\1-\\2")
|
36
|
-
end
|
37
|
-
when "RN"
|
38
|
-
if ie.length == 9
|
39
|
-
formated_ie = ie.sub(/(\d{2})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3-\\4")
|
40
|
-
else
|
41
|
-
formated_ie = ie.sub(/(\d{2})(\d{1})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3.\\4-\\5")
|
42
|
-
end
|
43
|
-
when "AC"
|
44
|
-
formated_ie = ie.sub(/(\d{2})(\d{3})(\d{3})(\d{3})(\d{2})/, "\\1.\\2.\\3/\\4-\\5")
|
45
|
-
when "DF"
|
46
|
-
formated_ie = ie.sub(/(\d{11})(\d{2})/, "\\1-\\2")
|
47
|
-
when "MG"
|
48
|
-
formated_ie = ie.sub(/(\d{3})(\d{3})(\d{3})(\d{4})/, "\\1.\\2.\\3/\\4")
|
49
|
-
when "MT"
|
50
|
-
formated_ie = ie.sub(/(\d{10})(\d{1})/, "\\1-\\2")
|
51
|
-
when "RJ"
|
52
|
-
formated_ie = ie.sub(/(\d{2})(\d{3})(\d{2})(\d{1})/, "\\1.\\2.\\3-\\4")
|
53
|
-
when "PR"
|
54
|
-
formated_ie = ie.sub(/(\d{8})(\d{2})/, "\\1-\\2")
|
55
|
-
when "RS"
|
56
|
-
formated_ie = ie.sub(/(\d{3})(\d{7})/, "\\1/\\2")
|
57
|
-
when "PE"
|
58
|
-
formated_ie = ie.sub(/(\d{7})(\d{2})/, "\\1-\\2")
|
59
|
-
when "PA"
|
60
|
-
formated_ie = ie.sub(/(\d{2})(\d{6})(\d{1})/, "\\1-\\2-\\3")
|
61
|
-
when "SC"
|
62
|
-
formated_ie = ie.sub(/(\d{3})(\d{3})(\d{3})/, "\\1.\\2.\\3")
|
63
|
-
end
|
64
|
-
|
65
|
-
formated_ie
|
17
|
+
formatted
|
66
18
|
end
|
67
19
|
end
|
68
20
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
class IeMasks
|
3
|
+
def apply_mask_for_sp(ie)
|
4
|
+
if ie.length == 12
|
5
|
+
ie.sub(/(\d{3})(\d{3})(\d{3})(\d{3})/, "\\1.\\2.\\3.\\4")
|
6
|
+
else
|
7
|
+
ie.sub(/(\w{1})(\d{8})(\d{1})(\d{3})/, "\\1-\\2.\\3/\\4")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def apply_mask_for_ba(ie)
|
12
|
+
if ie.length == 8
|
13
|
+
ie.sub(/(\d{6})(\d{2})/, "\\1-\\2")
|
14
|
+
else
|
15
|
+
ie.sub(/(\d{7})(\d{2})/, "\\1-\\2")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def apply_mask_for_ro(ie)
|
20
|
+
if ie.length == 9
|
21
|
+
ie.sub(/(\d{3})(\d{5})(\d{1})/, "\\1.\\2-\\3")
|
22
|
+
else
|
23
|
+
ie.sub(/(\d{13})(\d{1})/, "\\1-\\2")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def apply_mask_for_rn(ie)
|
28
|
+
if ie.length == 9
|
29
|
+
ie.sub(/(\d{2})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3-\\4")
|
30
|
+
else
|
31
|
+
ie.sub(/(\d{2})(\d{1})(\d{3})(\d{3})(\d{1})/, "\\1.\\2.\\3.\\4-\\5")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def apply_mask_for_ac(ie)
|
36
|
+
ie.sub(/(\d{2})(\d{3})(\d{3})(\d{3})(\d{2})/, "\\1.\\2.\\3/\\4-\\5")
|
37
|
+
end
|
38
|
+
|
39
|
+
def apply_mask_for_df(ie)
|
40
|
+
ie.sub(/(\d{11})(\d{2})/, "\\1-\\2")
|
41
|
+
end
|
42
|
+
|
43
|
+
def apply_mask_for_mg(ie)
|
44
|
+
ie.sub(/(\d{3})(\d{3})(\d{3})(\d{4})/, "\\1.\\2.\\3/\\4")
|
45
|
+
end
|
46
|
+
|
47
|
+
def apply_mask_for_mt(ie)
|
48
|
+
ie.sub(/(\d{10})(\d{1})/, "\\1-\\2")
|
49
|
+
end
|
50
|
+
|
51
|
+
def apply_mask_for_rj(ie)
|
52
|
+
ie.sub(/(\d{2})(\d{3})(\d{2})(\d{1})/, "\\1.\\2.\\3-\\4")
|
53
|
+
end
|
54
|
+
|
55
|
+
def apply_mask_for_pr(ie)
|
56
|
+
ie.sub(/(\d{8})(\d{2})/, "\\1-\\2")
|
57
|
+
end
|
58
|
+
|
59
|
+
def apply_mask_for_rs(ie)
|
60
|
+
ie.sub(/(\d{3})(\d{7})/, "\\1/\\2")
|
61
|
+
end
|
62
|
+
|
63
|
+
def apply_mask_for_pe(ie)
|
64
|
+
ie.sub(/(\d{7})(\d{2})/, "\\1-\\2")
|
65
|
+
end
|
66
|
+
|
67
|
+
def apply_mask_for_pa(ie)
|
68
|
+
ie.sub(/(\d{2})(\d{6})(\d{1})/, "\\1-\\2-\\3")
|
69
|
+
end
|
70
|
+
|
71
|
+
def apply_mask_for_sc(ie)
|
72
|
+
ie.sub(/(\d{3})(\d{3})(\d{3})/, "\\1.\\2.\\3")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/br_danfe/infadic.rb
CHANGED
@@ -1,53 +1,73 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Infadic
|
3
|
-
def
|
4
|
-
pdf
|
3
|
+
def initialize(pdf, xml)
|
4
|
+
@pdf = pdf
|
5
|
+
@xml = xml
|
6
|
+
end
|
7
|
+
|
8
|
+
def render(nVol)
|
9
|
+
@pdf.ititle 0.42, 10.00, 0.25, 25.91, "infAdic.title"
|
5
10
|
|
6
11
|
if nVol > 1
|
7
|
-
|
12
|
+
render_extra_volumes
|
8
13
|
else
|
9
|
-
pdf.ibox 3.07, 12.93, 0.25, 26.33, I18n.t("danfe.infAdic.infCpl"), xml["infAdic/infCpl"], {size: 6, valign: :top}
|
14
|
+
@pdf.ibox 3.07, 12.93, 0.25, 26.33, I18n.t("danfe.infAdic.infCpl"), @xml["infAdic/infCpl"], { size: 6, valign: :top }
|
10
15
|
end
|
11
16
|
|
12
|
-
pdf.ibox 3.07, 7.62, 13.17, 26.33, I18n.t("danfe.infAdic.reserved")
|
17
|
+
@pdf.ibox 3.07, 7.62, 13.17, 26.33, I18n.t("danfe.infAdic.reserved")
|
13
18
|
end
|
14
19
|
|
15
20
|
private
|
16
|
-
def
|
17
|
-
pdf.ibox 3.07, 12.93, 0.25, 26.33, I18n.t("danfe.infAdic.infCpl"), "", {size: 8, valign: :top}
|
18
|
-
pdf.ibox 3.07, 12.93, 0.25, 26.60, "", I18n.t("danfe.infAdic.vol.title"), {size: 5, valign: :top, border: 0}
|
21
|
+
def render_extra_volumes
|
22
|
+
@pdf.ibox 3.07, 12.93, 0.25, 26.33, I18n.t("danfe.infAdic.infCpl"), "", { size: 8, valign: :top }
|
23
|
+
@pdf.ibox 3.07, 12.93, 0.25, 26.60, "", I18n.t("danfe.infAdic.vol.title"), { size: 5, valign: :top, border: 0 }
|
19
24
|
|
20
25
|
volumes = 0
|
21
26
|
y = 26.67
|
22
|
-
xml.collect("xmlns", "vol") do |det|
|
27
|
+
@xml.collect("xmlns", "vol") do |det|
|
23
28
|
volumes += 1
|
24
29
|
if volumes > 1
|
25
|
-
|
30
|
+
render_extra_volume(det, y + 0.10)
|
26
31
|
y += 0.15
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
pdf.ibox 2.07, 12.93, 0.25, y + 0.30, "", I18n.t("danfe.infAdic.others"), { size: 6, valign: :top, border: 0 }
|
31
|
-
pdf.ibox 2.07, 12.93, 0.25, y + 0.50, "", xml["infAdic/infCpl"], { size: 5, valign: :top, border: 0 }
|
32
|
-
end
|
33
|
-
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
pdf.ibox 0.35,
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
@pdf.ibox 2.07, 12.93, 0.25, y + 0.30, "", I18n.t("danfe.infAdic.others"), { size: 6, valign: :top, border: 0 }
|
36
|
+
@pdf.ibox 2.07, 12.93, 0.25, y + 0.50, "", @xml["infAdic/infCpl"], { size: 5, valign: :top, border: 0 }
|
37
|
+
end
|
38
|
+
|
39
|
+
def render_extra_volume(det, y)
|
40
|
+
render_field "qVol", det, 0.70, 0.25, 0.70, 0.90, y, :text
|
41
|
+
render_field "esp", det, 0.50, 1.35, 3.00, 1.75, y, :text
|
42
|
+
render_field "marca", det, 0.70, 4.15, 2.00, 4.75, y, :text
|
43
|
+
render_field "nVol", det, 1.00, 6.10, 1.00, 6.70, y, :text
|
44
|
+
render_field "pesoB", det, 1.30, 7.00, 1.30, 7.00, y, :numeric
|
45
|
+
render_field "pesoL", det, 0.90, 8.50, 1.50, 8.50, y, :numeric
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_field(field, det, w1, x1, w2, x2, y, kind)
|
49
|
+
label = I18n.t("danfe.infAdic.vol.#{field}")
|
50
|
+
value = det.css(field).text
|
51
|
+
|
52
|
+
@pdf.ibox 0.35, w1, x1, y, "", label, style_normal
|
53
|
+
|
54
|
+
if kind == :numeric
|
55
|
+
@pdf.inumeric 0.35, w2, x2, y, "", value, style_decimal
|
56
|
+
else
|
57
|
+
@pdf.ibox 0.35, w2, x2, y, "", value, style_italic
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def style_normal
|
62
|
+
{ size: 4, border: 0 }
|
63
|
+
end
|
64
|
+
|
65
|
+
def style_italic
|
66
|
+
style_normal.merge({ style: :italic })
|
67
|
+
end
|
68
|
+
|
69
|
+
def style_decimal
|
70
|
+
style_italic.merge({ decimals: 3 })
|
51
71
|
end
|
52
72
|
end
|
53
73
|
end
|
data/lib/br_danfe/version.rb
CHANGED
data/lib/br_danfe/vol.rb
CHANGED
@@ -1,23 +1,29 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Vol
|
3
|
-
def
|
3
|
+
def initialize(pdf, xml)
|
4
|
+
@pdf = pdf
|
5
|
+
@xml = xml
|
6
|
+
end
|
7
|
+
|
8
|
+
def render
|
4
9
|
nVol = 0
|
5
10
|
|
6
|
-
xml.collect("xmlns", "vol") do |det|
|
11
|
+
@xml.collect("xmlns", "vol") do |det|
|
7
12
|
nVol += 1
|
8
|
-
if nVol < 2
|
9
|
-
pdf.ibox 0.85, 2.92, 0.25, 16.60, I18n.t("danfe.vol.qVol"), det.css("qVol").text
|
10
|
-
pdf.ibox 0.85, 3.05, 3.17, 16.60, I18n.t("danfe.vol.esp"), det.css("esp").text
|
11
|
-
pdf.ibox 0.85, 3.05, 6.22, 16.60, I18n.t("danfe.vol.marca"), det.css("marca").text
|
12
|
-
pdf.ibox 0.85, 4.83, 9.27, 16.60, I18n.t("danfe.vol.nVol")
|
13
|
-
pdf.inumeric 0.85, 3.43, 14.10, 16.60, "vol.pesoB", det.css("pesoB").text, {decimals: 3}
|
14
|
-
pdf.inumeric 0.85, 3.30, 17.53, 16.60, "vol.pesoL", det.css("pesoL").text, {decimals: 3}
|
15
|
-
else
|
16
|
-
break
|
17
|
-
end
|
13
|
+
render_vol(det) if nVol < 2
|
18
14
|
end
|
19
15
|
|
20
16
|
nVol
|
21
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def render_vol(det)
|
21
|
+
@pdf.ibox 0.85, 2.92, 0.25, 16.60, I18n.t("danfe.vol.qVol"), det.css("qVol").text
|
22
|
+
@pdf.ibox 0.85, 3.05, 3.17, 16.60, I18n.t("danfe.vol.esp"), det.css("esp").text
|
23
|
+
@pdf.ibox 0.85, 3.05, 6.22, 16.60, I18n.t("danfe.vol.marca"), det.css("marca").text
|
24
|
+
@pdf.ibox 0.85, 4.83, 9.27, 16.60, I18n.t("danfe.vol.nVol")
|
25
|
+
@pdf.inumeric 0.85, 3.43, 14.10, 16.60, "vol.pesoB", det.css("pesoB").text, { decimals: 3 }
|
26
|
+
@pdf.inumeric 0.85, 3.30, 17.53, 16.60, "vol.pesoL", det.css("pesoL").text, { decimals: 3 }
|
27
|
+
end
|
22
28
|
end
|
23
29
|
end
|