br_danfe 0.19.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/Gemfile.lock +21 -19
- data/br_danfe.gemspec +4 -4
- data/config/locales/pt-BR.yml +15 -0
- data/lib/br_danfe/danfe_lib/nfe.rb +5 -3
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +6 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +8 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/entrega.rb +86 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +4 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +8 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +3 -19
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +4 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +8 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +6 -2
- data/lib/br_danfe/logo_config.rb +4 -15
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe.rb +0 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +73 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +50 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/entrega_spec.rb +186 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +23 -4
- data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +46 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +0 -41
- data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +49 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +49 -0
- data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +59 -0
- data/spec/br_danfe/danfe_lib/nfe_spec.rb +11 -0
- data/spec/br_danfe/logo_config_spec.rb +6 -8
- data/spec/fixtures/nfe/lib/det_body#render-with_entrega.pdf +1110 -0
- data/spec/fixtures/nfe/lib/dup#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-v2.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with-address-bigger.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with_cpf.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-without-address-complement.pdf +0 -0
- data/spec/fixtures/nfe/lib/icmstot#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml +260 -0
- data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml.fixture.pdf +3413 -0
- metadata +28 -14
@@ -48,5 +48,55 @@ describe BrDanfe::DanfeLib::NfeLib::Dup do
|
|
48
48
|
|
49
49
|
expect("#{base_dir}dup#render.pdf").to have_same_content_of file: output_pdf
|
50
50
|
end
|
51
|
+
|
52
|
+
describe 'with entrega' do
|
53
|
+
let(:xml_as_string) do
|
54
|
+
<<~XML
|
55
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
56
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
57
|
+
<cobr>
|
58
|
+
<dup>
|
59
|
+
<nDup>1</nDup>
|
60
|
+
<dVenc>2015-02-13</dVenc>
|
61
|
+
<vDup>25.56</vDup>
|
62
|
+
</dup>
|
63
|
+
<dup>
|
64
|
+
<nDup>2</nDup>
|
65
|
+
<dVenc>2015-03-15</dVenc>
|
66
|
+
<vDup>25.56</vDup>
|
67
|
+
</dup>
|
68
|
+
<dup>
|
69
|
+
<nDup>3</nDup>
|
70
|
+
<dVenc>2015-04-14</dVenc>
|
71
|
+
<vDup>25.55</vDup>
|
72
|
+
</dup>
|
73
|
+
</cobr>
|
74
|
+
<entrega>
|
75
|
+
<CNPJ>82743287000880</CNPJ>
|
76
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
77
|
+
<xLgr>Av da Saudade</xLgr>
|
78
|
+
<nro>1125</nro>
|
79
|
+
<xBairro>Frutal</xBairro>
|
80
|
+
<xCpl>Sala 01 e 02</xCpl>
|
81
|
+
<cMun>3552403</cMun>
|
82
|
+
<xMun>SUMARE</xMun>
|
83
|
+
<UF>SP</UF>
|
84
|
+
<CEP>13171320</CEP>
|
85
|
+
<fone>1921046300</fone>
|
86
|
+
<IE>671008375110</IE>
|
87
|
+
</entrega>
|
88
|
+
</infNFe>
|
89
|
+
</NFe>
|
90
|
+
XML
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'renders xml to the pdf' do
|
94
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
95
|
+
|
96
|
+
pdf.render_file output_pdf
|
97
|
+
|
98
|
+
expect("#{base_dir}dup#render-with_entrega.pdf").to have_same_content_of file: output_pdf
|
99
|
+
end
|
100
|
+
end
|
51
101
|
end
|
52
102
|
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BrDanfe::DanfeLib::NfeLib::Entrega do
|
4
|
+
let(:path_of_expected_pdf) { './spec/fixtures/nfe/lib/output.pdf' }
|
5
|
+
|
6
|
+
let(:pdf) { BrDanfe::DanfeLib::NfeLib::Document.new }
|
7
|
+
let(:xml) { BrDanfe::XML.new(xml_as_string) }
|
8
|
+
|
9
|
+
subject { described_class.new(pdf, xml) }
|
10
|
+
|
11
|
+
describe '#render' do
|
12
|
+
before do
|
13
|
+
subject.render
|
14
|
+
File.delete(path_of_expected_pdf) if File.exist?(path_of_expected_pdf)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when nf-e's version is 2.00" do
|
18
|
+
let(:xml_as_string) do
|
19
|
+
<<~XML
|
20
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
21
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
22
|
+
<ide>
|
23
|
+
<dEmi>2011-10-29</dEmi>
|
24
|
+
<dSaiEnt>2011-10-30</dSaiEnt>
|
25
|
+
<hSaiEnt>15:32:45</hSaiEnt>
|
26
|
+
</ide>
|
27
|
+
<entrega>
|
28
|
+
<CNPJ>82743287000880</CNPJ>
|
29
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
30
|
+
<xLgr>Av da Saudade</xLgr>
|
31
|
+
<nro>1125</nro>
|
32
|
+
<xBairro>Frutal</xBairro>
|
33
|
+
<xCpl>Sala 01 e 02</xCpl>
|
34
|
+
<cMun>3552403</cMun>
|
35
|
+
<xMun>SUMARE</xMun>
|
36
|
+
<UF>SP</UF>
|
37
|
+
<CEP>13171320</CEP>
|
38
|
+
<fone>1921046300</fone>
|
39
|
+
<IE>671008375110</IE>
|
40
|
+
</entrega>
|
41
|
+
</infNFe>
|
42
|
+
</NFe>
|
43
|
+
XML
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'renders xml to the pdf' do
|
47
|
+
expect(File.exist?(path_of_expected_pdf)).to be false
|
48
|
+
|
49
|
+
pdf.render_file path_of_expected_pdf
|
50
|
+
|
51
|
+
expect('./spec/fixtures/nfe/lib/entrega#render-v2.00.pdf').to have_same_content_of file: path_of_expected_pdf
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when entrega has CPF' do
|
56
|
+
let(:xml_as_string) do
|
57
|
+
<<~XML
|
58
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
59
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
|
60
|
+
<entrega>
|
61
|
+
<CPF>48532557457</CPF>
|
62
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
63
|
+
<xLgr>Av da Saudade</xLgr>
|
64
|
+
<nro>1125</nro>
|
65
|
+
<xBairro>Frutal</xBairro>
|
66
|
+
<xCpl>Sala 01 e 02</xCpl>
|
67
|
+
<cMun>3552403</cMun>
|
68
|
+
<xMun>SUMARE</xMun>
|
69
|
+
<UF>SP</UF>
|
70
|
+
<CEP>13171320</CEP>
|
71
|
+
<fone>1921046300</fone>
|
72
|
+
</entrega>
|
73
|
+
</infNFe>
|
74
|
+
</NFe>
|
75
|
+
XML
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'renders xml to the pdf' do
|
79
|
+
expect(File.exist?(path_of_expected_pdf)).to be false
|
80
|
+
|
81
|
+
pdf.render_file path_of_expected_pdf
|
82
|
+
|
83
|
+
expect('./spec/fixtures/nfe/lib/entrega#render-with_cpf.pdf').to have_same_content_of file: path_of_expected_pdf
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when recipient address (xLgr + nro + xCpl) has more than 63 characters' do
|
88
|
+
let(:xml_as_string) do
|
89
|
+
<<~XML
|
90
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
91
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
|
92
|
+
<ide>
|
93
|
+
<dhEmi>2018-07-30T13:30:59+00:00</dhEmi>
|
94
|
+
<dhSaiEnt>2018-07-30T14:32:45-03:00</dhSaiEnt>
|
95
|
+
</ide>
|
96
|
+
<entrega>
|
97
|
+
<CNPJ>82743287000880</CNPJ>
|
98
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
99
|
+
<xLgr>Rua do governo do estado</xLgr>
|
100
|
+
<nro>1125</nro>
|
101
|
+
<xCpl>Em anexo ao super mercado maior do bairro</xCpl>
|
102
|
+
<xBairro>Frutal</xBairro>
|
103
|
+
<cMun>3552403</cMun>
|
104
|
+
<xMun>SUMARE</xMun>
|
105
|
+
<UF>SP</UF>
|
106
|
+
<CEP>13171320</CEP>
|
107
|
+
<cPais>1058</cPais>
|
108
|
+
<xPais>BRASIL</xPais>
|
109
|
+
<fone>1921046300</fone>
|
110
|
+
<IE>671008375110</IE>
|
111
|
+
</entrega>
|
112
|
+
</infNFe>
|
113
|
+
</NFe>
|
114
|
+
XML
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'renders xml to pdf discarding the address of after 63 characters' do
|
118
|
+
expect(File.exist?(path_of_expected_pdf)).to be false
|
119
|
+
|
120
|
+
pdf.render_file path_of_expected_pdf
|
121
|
+
|
122
|
+
expect('./spec/fixtures/nfe/lib/entrega#render-with-address-bigger.pdf')
|
123
|
+
.to have_same_content_of file: path_of_expected_pdf
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '.delivery_local' do
|
129
|
+
context 'when entrega/xLgr is present in the XML' do
|
130
|
+
let(:xml_with_address) do
|
131
|
+
<<~XML
|
132
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
133
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
|
134
|
+
<dest>
|
135
|
+
<idEstrangeiro>123456789</idEstrangeiro>
|
136
|
+
<xNome>John Doe</xNome>
|
137
|
+
<enderDest>
|
138
|
+
<xLgr>Av. Bayer Filho</xLgr>
|
139
|
+
<nro>1999</nro>
|
140
|
+
<xBairro>Centro</xBairro>
|
141
|
+
<xMun>Tijucas</xMun>
|
142
|
+
<UF>SC</UF>
|
143
|
+
</enderDest>
|
144
|
+
</dest>
|
145
|
+
<entrega>
|
146
|
+
<CNPJ>82743287000880</CNPJ>
|
147
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
148
|
+
<xLgr>Rua do governo do estado</xLgr>
|
149
|
+
<nro>1125</nro>
|
150
|
+
<xCpl>Em anexo ao super mercado maior do bairro</xCpl>
|
151
|
+
<xBairro>Frutal</xBairro>
|
152
|
+
<cMun>3552403</cMun>
|
153
|
+
<xMun>SUMARE</xMun>
|
154
|
+
<UF>SP</UF>
|
155
|
+
<CEP>13171320</CEP>
|
156
|
+
<cPais>1058</cPais>
|
157
|
+
<xPais>BRASIL</xPais>
|
158
|
+
<fone>1921046300</fone>
|
159
|
+
<IE>671008375110</IE>
|
160
|
+
</entrega>
|
161
|
+
</infNFe>
|
162
|
+
</NFe>
|
163
|
+
XML
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'returns true' do
|
167
|
+
expect(described_class.delivery_local?(xml_with_address)).to be true
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'when entrega/xLgr is not present in the XML' do
|
172
|
+
let(:xml_without_entrega) do
|
173
|
+
<<~XML
|
174
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
175
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="3.10">
|
176
|
+
</infNFe>
|
177
|
+
</NFe>
|
178
|
+
XML
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'returns false' do
|
182
|
+
expect(described_class.delivery_local?(xml_without_entrega)).to be false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
@@ -76,7 +76,7 @@ describe BrDanfe::DanfeLib::NfeLib::Helper do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'returns the address with the street, number and complement' do
|
79
|
-
expect(described_class.generate_address(xml_street))
|
79
|
+
expect(described_class.generate_address(xml_street, 'enderDest'))
|
80
80
|
.to eq 'Rua do governo do estado 1125 - Em anexo ao super mercado maior do bairro'
|
81
81
|
end
|
82
82
|
|
@@ -92,7 +92,7 @@ describe BrDanfe::DanfeLib::NfeLib::Helper do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'returns the address with the street and number' do
|
95
|
-
expect(described_class.generate_address(xml_street))
|
95
|
+
expect(described_class.generate_address(xml_street, 'enderDest'))
|
96
96
|
.to eq 'Rua do governo do estado 1125'
|
97
97
|
end
|
98
98
|
end
|
@@ -109,7 +109,7 @@ describe BrDanfe::DanfeLib::NfeLib::Helper do
|
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'returns the address with the street only' do
|
112
|
-
expect(described_class.generate_address(xml_street))
|
112
|
+
expect(described_class.generate_address(xml_street, 'enderDest'))
|
113
113
|
.to eq 'Rua do governo do estado'
|
114
114
|
end
|
115
115
|
end
|
@@ -126,9 +126,28 @@ describe BrDanfe::DanfeLib::NfeLib::Helper do
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'returns the address with the street and complement' do
|
129
|
-
expect(described_class.generate_address(xml_street))
|
129
|
+
expect(described_class.generate_address(xml_street, 'enderDest'))
|
130
130
|
.to eq 'Rua do governo do estado - Em anexo ao super mercado maior do bairro'
|
131
131
|
end
|
132
132
|
end
|
133
|
+
|
134
|
+
context 'when receive the path' do
|
135
|
+
let(:xml_entrega) do
|
136
|
+
<<~XML
|
137
|
+
<entrega>
|
138
|
+
<xLgr>Rua estadual</xLgr>
|
139
|
+
<nro>3341</nro>
|
140
|
+
<xCpl>Em anexo ao bairro</xCpl>
|
141
|
+
</entrega>
|
142
|
+
XML
|
143
|
+
end
|
144
|
+
|
145
|
+
let(:xml_street_entrega) { Nokogiri::XML(xml_entrega) }
|
146
|
+
|
147
|
+
it 'returns the address scoped by the given path' do
|
148
|
+
expect(described_class.generate_address(xml_street_entrega, 'entrega'))
|
149
|
+
.to eq 'Rua estadual 3341 - Em anexo ao bairro'
|
150
|
+
end
|
151
|
+
end
|
133
152
|
end
|
134
153
|
end
|
@@ -44,5 +44,51 @@ describe BrDanfe::DanfeLib::NfeLib::Icmstot do
|
|
44
44
|
|
45
45
|
expect("#{base_dir}icmstot#render.pdf").to have_same_content_of file: output_pdf
|
46
46
|
end
|
47
|
+
|
48
|
+
describe 'with entrega' do
|
49
|
+
let(:xml_as_string) do
|
50
|
+
<<~XML
|
51
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
52
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
53
|
+
<ICMSTot>
|
54
|
+
<vBC>1.23</vBC>
|
55
|
+
<vICMS>2.34</vICMS>
|
56
|
+
<vBCST>3.45</vBCST>
|
57
|
+
<vST>4.56</vST>
|
58
|
+
<vProd>5.67</vProd>
|
59
|
+
<vFrete>6.78</vFrete>
|
60
|
+
<vSeg>7.89</vSeg>
|
61
|
+
<vDesc>9.01</vDesc>
|
62
|
+
<vIPI>0.12</vIPI>
|
63
|
+
<vOutro>1.34</vOutro>
|
64
|
+
<vNF>4.35</vNF>
|
65
|
+
</ICMSTot>
|
66
|
+
<entrega>
|
67
|
+
<CNPJ>82743287000880</CNPJ>
|
68
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
69
|
+
<xLgr>Av da Saudade</xLgr>
|
70
|
+
<nro>1125</nro>
|
71
|
+
<xBairro>Frutal</xBairro>
|
72
|
+
<xCpl>Sala 01 e 02</xCpl>
|
73
|
+
<cMun>3552403</cMun>
|
74
|
+
<xMun>SUMARE</xMun>
|
75
|
+
<UF>SP</UF>
|
76
|
+
<CEP>13171320</CEP>
|
77
|
+
<fone>1921046300</fone>
|
78
|
+
<IE>671008375110</IE>
|
79
|
+
</entrega>
|
80
|
+
</infNFe>
|
81
|
+
</NFe>
|
82
|
+
XML
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'renders xml to the pdf' do
|
86
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
87
|
+
|
88
|
+
pdf.render_file output_pdf
|
89
|
+
|
90
|
+
expect("#{base_dir}icmstot#render-with_entrega.pdf").to have_same_content_of file: output_pdf
|
91
|
+
end
|
92
|
+
end
|
47
93
|
end
|
48
94
|
end
|
@@ -339,36 +339,6 @@ describe BrDanfe::DanfeLib::NfeLib::Infadic do
|
|
339
339
|
end
|
340
340
|
end
|
341
341
|
|
342
|
-
context 'when has address shipment' do
|
343
|
-
let(:xml_as_string) do
|
344
|
-
<<~XML
|
345
|
-
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
346
|
-
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
347
|
-
<entrega>
|
348
|
-
<CNPJ>32301321907894</CNPJ>
|
349
|
-
<CPF></CPF>
|
350
|
-
<xLgr>Rua dos bobos</xLgr>
|
351
|
-
<nro>0</nro>
|
352
|
-
<xCpl>Na casa não tem parede</xCpl>
|
353
|
-
<xBairro>Centro</xBairro>
|
354
|
-
<cMun>4218004</cMun>
|
355
|
-
<xMun>TIJUCAS</xMun>
|
356
|
-
<UF>SC</UF>
|
357
|
-
</entrega>
|
358
|
-
</infNFe>
|
359
|
-
</NFe>
|
360
|
-
XML
|
361
|
-
end
|
362
|
-
|
363
|
-
it 'renders title with box, subtitle, fisco box and address shipment information on the pdf' do
|
364
|
-
expect(File.exist?(output_pdf)).to be_falsey
|
365
|
-
|
366
|
-
pdf.render_file output_pdf
|
367
|
-
|
368
|
-
expect("#{base_dir}infadic#address-shipment.pdf").to have_same_content_of file: output_pdf
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
342
|
context 'when has all the informations' do
|
373
343
|
let(:xml_as_string) do
|
374
344
|
<<~XML
|
@@ -418,17 +388,6 @@ describe BrDanfe::DanfeLib::NfeLib::Infadic do
|
|
418
388
|
<pesoB>3300.000</pesoB>
|
419
389
|
</vol>
|
420
390
|
</transp>
|
421
|
-
<entrega>
|
422
|
-
<CNPJ>32301321907894</CNPJ>
|
423
|
-
<CPF></CPF>
|
424
|
-
<xLgr>Rua dos bobos</xLgr>
|
425
|
-
<nro>0</nro>
|
426
|
-
<xCpl>Na casa não tem parede</xCpl>
|
427
|
-
<xBairro>Centro</xBairro>
|
428
|
-
<cMun>4218004</cMun>
|
429
|
-
<xMun>TIJUCAS</xMun>
|
430
|
-
<UF>SC</UF>
|
431
|
-
</entrega>
|
432
391
|
<infAdic>
|
433
392
|
<infCpl>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue in dolor sed sagittis.</infCpl>
|
434
393
|
<infAdFisco>Total de FCP-ST: 348,96</infAdFisco>
|
@@ -73,5 +73,54 @@ describe BrDanfe::DanfeLib::NfeLib::Issqn do
|
|
73
73
|
expect("#{base_dir}issqn#render-without_issqn.pdf").to have_same_content_of file: output_pdf
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
describe 'with entrega' do
|
78
|
+
let(:xml_as_string) do
|
79
|
+
<<~XML
|
80
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
81
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
82
|
+
<emit>
|
83
|
+
<IM>2345</IM>
|
84
|
+
</emit>
|
85
|
+
<total>
|
86
|
+
<ISSQNtot>
|
87
|
+
#{issqn}
|
88
|
+
</ISSQNtot>
|
89
|
+
</total>
|
90
|
+
<entrega>
|
91
|
+
<CNPJ>82743287000880</CNPJ>
|
92
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
93
|
+
<xLgr>Av da Saudade</xLgr>
|
94
|
+
<nro>1125</nro>
|
95
|
+
<xBairro>Frutal</xBairro>
|
96
|
+
<xCpl>Sala 01 e 02</xCpl>
|
97
|
+
<cMun>3552403</cMun>
|
98
|
+
<xMun>SUMARE</xMun>
|
99
|
+
<UF>SP</UF>
|
100
|
+
<CEP>13171320</CEP>
|
101
|
+
<fone>1921046300</fone>
|
102
|
+
<IE>671008375110</IE>
|
103
|
+
</entrega>
|
104
|
+
</infNFe>
|
105
|
+
</NFe>
|
106
|
+
XML
|
107
|
+
end
|
108
|
+
|
109
|
+
let(:issqn) do
|
110
|
+
<<~XML
|
111
|
+
<vServ>1.43</vServ>
|
112
|
+
<vBC>2.34</vBC>
|
113
|
+
<vISS>3.45</vISS>
|
114
|
+
XML
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'renders xml to the pdf' do
|
118
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
119
|
+
|
120
|
+
pdf.render_file output_pdf
|
121
|
+
|
122
|
+
expect("#{base_dir}issqn#render-with_entrega.pdf").to have_same_content_of file: output_pdf
|
123
|
+
end
|
124
|
+
end
|
76
125
|
end
|
77
126
|
end
|
@@ -179,5 +179,54 @@ describe BrDanfe::DanfeLib::NfeLib::Transp do
|
|
179
179
|
expect("#{base_dir}transp#render-modfrete_9.pdf").to have_same_content_of file: output_pdf
|
180
180
|
end
|
181
181
|
end
|
182
|
+
|
183
|
+
describe 'with entrega' do
|
184
|
+
let(:xml_as_string) do
|
185
|
+
<<~XML
|
186
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
187
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
188
|
+
<transp>
|
189
|
+
<modFrete>0</modFrete>
|
190
|
+
<transporta>
|
191
|
+
<CNPJ>71434064000149</CNPJ>
|
192
|
+
<xNome>Nome do Transportador Ltda</xNome>
|
193
|
+
<IE>964508990089</IE>
|
194
|
+
<xEnder>Rua do Transportador, 456</xEnder>
|
195
|
+
<xMun>Votorantim</xMun>
|
196
|
+
<UF>SP</UF>
|
197
|
+
</transporta>
|
198
|
+
<veicTransp>
|
199
|
+
<placa>ABC-1234</placa>
|
200
|
+
<UF>SP</UF>
|
201
|
+
<RNTC>123456</RNTC>
|
202
|
+
</veicTransp>
|
203
|
+
</transp>
|
204
|
+
<entrega>
|
205
|
+
<CNPJ>82743287000880</CNPJ>
|
206
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
207
|
+
<xLgr>Av da Saudade</xLgr>
|
208
|
+
<nro>1125</nro>
|
209
|
+
<xBairro>Frutal</xBairro>
|
210
|
+
<xCpl>Sala 01 e 02</xCpl>
|
211
|
+
<cMun>3552403</cMun>
|
212
|
+
<xMun>SUMARE</xMun>
|
213
|
+
<UF>SP</UF>
|
214
|
+
<CEP>13171320</CEP>
|
215
|
+
<fone>1921046300</fone>
|
216
|
+
<IE>671008375110</IE>
|
217
|
+
</entrega>
|
218
|
+
</infNFe>
|
219
|
+
</NFe>
|
220
|
+
XML
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'renders xml to the pdf' do
|
224
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
225
|
+
|
226
|
+
pdf.render_file output_pdf
|
227
|
+
|
228
|
+
expect("#{base_dir}transp#render-with_entrega.pdf").to have_same_content_of file: output_pdf
|
229
|
+
end
|
230
|
+
end
|
182
231
|
end
|
183
232
|
end
|
@@ -82,5 +82,64 @@ describe BrDanfe::DanfeLib::NfeLib::Vol do
|
|
82
82
|
expect("#{base_dir}vol#render-blank-boxes.pdf").to have_same_content_of file: output_pdf
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
describe 'with entrega' do
|
87
|
+
let(:xml_as_string) do
|
88
|
+
<<~XML
|
89
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
90
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
91
|
+
<transp>
|
92
|
+
<vol>
|
93
|
+
<qVol>1</qVol>
|
94
|
+
<esp>VOLUMES 1</esp>
|
95
|
+
<marca>DIVERSOS 1</marca>
|
96
|
+
<nVol>1</nVol>
|
97
|
+
<pesoL>1000.000</pesoL>
|
98
|
+
<pesoB>1100.000</pesoB>
|
99
|
+
</vol>
|
100
|
+
<vol>
|
101
|
+
<qVol>2</qVol>
|
102
|
+
<esp>VOLUMES 2</esp>
|
103
|
+
<marca>DIVERSOS 2</marca>
|
104
|
+
<nVol>2</nVol>
|
105
|
+
<pesoL>2000.000</pesoL>
|
106
|
+
<pesoB>2200.000</pesoB>
|
107
|
+
</vol>
|
108
|
+
<vol>
|
109
|
+
<qVol>3</qVol>
|
110
|
+
<esp>VOLUMES 3</esp>
|
111
|
+
<marca>DIVERSOS 3</marca>
|
112
|
+
<nVol>3</nVol>
|
113
|
+
<pesoL>3000.000</pesoL>
|
114
|
+
<pesoB>3300.000</pesoB>
|
115
|
+
</vol>
|
116
|
+
</transp>
|
117
|
+
<entrega>
|
118
|
+
<CNPJ>82743287000880</CNPJ>
|
119
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
120
|
+
<xLgr>Av da Saudade</xLgr>
|
121
|
+
<nro>1125</nro>
|
122
|
+
<xBairro>Frutal</xBairro>
|
123
|
+
<xCpl>Sala 01 e 02</xCpl>
|
124
|
+
<cMun>3552403</cMun>
|
125
|
+
<xMun>SUMARE</xMun>
|
126
|
+
<UF>SP</UF>
|
127
|
+
<CEP>13171320</CEP>
|
128
|
+
<fone>1921046300</fone>
|
129
|
+
<IE>671008375110</IE>
|
130
|
+
</entrega>
|
131
|
+
</infNFe>
|
132
|
+
</NFe>
|
133
|
+
XML
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'renders xml to the pdf' do
|
137
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
138
|
+
|
139
|
+
pdf.render_file output_pdf
|
140
|
+
|
141
|
+
expect("#{base_dir}vol#render-with_entrega.pdf").to have_same_content_of file: output_pdf
|
142
|
+
end
|
143
|
+
end
|
85
144
|
end
|
86
145
|
end
|
@@ -91,6 +91,17 @@ describe BrDanfe::DanfeLib::Nfe do
|
|
91
91
|
expect("#{base_dir}nfe_with_extra_volumes.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
context 'when NF-e has entrega' do
|
96
|
+
let(:xml_file) { File.read("#{base_dir}nfe_with_entrega.xml") }
|
97
|
+
|
98
|
+
it 'renders a NF-e with entrega' do
|
99
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
100
|
+
subject.save_pdf output_pdf
|
101
|
+
|
102
|
+
expect("#{base_dir}nfe_with_entrega.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
103
|
+
end
|
104
|
+
end
|
94
105
|
end
|
95
106
|
|
96
107
|
context "when xml's version is v3.10" do
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::Logo::Config do
|
4
|
-
|
5
|
-
|
6
|
-
subject { described_class.new options }
|
4
|
+
subject { described_class.new({}) }
|
7
5
|
|
8
6
|
it 'returns the default config set in the code' do
|
9
|
-
expect(subject.logo).to
|
10
|
-
expect(subject.logo_dimensions).to
|
7
|
+
expect(subject.logo).to eql ''
|
8
|
+
expect(subject.logo_dimensions).to eql({})
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'when there are custom options' do
|
14
|
-
|
12
|
+
subject { described_class.new({ logo: '/fake/path/file.png', logo_dimensions: { width: 50, height: 50 } }) }
|
15
13
|
|
16
14
|
it 'returns the config set in params' do
|
17
|
-
expect(subject.logo).to
|
18
|
-
expect(subject.logo_dimensions).to
|
15
|
+
expect(subject.logo).to eql '/fake/path/file.png'
|
16
|
+
expect(subject.logo_dimensions).to eql width: 50, height: 50
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|