br_danfe 0.7.1 → 0.7.2
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/Gemfile.lock +2 -2
- data/README.md +9 -14
- data/lib/br_danfe/danfe_lib/dest.rb +15 -16
- data/lib/br_danfe/danfe_lib/xml.rb +2 -2
- data/lib/br_danfe/version.rb +1 -1
- data/spec/fixtures/nfe/lib/dest#render-v4.00.pdf +271 -0
- data/spec/lib/danfe_lib/dest_spec.rb +67 -25
- data/spec/lib/danfe_lib/xml_spec.rb +22 -7
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb741f1d1066620c0aa847c09fb4fa72b200c99e
|
4
|
+
data.tar.gz: a264f79ee360582e6ad7190fc8efebc14a630e8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9a9e0920ff13af6e4e9b9de29cb6a8db6da16b666a038551d51df1854805813bc6793569cf12a7a7172d9d30d2830b25df9bfff69d0aa4670e273dd30222e5d
|
7
|
+
data.tar.gz: cf94b429c376ab34b878409c257351025a935070a16b53f0fb5901d2e7516ac1317c7062c1758a9d0a7f66c5a7da19ea3a3c625c90056f55d64395f7d01c8744
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,6 +15,7 @@ XML version | Supported?
|
|
15
15
|
1.00 | no
|
16
16
|
2.00 | yes
|
17
17
|
3.10 | yes
|
18
|
+
4.00 | yes
|
18
19
|
|
19
20
|
## Installing
|
20
21
|
|
@@ -49,13 +50,7 @@ XML version | Supported?
|
|
49
50
|
* `logo_path`: Path of sender's logo image.
|
50
51
|
* `logo_dimensions`: Dimensions of the logo. Ex: logo_dimensions = { width: 100, height: 90 }
|
51
52
|
|
52
|
-
|
53
|
-
----------- | ----------
|
54
|
-
1.00 | no
|
55
|
-
2.00 | yes
|
56
|
-
3.10 | yes
|
57
|
-
|
58
|
-
### CC-e - _Carta de Correção Eletrônica_
|
53
|
+
### CC-e - Carta de Correção Eletrônica
|
59
54
|
|
60
55
|
#### Usage in Ruby
|
61
56
|
|
@@ -103,18 +98,18 @@ You needs to install all necessaries dependencies using bunder like above:
|
|
103
98
|
|
104
99
|
You can run all RSpec specs using:
|
105
100
|
|
106
|
-
$ rspec
|
101
|
+
$ bundle exec rspec
|
107
102
|
|
108
103
|
|
109
104
|
## About tests
|
110
105
|
|
111
|
-
> If you modify something that caused general visual changes at output
|
106
|
+
> If you modify something that caused general visual changes at output pdf's, so you have to rebuild the fixtures pdf files.
|
112
107
|
>
|
113
|
-
> You can do this simply deleting the fixture pdf file. The `have_same_content_of` matcher will recreate the fixture in the next time you run the `rspec` command.
|
108
|
+
> You can do this simply deleting the fixture pdf file. The `have_same_content_of` matcher will recreate the fixture in the next time you run the `bundle exec rspec` command.
|
114
109
|
|
115
110
|
### Code coverage
|
116
111
|
|
117
|
-
Code coverage is available through of SimpleCov. Just run `rspec` and open the coverage report in your browser.
|
112
|
+
Code coverage is available through of SimpleCov. Just run `bundle exec rspec` and open the coverage report in your browser.
|
118
113
|
|
119
114
|
### Fake data for generating new fixtures
|
120
115
|
|
@@ -183,9 +178,9 @@ You can generate new data using [4devs generators](http://www.4devs.com.br).
|
|
183
178
|
|
184
179
|
You can build using one of the above tasks
|
185
180
|
|
186
|
-
$ rake build # Build br_danfe-X.X.X.gem into the pkg directory
|
187
|
-
$ rake install # Build and install br_danfe-X.X.X.gem into system gems
|
188
|
-
$ rake release # Create tag vX.X.X
|
181
|
+
$ bundle exec rake build # Build br_danfe-X.X.X.gem into the pkg directory
|
182
|
+
$ bundle exec rake install # Build and install br_danfe-X.X.X.gem into system gems
|
183
|
+
$ bundle exec rake release # Create tag vX.X.X, build and push br_danfe-X.X.X.gem to Rubygems
|
189
184
|
|
190
185
|
## Contributing
|
191
186
|
|
@@ -7,6 +7,7 @@ module BrDanfe
|
|
7
7
|
def initialize(pdf, xml)
|
8
8
|
@pdf = pdf
|
9
9
|
@xml = xml
|
10
|
+
@xml_version_is_310_or_newer = @xml.version_is_310_or_newer?
|
10
11
|
|
11
12
|
@ltitle = Y - 0.42
|
12
13
|
@l1 = Y
|
@@ -21,10 +22,11 @@ module BrDanfe
|
|
21
22
|
render_line2
|
22
23
|
render_line3
|
23
24
|
|
24
|
-
|
25
|
+
@xml_version_is_310_or_newer ? render_dates_for_nfe_310_or_newer : render_dates_for_older_nfes
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
29
|
+
|
28
30
|
def render_line1
|
29
31
|
@pdf.lbox LINE_HEIGHT, 11.82, 0.75, @l1, @xml, "dest/xNome"
|
30
32
|
render_cnpj_cpf
|
@@ -72,25 +74,22 @@ module BrDanfe
|
|
72
74
|
@pdf.lie LINE_HEIGHT, 4.38, 12.56, @l3, @xml, "enderDest/UF", "dest/IE"
|
73
75
|
end
|
74
76
|
|
75
|
-
def
|
77
|
+
def phone
|
78
|
+
Phone.format(@xml["enderDest/fone"])
|
79
|
+
end
|
76
80
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
hSaiEnt = "ide/dhSaiEnt"
|
81
|
-
else
|
82
|
-
dEmi = "ide/dEmi"
|
83
|
-
dSaiEnt = "ide/dSaiEnt"
|
84
|
-
hSaiEnt = "ide/hSaiEnt"
|
85
|
-
end
|
81
|
+
def render_dates_for_nfe_310_or_newer
|
82
|
+
render_dates "ide/dhEmi", "ide/dhSaiEnt", "ide/dhSaiEnt"
|
83
|
+
end
|
86
84
|
|
87
|
-
|
88
|
-
@pdf.ldate LINE_HEIGHT, 2.92, 17.40, @
|
89
|
-
@pdf.
|
85
|
+
def render_dates(emitted_at_date_and_hour, exited_at_date, exited_at_hour)
|
86
|
+
@pdf.ldate LINE_HEIGHT, 2.92, 17.40, @l1, "ide.dEmi", @xml[emitted_at_date_and_hour], { align: :right }
|
87
|
+
@pdf.ldate LINE_HEIGHT, 2.92, 17.40, @l2, "ide.dSaiEnt", @xml[exited_at_date], { align: :right }
|
88
|
+
@pdf.ltime LINE_HEIGHT, 2.92, 17.40, @l3, "ide.hSaiEnt", @xml[exited_at_hour], { align: :right }
|
90
89
|
end
|
91
90
|
|
92
|
-
def
|
93
|
-
|
91
|
+
def render_dates_for_older_nfes
|
92
|
+
render_dates "ide/dEmi", "ide/dSaiEnt", "ide/hSaiEnt"
|
94
93
|
end
|
95
94
|
end
|
96
95
|
end
|
data/lib/br_danfe/version.rb
CHANGED
@@ -0,0 +1,271 @@
|
|
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 2451
|
21
|
+
>>
|
22
|
+
stream
|
23
|
+
q
|
24
|
+
0.3 w
|
25
|
+
|
26
|
+
BT
|
27
|
+
21.2598 596.8667 Td
|
28
|
+
/F2.0 8 Tf
|
29
|
+
[<44455354494e> 20 <41> 95 <54> 90 <c152494f202f2052454d4554454e5445>] TJ
|
30
|
+
ET
|
31
|
+
|
32
|
+
21.2598 571.748 335.0551 22.6772 re
|
33
|
+
S
|
34
|
+
|
35
|
+
BT
|
36
|
+
23.2598 588.3272 Td
|
37
|
+
/F1.0 6 Tf
|
38
|
+
[<4e4f4d452f52415ac3> 55 <4f20534f4349414c>] TJ
|
39
|
+
ET
|
40
|
+
|
41
|
+
|
42
|
+
BT
|
43
|
+
23.2598 574.5952 Td
|
44
|
+
/F1.0 10 Tf
|
45
|
+
[<5363686e656964657220456c6563747269632042726173696c204c746461>] TJ
|
46
|
+
ET
|
47
|
+
|
48
|
+
356.315 571.748 123.874 22.6772 re
|
49
|
+
S
|
50
|
+
|
51
|
+
BT
|
52
|
+
358.315 588.3272 Td
|
53
|
+
/F1.0 6 Tf
|
54
|
+
[<434e504a2f435046>] TJ
|
55
|
+
ET
|
56
|
+
|
57
|
+
|
58
|
+
BT
|
59
|
+
358.315 574.5952 Td
|
60
|
+
/F1.0 10 Tf
|
61
|
+
[<38322e3734332e3238372f303030382d3830>] TJ
|
62
|
+
ET
|
63
|
+
|
64
|
+
21.2598 549.0709 273.8268 22.6772 re
|
65
|
+
S
|
66
|
+
|
67
|
+
BT
|
68
|
+
23.2598 565.65 Td
|
69
|
+
/F1.0 6 Tf
|
70
|
+
[<454e44455245c74f>] TJ
|
71
|
+
ET
|
72
|
+
|
73
|
+
|
74
|
+
BT
|
75
|
+
23.2598 551.918 Td
|
76
|
+
/F1.0 10 Tf
|
77
|
+
[<41> 74 <7620646120536175646164652031313235202d2053616c612030312065203032>] TJ
|
78
|
+
ET
|
79
|
+
|
80
|
+
295.0866 549.0709 122.7402 22.6772 re
|
81
|
+
S
|
82
|
+
|
83
|
+
BT
|
84
|
+
297.0866 565.65 Td
|
85
|
+
/F1.0 6 Tf
|
86
|
+
[<42> 35 <41495252> 40 <4f>] TJ
|
87
|
+
ET
|
88
|
+
|
89
|
+
|
90
|
+
BT
|
91
|
+
297.0866 551.918 Td
|
92
|
+
/F1.0 10 Tf
|
93
|
+
[<46727574616c>] TJ
|
94
|
+
ET
|
95
|
+
|
96
|
+
417.8268 549.0709 62.3622 22.6772 re
|
97
|
+
S
|
98
|
+
|
99
|
+
BT
|
100
|
+
419.8268 565.65 Td
|
101
|
+
/F1.0 6 Tf
|
102
|
+
[<434550>] TJ
|
103
|
+
ET
|
104
|
+
|
105
|
+
|
106
|
+
BT
|
107
|
+
419.8268 551.918 Td
|
108
|
+
/F1.0 10 Tf
|
109
|
+
[<31332e3137312d333230>] TJ
|
110
|
+
ET
|
111
|
+
|
112
|
+
21.2598 526.3937 187.3701 22.6772 re
|
113
|
+
S
|
114
|
+
|
115
|
+
BT
|
116
|
+
23.2598 542.9729 Td
|
117
|
+
/F1.0 6 Tf
|
118
|
+
[<4d554e4943cd50494f>] TJ
|
119
|
+
ET
|
120
|
+
|
121
|
+
|
122
|
+
BT
|
123
|
+
23.2598 529.2409 Td
|
124
|
+
/F1.0 10 Tf
|
125
|
+
[<53554d415245>] TJ
|
126
|
+
ET
|
127
|
+
|
128
|
+
208.6299 526.3937 115.0866 22.6772 re
|
129
|
+
S
|
130
|
+
|
131
|
+
BT
|
132
|
+
210.6299 542.9729 Td
|
133
|
+
/F1.0 6 Tf
|
134
|
+
[<464f4e452f46> 74 <4158>] TJ
|
135
|
+
ET
|
136
|
+
|
137
|
+
|
138
|
+
BT
|
139
|
+
210.6299 529.2409 Td
|
140
|
+
/F1.0 10 Tf
|
141
|
+
[<2831392920323130342d36333030>] TJ
|
142
|
+
ET
|
143
|
+
|
144
|
+
323.7165 526.3937 32.315 22.6772 re
|
145
|
+
S
|
146
|
+
|
147
|
+
BT
|
148
|
+
325.7165 542.9729 Td
|
149
|
+
/F1.0 6 Tf
|
150
|
+
[<5546>] TJ
|
151
|
+
ET
|
152
|
+
|
153
|
+
|
154
|
+
BT
|
155
|
+
325.7165 529.2409 Td
|
156
|
+
/F1.0 10 Tf
|
157
|
+
[<5350>] TJ
|
158
|
+
ET
|
159
|
+
|
160
|
+
356.0315 526.3937 124.1575 22.6772 re
|
161
|
+
S
|
162
|
+
|
163
|
+
BT
|
164
|
+
358.0315 542.9729 Td
|
165
|
+
/F1.0 6 Tf
|
166
|
+
[<494e53435249c7c3> 55 <4f20455354> 93 <414455> 40 <414c>] TJ
|
167
|
+
ET
|
168
|
+
|
169
|
+
|
170
|
+
BT
|
171
|
+
358.0315 529.2409 Td
|
172
|
+
/F1.0 10 Tf
|
173
|
+
[<3637312e3030382e3337352e313130>] TJ
|
174
|
+
ET
|
175
|
+
|
176
|
+
493.2283 571.748 82.7717 22.6772 re
|
177
|
+
S
|
178
|
+
|
179
|
+
BT
|
180
|
+
495.2283 588.3272 Td
|
181
|
+
/F1.0 6 Tf
|
182
|
+
[<44> 40 <41> 111 <54> 93 <412044> 40 <4120454d495353c3> 55 <4f>] TJ
|
183
|
+
ET
|
184
|
+
|
185
|
+
|
186
|
+
BT
|
187
|
+
528.44 574.5952 Td
|
188
|
+
/F1.0 10 Tf
|
189
|
+
[<33302f30372f32303138>] TJ
|
190
|
+
ET
|
191
|
+
|
192
|
+
493.2283 549.0709 82.7717 22.6772 re
|
193
|
+
S
|
194
|
+
|
195
|
+
BT
|
196
|
+
495.2283 565.65 Td
|
197
|
+
/F1.0 6 Tf
|
198
|
+
[<44> 40 <41> 111 <54> 93 <412044> 40 <4120454e54524144> 40 <412f5341cd44> 40 <41>] TJ
|
199
|
+
ET
|
200
|
+
|
201
|
+
|
202
|
+
BT
|
203
|
+
528.44 551.918 Td
|
204
|
+
/F1.0 10 Tf
|
205
|
+
[<33302f30372f32303138>] TJ
|
206
|
+
ET
|
207
|
+
|
208
|
+
493.2283 526.3937 82.7717 22.6772 re
|
209
|
+
S
|
210
|
+
|
211
|
+
BT
|
212
|
+
495.2283 542.9729 Td
|
213
|
+
/F1.0 6 Tf
|
214
|
+
[<484f524120444520454e54524144> 40 <412f5341cd44> 40 <41>] TJ
|
215
|
+
ET
|
216
|
+
|
217
|
+
|
218
|
+
BT
|
219
|
+
538.44 529.2409 Td
|
220
|
+
/F1.0 10 Tf
|
221
|
+
[<31343a33323a3435>] TJ
|
222
|
+
ET
|
223
|
+
|
224
|
+
Q
|
225
|
+
|
226
|
+
endstream
|
227
|
+
endobj
|
228
|
+
5 0 obj
|
229
|
+
<< /Type /Page
|
230
|
+
/Parent 3 0 R
|
231
|
+
/MediaBox [0 0 595.28 841.89]
|
232
|
+
/Contents 4 0 R
|
233
|
+
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
234
|
+
/Font << /F2.0 6 0 R
|
235
|
+
/F1.0 7 0 R
|
236
|
+
>>
|
237
|
+
>>
|
238
|
+
>>
|
239
|
+
endobj
|
240
|
+
6 0 obj
|
241
|
+
<< /Type /Font
|
242
|
+
/Subtype /Type1
|
243
|
+
/BaseFont /Times-Bold
|
244
|
+
/Encoding /WinAnsiEncoding
|
245
|
+
>>
|
246
|
+
endobj
|
247
|
+
7 0 obj
|
248
|
+
<< /Type /Font
|
249
|
+
/Subtype /Type1
|
250
|
+
/BaseFont /Times-Roman
|
251
|
+
/Encoding /WinAnsiEncoding
|
252
|
+
>>
|
253
|
+
endobj
|
254
|
+
xref
|
255
|
+
0 8
|
256
|
+
0000000000 65535 f
|
257
|
+
0000000015 00000 n
|
258
|
+
0000000109 00000 n
|
259
|
+
0000000158 00000 n
|
260
|
+
0000000215 00000 n
|
261
|
+
0000002718 00000 n
|
262
|
+
0000002910 00000 n
|
263
|
+
0000003008 00000 n
|
264
|
+
trailer
|
265
|
+
<< /Size 8
|
266
|
+
/Root 2 0 R
|
267
|
+
/Info 1 0 R
|
268
|
+
>>
|
269
|
+
startxref
|
270
|
+
3107
|
271
|
+
%%EOF
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe BrDanfe::DanfeLib::Dest do
|
4
|
-
let(:
|
5
|
-
let(:output_pdf) { "#{base_dir}output.pdf" }
|
4
|
+
let(:path_of_expected_pdf) { "./spec/fixtures/nfe/lib/output.pdf" }
|
6
5
|
|
7
6
|
let(:pdf) { BrDanfe::DanfeLib::Document.new }
|
8
7
|
let(:xml) { BrDanfe::DanfeLib::XML.new(xml_as_string) }
|
@@ -11,8 +10,8 @@ describe BrDanfe::DanfeLib::Dest do
|
|
11
10
|
|
12
11
|
describe "#render" do
|
13
12
|
before do
|
13
|
+
File.delete(path_of_expected_pdf) if File.exist?(path_of_expected_pdf)
|
14
14
|
subject.render
|
15
|
-
File.delete(output_pdf) if File.exist?(output_pdf)
|
16
15
|
end
|
17
16
|
|
18
17
|
context "when nf-e's version is 2.00" do
|
@@ -49,11 +48,11 @@ describe BrDanfe::DanfeLib::Dest do
|
|
49
48
|
end
|
50
49
|
|
51
50
|
it "renders xml to the pdf" do
|
52
|
-
expect(File.exist?(
|
51
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
53
52
|
|
54
|
-
pdf.render_file
|
53
|
+
pdf.render_file path_of_expected_pdf
|
55
54
|
|
56
|
-
expect("
|
55
|
+
expect("./spec/fixtures/nfe/lib/dest#render-v2.00.pdf").to have_same_content_of file: path_of_expected_pdf
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
@@ -90,11 +89,52 @@ describe BrDanfe::DanfeLib::Dest do
|
|
90
89
|
end
|
91
90
|
|
92
91
|
it "renders xml to the pdf" do
|
93
|
-
expect(File.exist?(
|
92
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
94
93
|
|
95
|
-
pdf.render_file
|
94
|
+
pdf.render_file path_of_expected_pdf
|
96
95
|
|
97
|
-
expect("
|
96
|
+
expect("./spec/fixtures/nfe/lib/dest#render-v3.10.pdf").to have_same_content_of file: path_of_expected_pdf
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when nf-e's version is 4.00" do
|
101
|
+
let(:xml_as_string) do
|
102
|
+
<<-eos
|
103
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
104
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="4.00">
|
105
|
+
<ide>
|
106
|
+
<dhEmi>2018-07-30T13:30:59+00:00</dhEmi>
|
107
|
+
<dhSaiEnt>2018-07-30T14:32:45-03:00</dhSaiEnt>
|
108
|
+
</ide>
|
109
|
+
<dest>
|
110
|
+
<CNPJ>82743287000880</CNPJ>
|
111
|
+
<xNome>Schneider Electric Brasil Ltda</xNome>
|
112
|
+
<enderDest>
|
113
|
+
<xLgr>Av da Saudade</xLgr>
|
114
|
+
<nro>1125</nro>
|
115
|
+
<xBairro>Frutal</xBairro>
|
116
|
+
<xCpl>Sala 01 e 02</xCpl>
|
117
|
+
<cMun>3552403</cMun>
|
118
|
+
<xMun>SUMARE</xMun>
|
119
|
+
<UF>SP</UF>
|
120
|
+
<CEP>13171320</CEP>
|
121
|
+
<cPais>1058</cPais>
|
122
|
+
<xPais>BRASIL</xPais>
|
123
|
+
<fone>1921046300</fone>
|
124
|
+
</enderDest>
|
125
|
+
<IE>671008375110</IE>
|
126
|
+
</dest>
|
127
|
+
</infNFe>
|
128
|
+
</NFe>
|
129
|
+
eos
|
130
|
+
end
|
131
|
+
|
132
|
+
it "renders xml to the pdf" do
|
133
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
134
|
+
|
135
|
+
pdf.render_file path_of_expected_pdf
|
136
|
+
|
137
|
+
expect("./spec/fixtures/nfe/lib/dest#render-v4.00.pdf").to have_same_content_of file: path_of_expected_pdf
|
98
138
|
end
|
99
139
|
end
|
100
140
|
|
@@ -112,11 +152,11 @@ describe BrDanfe::DanfeLib::Dest do
|
|
112
152
|
end
|
113
153
|
|
114
154
|
it "renders xml to the pdf" do
|
115
|
-
expect(File.exist?(
|
155
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
116
156
|
|
117
|
-
pdf.render_file
|
157
|
+
pdf.render_file path_of_expected_pdf
|
118
158
|
|
119
|
-
expect("
|
159
|
+
expect("./spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf").to have_same_content_of file: path_of_expected_pdf
|
120
160
|
end
|
121
161
|
end
|
122
162
|
|
@@ -134,11 +174,11 @@ describe BrDanfe::DanfeLib::Dest do
|
|
134
174
|
end
|
135
175
|
|
136
176
|
it "renders xml to the pdf" do
|
137
|
-
expect(File.exist?(
|
177
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
138
178
|
|
139
|
-
pdf.render_file
|
179
|
+
pdf.render_file path_of_expected_pdf
|
140
180
|
|
141
|
-
expect("
|
181
|
+
expect("./spec/fixtures/nfe/lib/dest#render-with_cpf.pdf").to have_same_content_of file: path_of_expected_pdf
|
142
182
|
end
|
143
183
|
end
|
144
184
|
|
@@ -159,11 +199,11 @@ describe BrDanfe::DanfeLib::Dest do
|
|
159
199
|
end
|
160
200
|
|
161
201
|
it "renders xml to the pdf" do
|
162
|
-
expect(File.exist?(
|
202
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
163
203
|
|
164
|
-
pdf.render_file
|
204
|
+
pdf.render_file path_of_expected_pdf
|
165
205
|
|
166
|
-
expect("
|
206
|
+
expect("./spec/fixtures/nfe/lib/dest#render-with_ie.pdf").to have_same_content_of file: path_of_expected_pdf
|
167
207
|
end
|
168
208
|
end
|
169
209
|
|
@@ -199,11 +239,12 @@ describe BrDanfe::DanfeLib::Dest do
|
|
199
239
|
end
|
200
240
|
|
201
241
|
it "renders xml to the pdf" do
|
202
|
-
expect(File.exist?(
|
242
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
203
243
|
|
204
|
-
pdf.render_file
|
244
|
+
pdf.render_file path_of_expected_pdf
|
205
245
|
|
206
|
-
expect("
|
246
|
+
expect("./spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf")
|
247
|
+
.to have_same_content_of file: path_of_expected_pdf
|
207
248
|
end
|
208
249
|
end
|
209
250
|
|
@@ -239,12 +280,13 @@ describe BrDanfe::DanfeLib::Dest do
|
|
239
280
|
eos
|
240
281
|
end
|
241
282
|
|
242
|
-
it "
|
243
|
-
expect(File.exist?(
|
283
|
+
it "renders xml to pdf discarding the address of after 63 characters" do
|
284
|
+
expect(File.exist?(path_of_expected_pdf)).to eql false
|
244
285
|
|
245
|
-
pdf.render_file
|
286
|
+
pdf.render_file path_of_expected_pdf
|
246
287
|
|
247
|
-
expect("
|
288
|
+
expect("./spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf")
|
289
|
+
.to have_same_content_of file: path_of_expected_pdf
|
248
290
|
end
|
249
291
|
end
|
250
292
|
end
|
@@ -3,8 +3,8 @@ require "spec_helper"
|
|
3
3
|
describe BrDanfe::DanfeLib::XML do
|
4
4
|
subject { BrDanfe::DanfeLib::XML.new(xml_as_string) }
|
5
5
|
|
6
|
-
describe "#
|
7
|
-
describe "when xml's version is 3.10" do
|
6
|
+
describe "#version_is_310_or_newer?" do
|
7
|
+
describe "when xml's version is equal 3.10" do
|
8
8
|
let(:xml_as_string) do
|
9
9
|
<<-eos
|
10
10
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -14,12 +14,27 @@ describe BrDanfe::DanfeLib::XML do
|
|
14
14
|
eos
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
expect(subject.
|
17
|
+
it "returns true" do
|
18
|
+
expect(subject.version_is_310_or_newer?).to eql true
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe "when xml's version
|
22
|
+
describe "when xml's version is greather 3.10" do
|
23
|
+
let(:xml_as_string) do
|
24
|
+
<<-eos
|
25
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
26
|
+
<infNFe versao="4.00" Id="NFe35150162013294000143550010000000011000000017">
|
27
|
+
</infNFe>
|
28
|
+
</NFe>
|
29
|
+
eos
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns true" do
|
33
|
+
expect(subject.version_is_310_or_newer?).to eql true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "when xml's version is minor that 3.10" do
|
23
38
|
let(:xml_as_string) do
|
24
39
|
<<-eos
|
25
40
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
@@ -29,8 +44,8 @@ describe BrDanfe::DanfeLib::XML do
|
|
29
44
|
eos
|
30
45
|
end
|
31
46
|
|
32
|
-
it "
|
33
|
-
expect(subject.
|
47
|
+
it "returns false" do
|
48
|
+
expect(subject.version_is_310_or_newer?).to eql false
|
34
49
|
end
|
35
50
|
end
|
36
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: br_danfe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ASSEINFO
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -220,6 +220,7 @@ files:
|
|
220
220
|
- spec/fixtures/logo.png
|
221
221
|
- spec/fixtures/nfe/lib/dest#render-v2.00.pdf
|
222
222
|
- spec/fixtures/nfe/lib/dest#render-v3.10.pdf
|
223
|
+
- spec/fixtures/nfe/lib/dest#render-v4.00.pdf
|
223
224
|
- spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf
|
224
225
|
- spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf
|
225
226
|
- spec/fixtures/nfe/lib/dest#render-with_cpf.pdf
|
@@ -336,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
337
|
version: '0'
|
337
338
|
requirements: []
|
338
339
|
rubyforge_project:
|
339
|
-
rubygems_version: 2.4.
|
340
|
+
rubygems_version: 2.4.5.1
|
340
341
|
signing_key:
|
341
342
|
specification_version: 4
|
342
343
|
summary: DANFE pdf generator for Brazilian invoices.
|
@@ -361,6 +362,7 @@ test_files:
|
|
361
362
|
- spec/fixtures/logo.png
|
362
363
|
- spec/fixtures/nfe/lib/dest#render-v2.00.pdf
|
363
364
|
- spec/fixtures/nfe/lib/dest#render-v3.10.pdf
|
365
|
+
- spec/fixtures/nfe/lib/dest#render-v4.00.pdf
|
364
366
|
- spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf
|
365
367
|
- spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf
|
366
368
|
- spec/fixtures/nfe/lib/dest#render-with_cpf.pdf
|