br_danfe 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 276ea31f2d3b21b2183aa5ea35e67f639822f0b1
4
- data.tar.gz: 4cdfea1190a2dba3b7525e91c04dcb6273be0bf6
3
+ metadata.gz: ba0be0232ce7c32209b3efcf97e13e9ad7a8826d
4
+ data.tar.gz: d12d50a599043e9cc1297ffba185ab19554775b4
5
5
  SHA512:
6
- metadata.gz: b6a5b46f1680a691414ed2145be1ee559a5f42e2f51eafb4fefc3683bd6f67df9eb991ab403cc21afc013290f8c01bb4f64afeeb91af08fe732c1494ba4641fe
7
- data.tar.gz: 8e800c08ee1eb190f98aae50ba10d2e5c854cc85a8e3ee7f516af7d15e5e2f3c7c927b5cefc9e4b59486d2619b6b260dee90293e81bbcfca5a2abe6a22d37123
6
+ metadata.gz: b2eb27d0c88590cb39c4124c52f874f16f52a2700e4f2ee0adfc549293c88714ad19d04d02b269afa954ba7a8d4b0d31bd49b1d6283c1e1ee28e36b9e1a987ed
7
+ data.tar.gz: a103bf1225b7e26d541fece0bd3c7b47a8ffbe33a1549242bca9e472a45ebec01753aea3982cce03b943cf7e49a1aab87640423a77586761b5a39663a60a431f
data/Dockerfile CHANGED
@@ -13,7 +13,7 @@ ADD ./lib/br_danfe/version.rb ./lib/br_danfe/version.rb
13
13
  ADD ./br_danfe.gemspec ./br_danfe.gemspec
14
14
  ADD ./Gemfile ./Gemfile
15
15
 
16
- RUN bundle
16
+ RUN bundle install
17
17
 
18
18
  # LINK SOURCE
19
19
  ADD ./ ./
data/Gemfile CHANGED
@@ -3,4 +3,6 @@ ruby "2.2.5"
3
3
 
4
4
  gemspec
5
5
 
6
- gem "rake"
6
+ gem "rake", "12.0.0"
7
+ gem "simplecov", "0.11.1", group: :test
8
+ gem "simplecov-html", "0.10.1", group: :test
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.7.0)
4
+ br_danfe (0.7.1)
5
5
  barby (= 0.5.1)
6
6
  br_documents (>= 0.0.8)
7
7
  i18n
@@ -12,9 +12,9 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activemodel (5.1.1)
16
- activesupport (= 5.1.1)
17
- activesupport (5.1.1)
15
+ activemodel (5.1.4)
16
+ activesupport (= 5.1.4)
17
+ activesupport (5.1.4)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (~> 0.7)
20
20
  minitest (~> 5.1)
@@ -34,12 +34,12 @@ GEM
34
34
  debugger-linecache (1.2.0)
35
35
  diff-lcs (1.3)
36
36
  docile (1.1.5)
37
- i18n (0.8.1)
37
+ i18n (0.8.6)
38
38
  json (1.8.6)
39
- mini_portile2 (2.1.0)
40
- minitest (5.10.2)
41
- nokogiri (1.7.2)
42
- mini_portile2 (~> 2.1.0)
39
+ mini_portile2 (2.3.0)
40
+ minitest (5.10.3)
41
+ nokogiri (1.8.1)
42
+ mini_portile2 (~> 2.3.0)
43
43
  pdf-core (0.6.1)
44
44
  prawn (2.1.0)
45
45
  pdf-core (~> 0.6.1)
@@ -78,12 +78,13 @@ DEPENDENCIES
78
78
  br_danfe!
79
79
  byebug (= 3.5.1)
80
80
  codeclimate-test-reporter
81
- rake
81
+ rake (= 12.0.0)
82
82
  rspec (>= 3.0.0)
83
83
  simplecov (= 0.11.1)
84
+ simplecov-html (= 0.10.1)
84
85
 
85
86
  RUBY VERSION
86
87
  ruby 2.2.5p319
