br_danfe 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/br_danfe.gemspec +3 -1
- data/circle.yml +5 -0
- data/config/locales/pt-BR.yml +4 -3
- data/lib/br_danfe/danfe.rb +2 -2
- data/lib/br_danfe/dest.rb +12 -22
- data/lib/br_danfe/det_header.rb +1 -2
- data/lib/br_danfe/document.rb +34 -9
- data/lib/br_danfe/emit.rb +8 -18
- data/lib/br_danfe/issqn.rb +3 -3
- data/lib/br_danfe/ticket.rb +10 -5
- data/lib/br_danfe/transp.rb +17 -4
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe/xprod.rb +4 -4
- data/lib/br_danfe.rb +1 -0
- data/spec/features/br_danfe_spec.rb +2 -19
- data/spec/fixtures/lib/dest#render-with_cnpj.pdf +201 -0
- data/spec/fixtures/lib/dest#render-with_cpf.pdf +201 -0
- data/spec/fixtures/lib/dest#render-with_ie.pdf +208 -0
- data/spec/fixtures/lib/det_body#render-csosn.pdf +855 -0
- data/spec/fixtures/lib/det_body#render-cst.pdf +512 -0
- data/spec/fixtures/lib/det_body#render-fci.pdf +260 -0
- data/spec/fixtures/lib/det_body#render-icms_st.pdf +267 -0
- data/spec/fixtures/lib/det_header#render.pdf +207 -0
- data/spec/fixtures/lib/document#lcnpj-blank.pdf +74 -0
- data/spec/fixtures/lib/document#lcnpj-invalid.pdf +74 -0
- data/spec/fixtures/lib/document#lcnpj-valid.pdf +81 -0
- data/spec/fixtures/lib/document#lie-blank.pdf +74 -0
- data/spec/fixtures/lib/document#lie-invalid.pdf +74 -0
- data/spec/fixtures/lib/document#lie-valid.pdf +81 -0
- data/spec/fixtures/lib/dup#render.pdf +216 -0
- data/spec/fixtures/lib/emit#render.pdf +143 -0
- data/spec/fixtures/lib/emit_header#render-with_logo.pdf +712 -0
- data/spec/fixtures/lib/emit_header#render-without_logo.pdf +650 -0
- data/spec/fixtures/lib/icmstot#render.pdf +255 -0
- data/spec/fixtures/lib/infadic#render-extra_volume.pdf +295 -0
- data/spec/fixtures/lib/infadic#render.pdf +104 -0
- data/spec/fixtures/lib/issqn#render.pdf +143 -0
- data/spec/fixtures/lib/ticket#render.pdf +113 -0
- data/spec/fixtures/lib/transp#render.pdf +239 -0
- data/spec/fixtures/lib/vol#render.pdf +152 -0
- data/spec/fixtures/{v2.00/nfe_with_logo.xml.logo.png → logo.png} +0 -0
- data/spec/fixtures/v2.00/nfe_simples_nacional.xml.fixture.pdf +14 -14
- data/spec/fixtures/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +29 -43
- data/spec/fixtures/v2.00/nfe_with_fci.xml.fixture.pdf +12 -12
- data/spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf +16 -16
- data/spec/fixtures/v2.00/nfe_with_ns.xml.fixture.pdf +29 -43
- data/spec/fixtures/v2.00/nfe_without_ns.xml.fixture.pdf +13 -27
- data/spec/fixtures/v3.10/nfe_simples_nacional.xml.fixture.pdf +23 -23
- data/spec/lib/dest_spec.rb +69 -0
- data/spec/lib/det_body_spec.rb +299 -0
- data/spec/lib/det_header_spec.rb +26 -0
- data/spec/lib/document_spec.rb +172 -0
- data/spec/lib/dup_spec.rb +52 -0
- data/spec/lib/emit_header_spec.rb +76 -0
- data/spec/lib/emit_spec.rb +54 -0
- data/spec/lib/icmstot_spec.rb +48 -0
- data/spec/lib/infadic_spec.rb +81 -0
- data/spec/lib/issqn_spec.rb +45 -0
- data/spec/lib/ticket_spec.rb +42 -0
- data/spec/lib/transp_spec.rb +51 -0
- data/spec/lib/vol_spec.rb +65 -0
- data/spec/lib/xprod_spec.rb +2 -2
- metadata +96 -12
- data/spec/fixtures/v2.00/nfe_with_cpf.xml +0 -1
- data/spec/fixtures/v2.00/nfe_with_cpf.xml.fixture.pdf +0 -1871
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 495bde96f88c5762bebf455e55b41d9ea1bda6c6
|
4
|
+
data.tar.gz: 1117b6d8838a67787ff32d1c3da4a903d76fbebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a8868c455f39fe42752c198453e3357f34a39d5d6b9572212300e631ee90e2cbec2cefab159e1dd19129df9ae28404a3032fbab41fc435246e4aedcd02219d3
|
7
|
+
data.tar.gz: f5db6c1c3b5a0146bf1b33b0b21e4cd0a7067ca8eaed888247731ae8d483e8d8730ef84fe8599126564f64f4732a471fb6bbb780282feaca58f114b45ec70a36
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This gem generates PDF files for Brazilian DANFE (_Documento Auxiliar da Nota Fi
|
|
6
6
|
|
7
7
|
[See an example here.](https://github.com/asseinfo/br_danfe/blob/master/spec/fixtures/v2.00/nfe_with_logo.xml.fixture.pdf?raw=true)
|
8
8
|
|
9
|
-
This gem requires `ruby >= 1.9.
|
9
|
+
This gem requires `ruby >= 1.9.3`.
|
10
10
|
|
11
11
|
## Supported NF-e versions
|
12
12
|
|
@@ -132,6 +132,7 @@ City | Sumaré - SP
|
|
132
132
|
Phone | (19) 2345-6789
|
133
133
|
CNPJ | 71.058.884/0001-83
|
134
134
|
IE | 671.008.375.110
|
135
|
+
IE ST | 611.724.092.039
|
135
136
|
|
136
137
|
Field | Content
|
137
138
|
------------ | -------------------------
|
data/br_danfe.gemspec
CHANGED
@@ -15,9 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
spec.require_paths = ["lib"]
|
18
|
+
spec.required_ruby_version = ">= 2.0"
|
18
19
|
|
19
20
|
spec.add_dependency "nokogiri"
|
20
|
-
spec.add_dependency "prawn", "1.
|
21
|
+
spec.add_dependency "prawn", "1.3.0"
|
22
|
+
spec.add_dependency "prawn-table", "0.2.1"
|
21
23
|
spec.add_dependency "barby", "0.5.1"
|
22
24
|
spec.add_dependency "i18n"
|
23
25
|
spec.add_dependency "br_documents", ">= 0.0.8"
|
data/circle.yml
ADDED
data/config/locales/pt-BR.yml
CHANGED
@@ -102,9 +102,10 @@ pt-BR:
|
|
102
102
|
issqn:
|
103
103
|
title: "CÁLCULO DO ISSQN"
|
104
104
|
total:
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
ISSQNtot:
|
106
|
+
vServ: "VALOR TOTAL DOS SERVIÇOS"
|
107
|
+
vBC: "BASE DE CÁLCULO DO ISSQN"
|
108
|
+
vISS: "VALOR DO ISSQN"
|
108
109
|
infAdic:
|
109
110
|
title: "DADOS ADICIONAIS"
|
110
111
|
infCpl: "INFORMAÇÕES COMPLEMENTARES"
|
data/lib/br_danfe/danfe.rb
CHANGED
@@ -57,7 +57,7 @@ module BrDanfe
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def repeat_on_each_page
|
60
|
-
Ticket.
|
60
|
+
Ticket.new(@pdf, @xml).render
|
61
61
|
EmitHeader.new(@pdf, @xml, @options.logo_path).render
|
62
62
|
Emit.new(@pdf, @xml).render
|
63
63
|
Dest.new(@pdf, @xml).render
|
@@ -65,7 +65,7 @@ module BrDanfe
|
|
65
65
|
Icmstot.new(@pdf, @xml).render
|
66
66
|
Transp.new(@pdf, @xml).render
|
67
67
|
nVol = Vol.new(@pdf, @xml).render
|
68
|
-
DetHeader.new(@pdf
|
68
|
+
DetHeader.new(@pdf).render
|
69
69
|
Issqn.new(@pdf, @xml).render
|
70
70
|
Infadic.new(@pdf, @xml).render(nVol)
|
71
71
|
end
|
data/lib/br_danfe/dest.rb
CHANGED
@@ -30,26 +30,21 @@ module BrDanfe
|
|
30
30
|
|
31
31
|
def render_cnpj_cpf
|
32
32
|
if @xml["dest/CNPJ"] == ""
|
33
|
-
@pdf.
|
33
|
+
@pdf.i18n_lbox LINE_HEIGHT, 4.87, 12.57, @l1, "dest.CPF", cpf
|
34
34
|
else
|
35
|
-
@pdf.
|
35
|
+
@pdf.lcnpj LINE_HEIGHT, 4.87, 12.57, @l1, @xml, "dest/CNPJ"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def cnpj
|
40
|
-
cnpj = BrDocuments::CnpjCpf::Cnpj.new(@xml["dest/CNPJ"])
|
41
|
-
cnpj.formatted
|
42
|
-
end
|
43
|
-
|
44
39
|
def cpf
|
45
40
|
cpf = BrDocuments::CnpjCpf::Cpf.new(@xml["dest/CPF"])
|
46
41
|
cpf.formatted
|
47
42
|
end
|
48
43
|
|
49
44
|
def render_line2
|
50
|
-
@pdf.
|
45
|
+
@pdf.i18n_lbox LINE_HEIGHT, 10.16, 0.25, @l2, "enderDest.xLgr", street
|
51
46
|
@pdf.lbox LINE_HEIGHT, 4.83, 10.41, @l2, @xml, "enderDest/xBairro"
|
52
|
-
@pdf.
|
47
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.20, 15.24, @l2, "enderDest.CEP", cep
|
53
48
|
end
|
54
49
|
|
55
50
|
def street
|
@@ -62,33 +57,28 @@ module BrDanfe
|
|
62
57
|
|
63
58
|
def render_line3
|
64
59
|
@pdf.lbox LINE_HEIGHT, 7.11, 0.25, @l3, @xml, "enderDest/xMun"
|
65
|
-
@pdf.
|
60
|
+
@pdf.i18n_lbox LINE_HEIGHT, 4.06, 7.36, @l3, "enderDest.fone", phone
|
66
61
|
@pdf.lbox LINE_HEIGHT, 1.14, 11.42, @l3, @xml, "enderDest/UF"
|
67
|
-
@pdf.
|
62
|
+
@pdf.lie LINE_HEIGHT, 4.88, 12.56, @l3, @xml, "enderDest/UF", "dest/IE"
|
68
63
|
end
|
69
64
|
|
70
65
|
def render_dates_block
|
71
66
|
@pdf.ldate LINE_HEIGHT, 2.92, 17.90, @l1, "ide.dEmi", @xml["ide/dEmi"], { align: :right }
|
72
67
|
|
73
68
|
if @xml.version_310?
|
74
|
-
dSaiEnt =
|
75
|
-
hSaiEnt =
|
69
|
+
dSaiEnt = "ide/dhSaiEnt"
|
70
|
+
hSaiEnt = "ide/dhSaiEnt"
|
76
71
|
else
|
77
|
-
dSaiEnt =
|
78
|
-
hSaiEnt =
|
72
|
+
dSaiEnt = "ide/dSaiEnt"
|
73
|
+
hSaiEnt = "ide/hSaiEnt"
|
79
74
|
end
|
80
75
|
|
81
|
-
@pdf.ldate LINE_HEIGHT, 2.92, 17.90, @l2, "ide.dSaiEnt", dSaiEnt, { align: :right }
|
82
|
-
@pdf.ltime LINE_HEIGHT, 2.92, 17.90, @l3, "ide.hSaiEnt", hSaiEnt, { align: :right }
|
76
|
+
@pdf.ldate LINE_HEIGHT, 2.92, 17.90, @l2, "ide.dSaiEnt", @xml[dSaiEnt], { align: :right }
|
77
|
+
@pdf.ltime LINE_HEIGHT, 2.92, 17.90, @l3, "ide.hSaiEnt", @xml[hSaiEnt], { align: :right }
|
83
78
|
end
|
84
79
|
|
85
80
|
def phone
|
86
81
|
Phone.format(@xml["enderDest/fone"])
|
87
82
|
end
|
88
|
-
|
89
|
-
def ie
|
90
|
-
ie = BrDocuments::IE::Factory.create(@xml["enderDest/UF"], @xml["dest/IE"])
|
91
|
-
ie.formatted
|
92
|
-
end
|
93
83
|
end
|
94
84
|
end
|
data/lib/br_danfe/det_header.rb
CHANGED
data/lib/br_danfe/document.rb
CHANGED
@@ -33,7 +33,7 @@ module BrDanfe
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def lbox(h, w, x, y, xml, xpath, options = {})
|
36
|
-
i18n = xpath.
|
36
|
+
i18n = xpath.gsub("/", ".");
|
37
37
|
label = I18n.t("danfe.#{i18n}")
|
38
38
|
data = xml[xpath]
|
39
39
|
|
@@ -50,8 +50,33 @@ module BrDanfe
|
|
50
50
|
i18n_lbox(h, w, x, y, i18n, data, options)
|
51
51
|
end
|
52
52
|
|
53
|
+
def lcnpj(h, w, x, y, xml, xpath, options = {})
|
54
|
+
i18n = xpath.gsub("/", ".");
|
55
|
+
|
56
|
+
cnpj = BrDocuments::CnpjCpf::Cnpj.new(xml[xpath])
|
57
|
+
if cnpj.valid?
|
58
|
+
data = cnpj.formatted
|
59
|
+
else
|
60
|
+
data = ""
|
61
|
+
end
|
62
|
+
|
63
|
+
i18n_lbox(h, w, x, y, i18n, data, options)
|
64
|
+
end
|
65
|
+
|
66
|
+
def lie(h, w, x, y, xml, xpath_uf, xpath_ie, options = {})
|
67
|
+
i18n = xpath_ie.gsub("/", ".");
|
68
|
+
|
69
|
+
data = ""
|
70
|
+
if xml[xpath_uf].present? #BrDocument bug - review this in the future
|
71
|
+
ie = BrDocuments::IE::Factory.create(xml[xpath_uf], xml[xpath_ie])
|
72
|
+
data = ie.formatted if ie.valid?
|
73
|
+
end
|
74
|
+
|
75
|
+
i18n_lbox(h, w, x, y, i18n, data, options)
|
76
|
+
end
|
77
|
+
|
53
78
|
def lnumeric(h, w, x, y, xml, xpath, options = {})
|
54
|
-
i18n = xpath.
|
79
|
+
i18n = xpath.gsub("/", ".");
|
55
80
|
data = xml[xpath]
|
56
81
|
|
57
82
|
inumeric(h, w, x, y, i18n, data, options)
|
@@ -64,6 +89,13 @@ module BrDanfe
|
|
64
89
|
numeric [x.cm, Helper.invert(y.cm)], w.cm, h.cm, label, data, options
|
65
90
|
end
|
66
91
|
|
92
|
+
def i18n_lbox(h, w, x, y, i18n = "", info = "", options = {})
|
93
|
+
label = ""
|
94
|
+
label = I18n.t("danfe.#{i18n}") if i18n != ""
|
95
|
+
|
96
|
+
ibox h, w, x, y, label, info, options
|
97
|
+
end
|
98
|
+
|
67
99
|
private
|
68
100
|
def numeric(at, w, h, title = "", info = "", options = {})
|
69
101
|
options = {
|
@@ -74,13 +106,6 @@ module BrDanfe
|
|
74
106
|
box at, w, h, title, info, options.merge({align: :right})
|
75
107
|
end
|
76
108
|
|
77
|
-
def i18n_lbox(h, w, x, y, i18n = "", info = "", options = {})
|
78
|
-
label = ""
|
79
|
-
label = I18n.t("danfe.#{i18n}") if i18n != ""
|
80
|
-
|
81
|
-
ibox h, w, x, y, label, info, options
|
82
|
-
end
|
83
|
-
|
84
109
|
def box(at, w, h, title = "", info = "", options = {})
|
85
110
|
options = {
|
86
111
|
align: :left,
|
data/lib/br_danfe/emit.rb
CHANGED
@@ -1,31 +1,21 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Emit
|
3
3
|
Y = 6.46
|
4
|
-
L1 = Y
|
5
|
-
L2 = Y + LINE_HEIGHT
|
6
4
|
|
7
5
|
def initialize(pdf, xml)
|
8
6
|
@pdf = pdf
|
9
7
|
@xml = xml
|
10
|
-
end
|
11
8
|
|
12
|
-
|
13
|
-
@
|
14
|
-
@pdf.ibox LINE_HEIGHT, 10.02, 10.79, L1, I18n.t("danfe.infProt"), @xml["infProt/nProt"] + " " + Helper.format_datetime(@xml["infProt/dhRecbto"]), { align: :center }
|
15
|
-
ie(0.25, "IE")
|
16
|
-
ie(7.11, "IE_ST")
|
17
|
-
cnpj_box
|
9
|
+
@l1 = Y
|
10
|
+
@l2 = Y + LINE_HEIGHT
|
18
11
|
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@pdf.
|
24
|
-
|
25
|
-
|
26
|
-
def cnpj_box
|
27
|
-
cnpj = BrDocuments::CnpjCpf::Cnpj.new(@xml["emit/CNPJ"])
|
28
|
-
@pdf.ibox LINE_HEIGHT, 6.84, 13.97, L2, I18n.t("danfe.emit.CNPJ"), cnpj.formatted
|
13
|
+
def render
|
14
|
+
@pdf.lbox LINE_HEIGHT, 10.54, 0.25, @l1, @xml, "ide/natOp"
|
15
|
+
@pdf.ibox LINE_HEIGHT, 10.02, 10.79, @l1, I18n.t("danfe.infProt"), @xml["infProt/nProt"] + " " + Helper.format_datetime(@xml["infProt/dhRecbto"]), { align: :center }
|
16
|
+
@pdf.lie LINE_HEIGHT, 6.86, 0.25, @l2, @xml, "enderEmit/UF", "emit/IE"
|
17
|
+
@pdf.lie LINE_HEIGHT, 6.86, 7.11, @l2, @xml, "enderEmit/UF", "emit/IE_ST"
|
18
|
+
@pdf.lcnpj LINE_HEIGHT, 6.84, 13.97, @l2, @xml, "emit/CNPJ"
|
29
19
|
end
|
30
20
|
end
|
31
21
|
end
|
data/lib/br_danfe/issqn.rb
CHANGED
@@ -14,9 +14,9 @@ module BrDanfe
|
|
14
14
|
@pdf.ititle 0.42, 10.00, 0.25, @ltitle, "issqn.title"
|
15
15
|
|
16
16
|
@pdf.lbox LINE_HEIGHT, 5.14, 0.25, @l1, @xml, "emit/IM"
|
17
|
-
@pdf.
|
18
|
-
@pdf.
|
19
|
-
@pdf.
|
17
|
+
@pdf.lnumeric LINE_HEIGHT, 5.14, 5.39, @l1, @xml, "total/ISSQNtot/vServ"
|
18
|
+
@pdf.lnumeric LINE_HEIGHT, 5.14, 10.53, @l1, @xml, "total/ISSQNtot/vBC"
|
19
|
+
@pdf.lnumeric LINE_HEIGHT, 5.14, 15.67, @l1, @xml, "total/ISSQNtot/vISS"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/br_danfe/ticket.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Ticket
|
3
|
-
def
|
4
|
-
pdf
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def initialize(pdf, xml)
|
4
|
+
@pdf = pdf
|
5
|
+
@xml = xml
|
6
|
+
end
|
7
|
+
|
8
|
+
def render
|
9
|
+
@pdf.ibox 0.85, 16.10, 0.25, 0.42, I18n.t("danfe.ticket.xNome", xNome: @xml["emit/xNome"])
|
10
|
+
@pdf.ibox 0.85, 4.10, 0.25, 1.27, I18n.t("danfe.ticket.received_at")
|
11
|
+
@pdf.ibox 0.85, 12.00, 4.35, 1.27, I18n.t("danfe.ticket.receiver")
|
12
|
+
@pdf.ibox 1.70, 4.50, 16.35, 0.42, "", I18n.t("danfe.ticket.document", nNF: @xml["ide/nNF"], serie: @xml["ide/serie"]), {align: :center, valign: :center}
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
data/lib/br_danfe/transp.rb
CHANGED
@@ -15,15 +15,28 @@ module BrDanfe
|
|
15
15
|
@pdf.ititle 0.42, 10.00, 0.25, @ltitle, "transporta.title"
|
16
16
|
|
17
17
|
@pdf.lbox LINE_HEIGHT, 9.02, 0.25, @l1, @xml, "transporta/xNome"
|
18
|
-
@pdf.
|
18
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.79, 9.27, @l1, "transp.modFrete.title", mod_frete
|
19
19
|
@pdf.lbox LINE_HEIGHT, 1.78, 12.06, @l1, @xml, "veicTransp/RNTC"
|
20
|
-
@pdf.
|
20
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.29, 13.84, @l1, "veicTransp.placa", plate
|
21
21
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l1, @xml, "veicTransp/UF"
|
22
|
-
@pdf.
|
22
|
+
@pdf.lcnpj LINE_HEIGHT, 3.94, 16.89, @l1, @xml, "transporta/CNPJ"
|
23
23
|
@pdf.lbox LINE_HEIGHT, 9.02, 0.25, @l2, @xml, "transporta/xEnder"
|
24
24
|
@pdf.lbox LINE_HEIGHT, 6.86, 9.27, @l2, @xml, "transporta/xMun"
|
25
25
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l2, @xml, "transporta/UF"
|
26
|
-
@pdf.
|
26
|
+
@pdf.lie LINE_HEIGHT, 3.94, 16.89, @l2, @xml, "transporta/UF", "transporta/IE"
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def plate
|
31
|
+
Plate.format(@xml["veicTransp/placa"])
|
32
|
+
end
|
33
|
+
|
34
|
+
def mod_frete
|
35
|
+
if @xml["transp/modFrete"] == "0"
|
36
|
+
I18n.t("danfe.transp.modFrete.emitter")
|
37
|
+
else
|
38
|
+
I18n.t("danfe.transp.modFrete.recipient")
|
39
|
+
end
|
27
40
|
end
|
28
41
|
end
|
29
42
|
end
|
data/lib/br_danfe/version.rb
CHANGED
data/lib/br_danfe/xprod.rb
CHANGED
@@ -37,10 +37,10 @@ module BrDanfe
|
|
37
37
|
|
38
38
|
def st
|
39
39
|
"\n" + I18n.t("danfe.det.prod.xProdST",
|
40
|
-
pMVAST: @det.css('ICMS/*/pMVAST').text,
|
41
|
-
pICMSST: @det.css('ICMS/*/pICMSST').text,
|
42
|
-
vBCST: @det.css('ICMS/*/vBCST').text,
|
43
|
-
vICMSST: @det.css('ICMS/*/vICMSST').text)
|
40
|
+
pMVAST: Helper.numerify(@det.css('ICMS/*/pMVAST').text, 2),
|
41
|
+
pICMSST: Helper.numerify(@det.css('ICMS/*/pICMSST').text, 2),
|
42
|
+
vBCST: Helper.numerify(@det.css('ICMS/*/vBCST').text, 2),
|
43
|
+
vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text, 2))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/br_danfe.rb
CHANGED
@@ -49,20 +49,12 @@ describe BrDanfe::Danfe do
|
|
49
49
|
|
50
50
|
it "renders a NF-e with logo" do
|
51
51
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
|
52
|
-
danfe.options.logo_path = "
|
52
|
+
danfe.options.logo_path = "spec/fixtures/logo.png"
|
53
53
|
|
54
54
|
expected = IO.binread("#{base_dir}nfe_with_logo.xml.fixture.pdf")
|
55
55
|
|
56
56
|
expect(danfe.render_pdf).to eq expected
|
57
57
|
end
|
58
|
-
|
59
|
-
it "renders a NF-e with CPF" do
|
60
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
|
61
|
-
|
62
|
-
expected = IO.binread("#{base_dir}nfe_with_cpf.xml.fixture.pdf")
|
63
|
-
|
64
|
-
expect(danfe.render_pdf).to eq expected
|
65
|
-
end
|
66
58
|
end
|
67
59
|
|
68
60
|
describe "#save_pdf" do
|
@@ -117,20 +109,11 @@ describe BrDanfe::Danfe do
|
|
117
109
|
expect(File.exist?(output_pdf)).to be_falsey
|
118
110
|
|
119
111
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_logo.xml"))
|
120
|
-
danfe.options.logo_path = "
|
112
|
+
danfe.options.logo_path = "spec/fixtures/logo.png"
|
121
113
|
danfe.save_pdf output_pdf
|
122
114
|
|
123
115
|
expect("#{base_dir}nfe_with_logo.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
124
116
|
end
|
125
|
-
|
126
|
-
it "renders a NF-e with CPF" do
|
127
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
128
|
-
|
129
|
-
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_cpf.xml"))
|
130
|
-
danfe.save_pdf output_pdf
|
131
|
-
|
132
|
-
expect("#{base_dir}nfe_with_cpf.xml.fixture.pdf").to be_same_file_as(output_pdf)
|
133
|
-
end
|
134
117
|
end
|
135
118
|
end
|
136
119
|
|
@@ -0,0 +1,201 @@
|
|
1
|
+
%PDF-1.3
|
2
|
+
%����
|
3
|
+
1 0 obj
|
4
|
+
<< /Creator <feff0050007200610077006e>
|
5
|
+
/Producer <feff0050007200610077006e>
|
6
|
+
>>
|
7
|
+
endobj
|
8
|
+
2 0 obj
|
9
|
+
<< /Type /Catalog
|
10
|
+
/Pages 3 0 R
|
11
|
+
>>
|
12
|
+
endobj
|
13
|
+
3 0 obj
|
14
|
+
<< /Type /Pages
|
15
|
+
/Count 1
|
16
|
+
/Kids [5 0 R]
|
17
|
+
>>
|
18
|
+
endobj
|
19
|
+
4 0 obj
|
20
|
+
<< /Length 1916
|
21
|
+
>>
|
22
|
+
stream
|
23
|
+
q
|
24
|
+
0.3 w
|
25
|
+
|
26
|
+
BT
|
27
|
+
7.086614173228347 608.772220472441 Td
|
28
|
+
/F2.0 8 Tf
|
29
|
+
[<44455354494e> 20 <41> 95 <54> 90 <c152494f202f2052454d4554454e5445>] TJ
|
30
|
+
ET
|
31
|
+
|
32
|
+
7.087 583.654 349.228 22.677 re
|
33
|
+
S
|
34
|
+
|
35
|
+
BT
|
36
|
+
9.086614173228348 600.2327086614175 Td
|
37
|
+
/F1.0 6 Tf
|
38
|
+
[<4e4f4d452f52415ac3> 55 <4f20534f4349414c>] TJ
|
39
|
+
ET
|
40
|
+
|
41
|
+
356.315 583.654 138.047 22.677 re
|
42
|
+
S
|
43
|
+
|
44
|
+
BT
|
45
|
+
358.3149606299213 600.2327086614175 Td
|
46
|
+
/F1.0 6 Tf
|
47
|
+
[<434e504a2f435046>] TJ
|
48
|
+
ET
|
49
|
+
|
50
|
+
|
51
|
+
BT
|
52
|
+
358.3149606299213 586.5007086614174 Td
|
53
|
+
/F1.0 10 Tf
|
54
|
+
[<37312e3035382e3838342f303030312d3833>] TJ
|
55
|
+
ET
|
56
|
+
|
57
|
+
7.087 560.976 288.000 22.677 re
|
58
|
+
S
|
59
|
+
|
60
|
+
BT
|
61
|
+
9.086614173228348 577.5555433070867 Td
|
62
|
+
/F1.0 6 Tf
|
63
|
+
[<454e44455245c74f>] TJ
|
64
|
+
ET
|
65
|
+
|
66
|
+
|
67
|
+
BT
|
68
|
+
9.086614173228348 563.8235433070867 Td
|
69
|
+
/F1.0 10 Tf
|
70
|
+
[<>] TJ
|
71
|
+
ET
|
72
|
+
|
73
|
+
295.087 560.976 136.913 22.677 re
|
74
|
+
S
|
75
|
+
|
76
|
+
BT
|
77
|
+
297.0866141732284 577.5555433070867 Td
|
78
|
+
/F1.0 6 Tf
|
79
|
+
[<42> 35 <41495252> 40 <4f>] TJ
|
80
|
+
ET
|
81
|
+
|
82
|
+
432.000 560.976 62.362 22.677 re
|
83
|
+
S
|
84
|
+
|
85
|
+
BT
|
86
|
+
434.00000000000006 577.5555433070867 Td
|
87
|
+
/F1.0 6 Tf
|
88
|
+
[<434550>] TJ
|
89
|
+
ET
|
90
|
+
|
91
|
+
7.087 538.299 201.543 22.677 re
|
92
|
+
S
|
93
|
+
|
94
|
+
BT
|
95
|
+
9.086614173228348 554.878377952756 Td
|
96
|
+
/F1.0 6 Tf
|
97
|
+
[<4d554e4943cd50494f>] TJ
|
98
|
+
ET
|
99
|
+
|
100
|
+
208.630 538.299 115.087 22.677 re
|
101
|
+
S
|
102
|
+
|
103
|
+
BT
|
104
|
+
210.62992125984258 554.878377952756 Td
|
105
|
+
/F1.0 6 Tf
|
106
|
+
[<464f4e452f46> 74 <4158>] TJ
|
107
|
+
ET
|
108
|
+
|
109
|
+
323.717 538.299 32.315 22.677 re
|
110
|
+
S
|
111
|
+
|
112
|
+
BT
|
113
|
+
325.71653543307093 554.878377952756 Td
|
114
|
+
/F1.0 6 Tf
|
115
|
+
[<5546>] TJ
|
116
|
+
ET
|
117
|
+
|
118
|
+
356.031 538.299 138.331 22.677 re
|
119
|
+
S
|
120
|
+
|
121
|
+
BT
|
122
|
+
358.0314960629922 554.878377952756 Td
|
123
|
+
/F1.0 6 Tf
|
124
|
+
[<494e53435249c7c3> 55 <4f20455354> 93 <414455> 40 <414c>] TJ
|
125
|
+
ET
|
126
|
+
|
127
|
+
507.402 583.654 82.772 22.677 re
|
128
|
+
S
|
129
|
+
|
130
|
+
BT
|
131
|
+
509.4015748031497 600.2327086614175 Td
|
132
|
+
/F1.0 6 Tf
|
133
|
+
[<44> 40 <41> 111 <54> 93 <412044> 40 <4120454d495353c3> 55 <4f>] TJ
|
134
|
+
ET
|
135
|
+
|
136
|
+
507.402 560.976 82.772 22.677 re
|
137
|
+
S
|
138
|
+
|
139
|
+
BT
|
140
|
+
509.4015748031497 577.5555433070867 Td
|
141
|
+
/F1.0 6 Tf
|
142
|
+
[<44> 40 <41> 111 <54> 93 <412044> 40 <4120454e54524144> 40 <412f5341cd44> 40 <41>] TJ
|
143
|
+
ET
|
144
|
+
|
145
|
+
507.402 538.299 82.772 22.677 re
|
146
|
+
S
|
147
|
+
|
148
|
+
BT
|
149
|
+
509.4015748031497 554.878377952756 Td
|
150
|
+
/F1.0 6 Tf
|
151
|
+
[<484f524120444520454e54524144> 40 <412f5341cd44> 40 <41>] TJ
|
152
|
+
ET
|
153
|
+
|
154
|
+
Q
|
155
|
+
|
156
|
+
endstream
|
157
|
+
endobj
|
158
|
+
5 0 obj
|
159
|
+
<< /Type /Page
|
160
|
+
/Parent 3 0 R
|
161
|
+
/MediaBox [0 0 595.28 841.89]
|
162
|
+
/Contents 4 0 R
|
163
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
164
|
+
/Font << /F2.0 6 0 R
|
165
|
+
/F1.0 7 0 R
|
166
|
+
>>
|
167
|
+
>>
|
168
|
+
>>
|
169
|
+
endobj
|
170
|
+
6 0 obj
|
171
|
+
<< /Type /Font
|
172
|
+
/Subtype /Type1
|
173
|
+
/BaseFont /Times-Bold
|
174
|
+
/Encoding /WinAnsiEncoding
|
175
|
+
>>
|
176
|
+
endobj
|
177
|
+
7 0 obj
|
178
|
+
<< /Type /Font
|
179
|
+
/Subtype /Type1
|
180
|
+
/BaseFont /Times-Roman
|
181
|
+
/Encoding /WinAnsiEncoding
|
182
|
+
>>
|
183
|
+
endobj
|
184
|
+
xref
|
185
|
+
0 8
|
186
|
+
0000000000 65535 f
|
187
|
+
0000000015 00000 n
|
188
|
+
0000000109 00000 n
|
189
|
+
0000000158 00000 n
|
190
|
+
0000000215 00000 n
|
191
|
+
0000002183 00000 n
|
192
|
+
0000002375 00000 n
|
193
|
+
0000002473 00000 n
|
194
|
+
trailer
|
195
|
+
<< /Size 8
|
196
|
+
/Root 2 0 R
|
197
|
+
/Info 1 0 R
|
198
|
+
>>
|
199
|
+
startxref
|
200
|
+
2572
|
201
|
+
%%EOF
|