87
88
 
88
89
  BUNDLED WITH
89
- 1.13.6
90
+ 1.15.3
data/README.md CHANGED
@@ -91,7 +91,7 @@ You needs to build docker container like above:
91
91
 
92
92
  You can run all RSpec specs using:
93
93
 
94
- $ docker-compose run br_danfe rspec
94
+ $ docker-compose run --rm br_danfe rspec
95
95
 
96
96
 
97
97
  ## Development - Without Docker
@@ -2,6 +2,7 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  class Dest
4
4
  Y = 10.00
5
+ MAXIMUM_SIZE_FOR_STREET = 319
5
6
 
6
7
  def initialize(pdf, xml)
7
8
  @pdf = pdf
@@ -43,13 +44,21 @@ module BrDanfe
43
44
  end
44
45
 
45
46
  def render_line2
46
- @pdf.i18n_lbox LINE_HEIGHT, 9.66, 0.75, @l2, "enderDest.xLgr", street
47
+ @pdf.i18n_lbox LINE_HEIGHT, 9.66, 0.75, @l2, "enderDest.xLgr", address
47
48
  @pdf.lbox LINE_HEIGHT, 4.33, 10.41, @l2, @xml, "enderDest/xBairro"
48
49
  @pdf.i18n_lbox LINE_HEIGHT, 2.20, 14.74, @l2, "enderDest.CEP", cep
49
50
  end
50
51
 
51
- def street
52
- @xml["enderDest/xLgr"] + " " + @xml["enderDest/nro"]
52
+ def address
53
+ address = Helper.generate_address @xml
54
+
55
+ if Helper.address_is_too_big(@pdf, address)
56
+ while Helper.mensure_text(@pdf, "#{address.strip}...") > MAXIMUM_SIZE_FOR_STREET && address.length > 0 do
57
+ address = address[0..address.length-2]
58
+ end
59
+ address = "#{address.strip}..."
60
+ end
61
+ address
53
62
  end
54
63
 
55
64
  def cep
@@ -66,11 +75,11 @@ module BrDanfe
66
75
  def render_dates_block
67
76
 
68
77
  if @xml.version_310?
69
- dEmi = "ide/dhEmi"
78
+ dEmi = "ide/dhEmi"
70
79
  dSaiEnt = "ide/dhSaiEnt"
71
80
  hSaiEnt = "ide/dhSaiEnt"
72
81
  else
73
- dEmi = "ide/dEmi"
82
+ dEmi = "ide/dEmi"
74
83
  dSaiEnt = "ide/dSaiEnt"
75
84
  hSaiEnt = "ide/hSaiEnt"
76
85
  end
@@ -55,14 +55,33 @@ module BrDanfe
55
55
  homologation?(xml) || unauthorized?(xml)
56
56
  end
57
57
 
58
- private
59
58
  def self.homologation?(xml)
60
- xml.css("nfeProc/NFe/infNFe/ide/tpAmb").text == "2"
59
+ xml_text(xml, "nfeProc/NFe/infNFe/ide/tpAmb") == "2"
61
60
  end
62
61
 
63
62
  def self.unauthorized?(xml)
64
63
  xml.css("nfeProc/protNFe/infProt/dhRecbto").empty?
65
64
  end
65
+
66
+ def self.mensure_text(pdf, text)
67
+ pdf.width_of(text)
68
+ end
69
+
70
+ def self.address_is_too_big(pdf, address)
71
+ Helper.mensure_text(pdf, address) > Dest::MAXIMUM_SIZE_FOR_STREET
72
+ end
73
+
74
+ def self.generate_address(xml)
75
+ address_complement = " - #{xml_text(xml, "enderDest/xCpl")}" if xml_text(xml, "enderDest/xCpl").present?
76
+ address_number = " #{xml_text(xml, "enderDest/nro")}" if xml_text(xml, "enderDest/nro").present?
77
+ "#{xml_text(xml, "enderDest/xLgr")}#{address_number}#{address_complement}"
78
+ end
79
+
80
+ def self.xml_text(xml, property)
81
+ xml.css(property).text
82
+ end
83
+
84
+ private_class_method :xml_text
66
85
  end
67
86
  end
68
87
  end
@@ -19,7 +19,9 @@ module BrDanfe
19
19
  elsif difal?
20
20
  render_difal
21
21
  else
22
- @pdf.ibox 2.65, 12.45, 0.75, @y_position, I18n.t("danfe.infAdic.infCpl"), @xml["infAdic/infCpl"], { size: 6, valign: :top }
22
+ title = I18n.t "danfe.infAdic.infCpl"
23
+ observation = generate_observation @xml["infAdic/infCpl"]
24
+ @pdf.ibox 2.65, 12.45, 0.75, @y_position, title, observation, { size: 6, valign: :top }
23
25
  end
24
26
 
25
27
  @pdf.ibox 2.65, 7.15, 13.20, @y_position, I18n.t("danfe.infAdic.reserved")
@@ -119,6 +121,17 @@ module BrDanfe
119
121
 
120
122
  render_info_cpl_with_others y
121
123
  end
124
+
125
+ def generate_observation(informations)
126
+ observation = informations
127
+
128
+ address = Helper.generate_address @xml
129
+ if Helper.address_is_too_big @pdf, address
130
+ observation = "#{observation} * Endereço: #{address}"
131
+ end
132
+
133
+ observation
134
+ end
122
135
  end
123
136
  end
124
137
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
@@ -17,7 +17,7 @@ endobj
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 2421
20
+ << /Length 2451
21
21
  >>
22
22
  stream
23
23
  q
@@ -74,7 +74,7 @@ ET
74
74
  BT
75
75
  23.2598 551.918 Td
76
76
  /F1.0 10 Tf
77
- [<41> 74 <7620646120536175646164652031313235>] TJ
77
+ [<41> 74 <7620646120536175646164652031313235202d2053616c612030312065203032>] TJ
78
78
  ET
79
79
 
80
80
  295.0866 549.0709 122.7402 22.6772 re
@@ -258,14 +258,14 @@ xref
258
258
  0000000109 00000 n
259
259
  0000000158 00000 n
260
260
  0000000215 00000 n
261
- 0000002688 00000 n
262
- 0000002880 00000 n
263
- 0000002978 00000 n
261
+ 0000002718 00000 n
262
+ 0000002910 00000 n
263
+ 0000003008 00000 n
264
264
  trailer
265
265
  << /Size 8
266
266
  /Root 2 0 R
267
267
  /Info 1 0 R
268
268
  >>
269
269
  startxref
270
- 3077
270
+ 3107
271
271
  %%EOF
@@ -17,7 +17,7 @@ endobj
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 2421
20
+ << /Length 2451
21
21
  >>
22
22
  stream
23
23
  q
@@ -74,7 +74,7 @@ ET
74
74
  BT
75
75
  23.2598 551.918 Td
76
76
  /F1.0 10 Tf
77
- [<41> 74 <7620646120536175646164652031313235>] TJ
77
+ [<41> 74 <7620646120536175646164652031313235202d2053616c612030312065203032>] TJ
78
78
  ET
79
79
 
80
80
  295.0866 549.0709 122.7402 22.6772 re
@@ -258,14 +258,14 @@ xref
258
258
  0000000109 00000 n
259
259
  0000000158 00000 n
260
260
  0000000215 00000 n
261
- 0000002688 00000 n
262
- 0000002880 00000 n
263
- 0000002978 00000 n
261
+ 0000002718 00000 n
262
+ 0000002910 00000 n
263
+ 0000003008 00000 n
264
264
  trailer
265
265
  << /Size 8
266
266
  /Root 2 0 R
267
267
  /Info 1 0 R
268
268
  >>
269
269
  startxref
270
- 3077
270
+ 3107
271
271
  %%EOF
@@ -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 2517
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
+ [<52756120646f20676f> 15 <76> 15 <65726e6f20646f2065737461646f2031313235202d20456d20616e65> 15 <786f20616f207375706572206d65726361646f2e2e2e>] 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
+ [<32392f31302f32303131>] 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
+ [<33302f31302f32303131>] 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
+ [<31333a33323a3435>] 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
+ 0000002784 00000 n
262
+ 0000002976 00000 n
263
+ 0000003074 00000 n
264
+ trailer
265
+ << /Size 8
266
+ /Root 2 0 R
267
+ /Info 1 0 R
268
+ >>
269
+ startxref
270
+ 3173
271
+ %%EOF
@@ -17,7 +17,7 @@ endobj
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 1678
20
+ << /Length 1631
21
21
  >>
22
22
  stream
23
23
  q
@@ -63,13 +63,6 @@ BT
63
63
  [<454e44455245c74f>] TJ
64
64
  ET
65
65
 
66
-
67
- BT
68
- 23.2598 551.918 Td
69
- /F1.0 10 Tf
70
- [<>] TJ
71
- ET
72
-
73
66
  295.0866 549.0709 122.7402 22.6772 re
74
67
  S
75
68
 
@@ -188,14 +181,14 @@ xref
188
181
  0000000109 00000 n
189
182
  0000000158 00000 n
190
183
  0000000215 00000 n
191
- 0000001945 00000 n
192
- 0000002137 00000 n
193
- 0000002235 00000 n
184
+ 0000001898 00000 n
185
+ 0000002090 00000 n
186
+ 0000002188 00000 n
194
187
  trailer
195
188
  << /Size 8
196
189
  /Root 2 0 R
197
190
  /Info 1 0 R
198
191
  >>
199
192
  startxref
200
- 2334
193
+ 2287
201
194
  %%EOF
@@ -17,7 +17,7 @@ endobj
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 1670
20
+ << /Length 1623
21
21
  >>
22
22
  stream
23
23
  q
@@ -63,13 +63,6 @@ BT
63
63
  [<454e44455245c74f>] TJ
64
64
  ET
65
65
 
66
-
67
- BT
68
- 23.2598 551.918 Td
69
- /F1.0 10 Tf
70
- [<>] TJ
71
- ET
72
-
73
66
  295.0866 549.0709 122.7402 22.6772 re
74
67
  S
75
68
 
@@ -188,14 +181,14 @@ xref
188
181
  0000000109 00000 n
189
182
  0000000158 00000 n
190
183
  0000000215 00000 n
191
- 0000001937 00000 n
192
- 0000002129 00000 n
193
- 0000002227 00000 n
184
+ 0000001890 00000 n
185
+ 0000002082 00000 n
186
+ 0000002180 00000 n
194
187
  trailer
195
188
  << /Size 8
196
189
  /Root 2 0 R
197
190
  /Info 1 0 R
198
191
  >>
199
192
  startxref
200
- 2326
193
+ 2279
201
194
  %%EOF
@@ -17,7 +17,7 @@ endobj
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 1726
20
+ << /Length 1679
21
21
  >>
22
22
  stream
23
23
  q
@@ -56,13 +56,6 @@ BT
56
56
  [<454e44455245c74f>] TJ
57
57
  ET
58
58
 
59
-
60
- BT
61
- 23.2598 551.918 Td
62
- /F1.0 10 Tf
63
- [<>] TJ
64
- ET
65
-
66
59
  295.0866 549.0709 122.7402 22.6772 re
67
60
  S
68
61
 
@@ -195,14 +188,14 @@ xref
195
188
  0000000109 00000 n
196
189
  0000000158 00000 n
197
190
  0000000215 00000 n
198
- 0000001993 00000 n
199
- 0000002185 00000 n
200
- 0000002283 00000 n
191
+ 0000001946 00000 n
192
+ 0000002138 00000 n
193
+ 0000002236 00000 n
201
194
  trailer
202
195
  << /Size 8
203
196
  /Root 2 0 R
204
197
  /Info 1 0 R
205
198
  >>
206
199
  startxref
207
- 2382
200
+ 2335
208
201
  %%EOF