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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -1
  3. data/Gemfile.lock +21 -19
  4. data/br_danfe.gemspec +4 -4
  5. data/config/locales/pt-BR.yml +15 -0
  6. data/lib/br_danfe/danfe_lib/nfe.rb +5 -3
  7. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +1 -1
  8. data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +6 -1
  9. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +8 -4
  10. data/lib/br_danfe/danfe_lib/nfe_lib/entrega.rb +86 -0
  11. data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +4 -4
  12. data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +8 -4
  13. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +3 -19
  14. data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +4 -2
  15. data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +8 -4
  16. data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +6 -2
  17. data/lib/br_danfe/logo_config.rb +4 -15
  18. data/lib/br_danfe/version.rb +1 -1
  19. data/lib/br_danfe.rb +0 -1
  20. data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +73 -0
  21. data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +50 -0
  22. data/spec/br_danfe/danfe_lib/nfe_lib/entrega_spec.rb +186 -0
  23. data/spec/br_danfe/danfe_lib/nfe_lib/helper_spec.rb +23 -4
  24. data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +46 -0
  25. data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +0 -41
  26. data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +49 -0
  27. data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +49 -0
  28. data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +59 -0
  29. data/spec/br_danfe/danfe_lib/nfe_spec.rb +11 -0
  30. data/spec/br_danfe/logo_config_spec.rb +6 -8
  31. data/spec/fixtures/nfe/lib/det_body#render-with_entrega.pdf +1110 -0
  32. data/spec/fixtures/nfe/lib/dup#render-with_entrega.pdf +0 -0
  33. data/spec/fixtures/nfe/lib/entrega#render-v2.00.pdf +0 -0
  34. data/spec/fixtures/nfe/lib/entrega#render-with-address-bigger.pdf +0 -0
  35. data/spec/fixtures/nfe/lib/entrega#render-with_cpf.pdf +0 -0
  36. data/spec/fixtures/nfe/lib/entrega#render-without-address-complement.pdf +0 -0
  37. data/spec/fixtures/nfe/lib/icmstot#render-with_entrega.pdf +0 -0
  38. data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +0 -0
  39. data/spec/fixtures/nfe/lib/issqn#render-with_entrega.pdf +0 -0
  40. data/spec/fixtures/nfe/lib/transp#render-with_entrega.pdf +0 -0
  41. data/spec/fixtures/nfe/lib/vol#render-with_entrega.pdf +0 -0
  42. data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml +260 -0
  43. data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml.fixture.pdf +3413 -0
  44. metadata +28 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ff71167a3eb755f223971cd4e639361ba416e51a0245381e4f0b5e0a2b64878
4
- data.tar.gz: 16243ab217adae707316aec6a81e922d1ed3c6f85b7f8dd43bf65bc2fbbd6086
3
+ metadata.gz: 345273bdb39c1d133110285def88a0dcae14df47b6e1b8fcd6085ab753d3898e
4
+ data.tar.gz: 2d24c830171df9dd03b4870e96704385a809d240ae7abcb3b4c0adc31673a2dd
5
5
  SHA512:
6
- metadata.gz: 10ac20074cc7091870c0b89dc4a5e15d4140b53a28a23add7b202db90cfc6588071202a79a21e06a6a61979acc9c7903fa87f4d87dc706080945415917fad9b7
7
- data.tar.gz: e124c2b1aef7685495600810dccf0f166e921749349a18a023e25d514d1721c29347fddd0c9f5df3bef3f91e8da52b226ec4c265ab6017ee2ee07cca45a611d3
6
+ metadata.gz: '08340f8602de112ea5260412165d3481f7a1122074093f30e505afacda6fbbdab1ccd43fdddffc606c60b546311ff89f92d08f20abc204832f33e95f702364fd'
7
+ data.tar.gz: 9ad4f2ed6707f8b4d486f4f8d78fb1cb4d251ae0b2b867c4cb760050343a491633ec5b59751d469e7eb7189feff096fd33e65f04a93afc334fdf64778ef3d9ee
data/.codeclimate.yml CHANGED
@@ -14,7 +14,7 @@ engines:
14
14
  enabled: true
15
15
  rubocop:
16
16
  enabled: true
17
- channel: rubocop-0-67-0
17
+ channel: rubocop-0-92
18
18
  ratings:
19
19
  paths:
20
20
  - Gemfile.lock
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.19.0)
5
- barby (= 0.6.8)
4
+ br_danfe (1.0.0)
5
+ barby (= 0.6.9)
6
6
  br_documents (>= 0.1.3)
7
7
  i18n (>= 0.8.6)
8
8
  nokogiri (>= 1.8)
@@ -28,7 +28,7 @@ GEM
28
28
  tzinfo (~> 2.0)
29
29
  afm (0.2.2)
30
30
  ast (2.4.2)
31
- barby (0.6.8)
31
+ barby (0.6.9)
32
32
  base64 (0.2.0)
33
33
  bigdecimal (3.1.6)
34
34
  br_documents (0.2.5)
@@ -37,10 +37,10 @@ GEM
37
37
  byebug (11.1.3)
38
38
  chunky_png (1.4.0)
39
39
  coderay (1.1.3)
40
- concurrent-ruby (1.2.3)
40
+ concurrent-ruby (1.3.1)
41
41
  connection_pool (2.4.1)
42
42
  diff-lcs (1.5.1)
43
- docile (1.4.0)
43
+ docile (1.4.1)
44
44
  drb (2.2.0)
45
45
  ruby2_keywords
46
46
  ffi (1.16.3)
@@ -60,19 +60,18 @@ GEM
60
60
  guard-compat (~> 1.1)
61
61
  rspec (>= 2.99.0, < 4.0)
62
62
  hashery (2.1.2)
63
- i18n (1.14.1)
63
+ i18n (1.14.5)
64
64
  concurrent-ruby (~> 1.0)
65
- json (2.5.1)
66
65
  listen (3.8.0)
67
66
  rb-fsevent (~> 0.10, >= 0.10.3)
68
67
  rb-inotify (~> 0.9, >= 0.9.10)
69
68
  lumberjack (1.2.10)
70
69
  method_source (1.0.0)
71
- mini_portile2 (2.8.5)
70
+ mini_portile2 (2.8.7)
72
71
  minitest (5.21.2)
73
72
  mutex_m (0.2.0)
74
73
  nenv (0.3.0)
75
- nokogiri (1.16.0)
74
+ nokogiri (1.16.7)
76
75
  mini_portile2 (~> 2.8.2)
77
76
  racc (~> 1.4)
78
77
  notiffany (0.1.3)
@@ -98,14 +97,15 @@ GEM
98
97
  pry (0.14.2)
99
98
  coderay (~> 1.1)
100
99
  method_source (~> 1.0)
101
- racc (1.7.3)
100
+ racc (1.8.1)
102
101
  rainbow (3.0.0)
103
- rake (13.1.0)
102
+ rake (13.2.1)
104
103
  rb-fsevent (0.11.2)
105
104
  rb-inotify (0.10.1)
106
105
  ffi (~> 1.0)
107
106
  regexp_parser (2.1.1)
108
- rexml (3.2.5)
107
+ rexml (3.3.3)
108
+ strscan
109
109
  rqrcode (2.2.0)
110
110
  chunky_png (~> 1.0)
111
111
  rqrcode_core (~> 1.0)
@@ -144,11 +144,13 @@ GEM
144
144
  ruby-rc4 (0.1.5)
145
145
  ruby2_keywords (0.0.5)
146
146
  shellany (0.0.1)
147
- simplecov (0.17.1)
147
+ simplecov (0.22.0)
148
148
  docile (~> 1.1)
149
- json (>= 1.8, < 3)
150
- simplecov-html (~> 0.10.0)
151
- simplecov-html (0.10.2)
149
+ simplecov-html (~> 0.11)
150
+ simplecov_json_formatter (~> 0.1)
151
+ simplecov-html (0.12.3)
152
+ simplecov_json_formatter (0.1.4)
153
+ strscan (3.1.0)
152
154
  thor (1.3.0)
153
155
  ttfunk (1.7.0)
154
156
  tzinfo (2.0.6)
@@ -164,13 +166,13 @@ DEPENDENCIES
164
166
  guard (~> 2.18.1)
165
167
  guard-rspec (~> 4.7.3)
166
168
  pdf-inspector (~> 1.3.0)
167
- rake (= 13.1.0)
169
+ rake (= 13.2.1)
168
170
  rspec (= 3.13.0)
169
171
  rubocop (~> 0.93.1)
170
172
  rubocop-performance (~> 1.10.2)
171
173
  rubocop-rspec (~> 1.44.1)
172
- simplecov (= 0.17.1)
173
- simplecov-html (= 0.10.2)
174
+ simplecov (= 0.22.0)
175
+ simplecov-html (= 0.12.3)
174
176
 
175
177
  BUNDLED WITH
176
178
  2.5.5
data/br_danfe.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.require_paths = ['lib']
17
17
  spec.required_ruby_version = '>= 3.0'
18
18
 
19
- spec.add_dependency 'barby', '0.6.8'
19
+ spec.add_dependency 'barby', '0.6.9'
20
20
  spec.add_dependency 'br_documents', '>= 0.1.3'
21
21
  spec.add_dependency 'i18n', '>= 0.8.6'
22
22
  spec.add_dependency 'nokogiri', '>= 1.8'
@@ -28,11 +28,11 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'guard', '~> 2.18.1'
29
29
  spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
30
30
  spec.add_development_dependency 'pdf-inspector', '~> 1.3.0'
31
- spec.add_development_dependency 'rake', '13.1.0'
31
+ spec.add_development_dependency 'rake', '13.2.1'
32
32
  spec.add_development_dependency 'rspec', '3.13.0'
33
33
  spec.add_development_dependency 'rubocop', '~> 0.93.1'
34
34
  spec.add_development_dependency 'rubocop-performance', '~> 1.10.2'
35
35
  spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
36
- spec.add_development_dependency 'simplecov', '0.17.1'
37
- spec.add_development_dependency 'simplecov-html', '0.10.2'
36
+ spec.add_development_dependency 'simplecov', '0.22.0'
37
+ spec.add_development_dependency 'simplecov-html', '0.12.3'
38
38
  end
@@ -144,6 +144,21 @@ pt-BR:
144
144
  received_at: "DATA DE RECEBIMENTO"
145
145
  receiver: "IDENTIFICAÇÃO E ASSINATURA DO RECEBEDOR"
146
146
  document: "NF-e\nN°. %{nNF}\nSÉRIE %{serie}"
147
+ entrega:
148
+ title: "INFORMAÇÕES DO LOCAL DE ENTREGA"
149
+ CNPJ: "CNPJ"
150
+ CPF: "CPF"
151
+ xNome: "NOME/RAZÃO SOCIAL"
152
+ xLgr: "ENDEREÇO"
153
+ nro: "NÚMERO"
154
+ xCpl: "COMPLEMENTO"
155
+ xBairro: "BAIRRO"
156
+ cMun: "CÓDIGO DE MUNICÍPIO"
157
+ xMun: "MUNICÍPIO"
158
+ UF: "UF"
159
+ CEP: "CEP"
160
+ fone: "FONE/FAX"
161
+ IE: "INSCRIÇÃO ESTADUAL"
147
162
  nfce:
148
163
  payment_methods:
149
164
  '01': "Dinheiro"
@@ -42,6 +42,7 @@ module BrDanfe
42
42
  def render_on_first_page(xml)
43
43
  NfeLib::Ticket.new(@document, xml).render
44
44
  NfeLib::Dest.new(@document, xml).render
45
+ NfeLib::Entrega.new(@document, xml).render
45
46
  NfeLib::Dup.new(@document, xml).render
46
47
  NfeLib::Icmstot.new(@document, xml).render
47
48
  NfeLib::Transp.new(@document, xml).render
@@ -73,13 +74,14 @@ module BrDanfe
73
74
  @document.go_to_page(page)
74
75
 
75
76
  emitter.render(initial_page_of_pdf, y_position, total_pages)
76
- render_product_table_title initial_page_of_pdf
77
+ render_product_table_title initial_page_of_pdf, xml
77
78
  render_footer_information footer_info
78
79
  render_no_fiscal_value(xml)
79
80
  end
80
81
 
81
- def render_product_table_title(page)
82
- y_position = page == 1 ? 18.91 : 7.40
82
+ def render_product_table_title(page, xml)
83
+ y_position = NfeLib::Entrega.delivery_local?(xml) && page == 1 ? 3.00 : 0
84
+ y_position += page == 1 ? 18.91 : 7.40
83
85
  @document.ititle 0.42, 10.00, 0.75, y_position, 'det.title'
84
86
  end
85
87
 
@@ -53,7 +53,7 @@ module BrDanfe
53
53
  end
54
54
 
55
55
  def address
56
- address = Helper.generate_address @xml
56
+ address = Helper.generate_address @xml, 'enderDest'
57
57
 
58
58
  if Helper.address_is_too_big(@pdf, address)
59
59
  address = address[0..address.length - 2] while Helper.mensure_text(@pdf, "#{address.strip}...") > MAXIMUM_SIZE_FOR_STREET && !address.empty?
@@ -2,9 +2,13 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class DetBody
5
+ attr_reader :y_position_with_entrega
6
+
5
7
  def initialize(pdf, xml)
6
8
  @pdf = pdf
7
9
  @xml = xml
10
+
11
+ @y_position_with_entrega = Entrega.delivery_local?(@xml) ? 3.00 : 0.00
8
12
  end
9
13
 
10
14
  def render(has_issqn)
@@ -121,7 +125,8 @@ module BrDanfe
121
125
  end
122
126
 
123
127
  def table_position_on_first_page
124
- Helper.invert(18.07.cm)
128
+ y_position = @y_position_with_entrega.cm + 18.07.cm
129
+ Helper.invert(y_position)
125
130
  end
126
131
 
127
132
  def table_position_on_next_pages
@@ -2,21 +2,25 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class Dup
5
- Y = 12.92
5
+ attr_reader :y_position
6
+
7
+ Y_POSITION = 12.92
6
8
 
7
9
  def initialize(pdf, xml)
8
10
  @pdf = pdf
9
11
  @xml = xml
10
12
 
11
- @ltitle = Y - 0.42
13
+ @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
14
+
15
+ @ltitle = @y_position - 0.42
12
16
  end
13
17
 
14
18
  def render
15
19
  @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'dup.title'
16
- @pdf.ibox 0.85, 19.57, 0.75, Y
20
+ @pdf.ibox 0.85, 19.57, 0.75, @y_position
17
21
 
18
22
  x = 0.75
19
- y = Y
23
+ y = @y_position
20
24
  @xml.collect('xmlns', 'dup') do |det|
21
25
  render_dup(det, x, y)
22
26
  x += 2.30
@@ -0,0 +1,86 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfeLib
4
+ class Entrega
5
+ Y_POSITION = 12.92
6
+ MAXIMUM_SIZE_FOR_STREET = 319
7
+
8
+ def initialize(pdf, xml)
9
+ @pdf = pdf
10
+ @xml = xml
11
+
12
+ @y_position = Y_POSITION
13
+ @ltitle = @y_position - 0.42
14
+ @l1 = @y_position
15
+ @l2 = @y_position + LINE_HEIGHT
16
+ @l3 = @y_position + (LINE_HEIGHT * 2)
17
+ end
18
+
19
+ def render
20
+ if Entrega.delivery_local?(@xml)
21
+ @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'entrega.title'
22
+ render_line1
23
+ render_line2
24
+ render_line3
25
+ end
26
+ end
27
+
28
+ def self.delivery_local?(xml)
29
+ doc = xml.is_a?(BrDanfe::XML) ? xml : Nokogiri::XML(xml)
30
+ doc.css('entrega/xLgr').text.present?
31
+ end
32
+
33
+ private
34
+
35
+ def render_line1
36
+ @pdf.lbox LINE_HEIGHT, 11.82, 0.75, @l1, @xml, 'entrega/xNome'
37
+ render_cnpj_cpf
38
+ @pdf.lie LINE_HEIGHT, 2.92, 17.40, @l1, @xml, 'entrega/UF', 'entrega/IE'
39
+ end
40
+
41
+ def render_cnpj_cpf
42
+ if @xml['entrega/CNPJ'] == ''
43
+ @pdf.i18n_lbox LINE_HEIGHT, 4.37, 12.57, @l1, 'entrega.CPF', cpf
44
+ else
45
+ @pdf.lcnpj LINE_HEIGHT, 4.37, 12.57, @l1, @xml, 'entrega/CNPJ'
46
+ end
47
+ end
48
+
49
+ def cpf
50
+ cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['entrega/CPF'])
51
+ cpf.formatted
52
+ end
53
+
54
+ def render_line2
55
+ @pdf.i18n_lbox LINE_HEIGHT, 11.82, 0.75, @l2, 'entrega.xLgr', address
56
+ @pdf.lbox LINE_HEIGHT, 4.37, 12.57, @l2, @xml, 'entrega/xBairro'
57
+ @pdf.i18n_lbox LINE_HEIGHT, 2.92, 17.40, @l2, 'entrega.CEP', cep
58
+ end
59
+
60
+ def address
61
+ address = Helper.generate_address @xml, 'entrega'
62
+
63
+ if Helper.address_is_too_big(@pdf, address)
64
+ address = address[0..address.length - 2] while Helper.mensure_text(@pdf, "#{address.strip}...") > MAXIMUM_SIZE_FOR_STREET && !address.empty?
65
+ address = "#{address.strip}..."
66
+ end
67
+ address
68
+ end
69
+
70
+ def cep
71
+ BrDanfe::Helper.format_cep(@xml['entrega/CEP'])
72
+ end
73
+
74
+ def render_line3
75
+ @pdf.lbox LINE_HEIGHT, 15.05, 0.75, @l3, @xml, 'entrega/xMun'
76
+ @pdf.lbox LINE_HEIGHT, 1.14, 15.8, @l3, @xml, 'entrega/UF'
77
+ @pdf.i18n_lbox LINE_HEIGHT, 2.92, 17.40, @l3, 'entrega.fone', phone
78
+ end
79
+
80
+ def phone
81
+ Phone.format(@xml['entrega/fone'])
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -38,10 +38,10 @@ module BrDanfe
38
38
  Helper.mensure_text(pdf, address) > Dest::MAXIMUM_SIZE_FOR_STREET
39
39
  end
40
40
 
41
- def self.generate_address(xml)
42
- address_complement = " - #{xml_text(xml, 'enderDest/xCpl')}" if xml_text(xml, 'enderDest/xCpl').present?
43
- address_number = " #{xml_text(xml, 'enderDest/nro')}" if xml_text(xml, 'enderDest/nro').present?
44
- "#{xml_text(xml, 'enderDest/xLgr')}#{address_number}#{address_complement}"
41
+ def self.generate_address(xml, path)
42
+ address_complement = " - #{xml_text(xml, "#{path}/xCpl")}" if xml_text(xml, "#{path}/xCpl").present?
43
+ address_number = " #{xml_text(xml, "#{path}/nro")}" if xml_text(xml, "#{path}/nro").present?
44
+ "#{xml_text(xml, "#{path}/xLgr")}#{address_number}#{address_complement}"
45
45
  end
46
46
 
47
47
  def self.xml_text(xml, property)
@@ -2,15 +2,19 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class Icmstot
5
- Y = 13.77 + SPACE_BETWEEN_GROUPS
5
+ attr_reader :y_position
6
+
7
+ Y_POSITION = 13.77 + SPACE_BETWEEN_GROUPS
6
8
 
7
9
  def initialize(pdf, xml)
8
10
  @pdf = pdf
9
11
  @xml = xml
10
12
 
11
- @ltitle = Y - 0.42
12
- @l1 = Y
13
- @l2 = Y + LINE_HEIGHT
13
+ @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
14
+
15
+ @ltitle = @y_position - 0.42
16
+ @l1 = @y_position
17
+ @l2 = @y_position + LINE_HEIGHT
14
18
  end
15
19
 
16
20
  def render
@@ -44,7 +44,6 @@ module BrDanfe
44
44
  additional_data.push(address_content) if address?
45
45
  additional_data.push(difal_content) if difal?
46
46
  additional_data.push(fisco_content) if fisco?
47
- additional_data.push(address_shipment) if shipment?
48
47
  additional_data.join(' * ')
49
48
  end
50
49
 
@@ -57,11 +56,11 @@ module BrDanfe
57
56
  end
58
57
 
59
58
  def address_content
60
- "Endereço: #{Helper.generate_address @xml}"
59
+ "Endereço: #{Helper.generate_address @xml, 'enderDest'}"
61
60
  end
62
61
 
63
62
  def address?
64
- Helper.address_is_too_big @pdf, Helper.generate_address(@xml)
63
+ Helper.address_is_too_big @pdf, Helper.generate_address(@xml, 'enderDest')
65
64
  end
66
65
 
67
66
  def difal_content
@@ -77,21 +76,6 @@ module BrDanfe
77
76
  BrDanfe::Helper.numerify(value) if value != ''
78
77
  end
79
78
 
80
- def shipment?
81
- @xml['entrega'].present?
82
- end
83
-
84
- def address_shipment
85
- street = @xml['entrega/xLgr'].to_s
86
- number = @xml['entrega/nro'].to_s
87
- complement = @xml['entrega/xCpl'].to_s
88
- neighborhood = @xml['entrega/xBairro'].to_s
89
- city = @xml['entrega/xMun'].to_s
90
- uf = @xml['entrega/UF'].to_s
91
-
92
- "Endereço de entrega: #{street}, nº #{number} - #{neighborhood} - #{city} - #{uf} - #{complement}"
93
- end
94
-
95
79
  def difal?
96
80
  value = @xml['ICMSTot/vICMSUFDest'].presence || '0.0'
97
81
  BigDecimal(value).positive?
@@ -114,7 +98,7 @@ module BrDanfe
114
98
  end
115
99
 
116
100
  def additional_data?
117
- complementary? || address? || difal? || fisco? || shipment?
101
+ complementary? || address? || difal? || fisco?
118
102
  end
119
103
 
120
104
  def render_reserved_fisco
@@ -2,14 +2,16 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class Issqn
5
+ attr_reader :y_position
6
+
5
7
  Y_POSITION = 25.72 + SPACE_BETWEEN_GROUPS
6
8
 
7
9
  def initialize(pdf, xml)
8
10
  @pdf = pdf
9
11
  @xml = xml
10
12
 
11
- @title = Y_POSITION - 0.42
12
- @y_position = Y_POSITION
13
+ @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
14
+ @title = @y_position - 0.42
13
15
 
14
16
  @serv = 'total/ISSQNtot/vServ'
15
17
  @bc = 'total/ISSQNtot/vBC'
@@ -2,15 +2,19 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class Transp
5
- Y = 15.89 + SPACE_BETWEEN_GROUPS
5
+ attr_reader :y_position
6
+
7
+ Y_POSITION = 15.89 + SPACE_BETWEEN_GROUPS
6
8
 
7
9
  def initialize(pdf, xml)
8
10
  @pdf = pdf
9
11
  @xml = xml
10
12
 
11
- @ltitle = Y - 0.42
12
- @l1 = Y
13
- @l2 = Y + LINE_HEIGHT
13
+ @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
14
+
15
+ @ltitle = @y_position - 0.42
16
+ @l1 = @y_position
17
+ @l2 = @y_position + LINE_HEIGHT
14
18
  end
15
19
 
16
20
  def render
@@ -2,13 +2,17 @@ module BrDanfe
2
2
  module DanfeLib
3
3
  module NfeLib
4
4
  class Vol
5
- Y = 18.01
5
+ attr_reader :y_position
6
+
7
+ Y_POSITION = 18.01
6
8
 
7
9
  def initialize(pdf, xml)
8
10
  @pdf = pdf
9
11
  @xml = xml
10
12
 
11
- @l1 = Y
13
+ @y_position = Entrega.delivery_local?(@xml) ? Y_POSITION + 3.00 : Y_POSITION
14
+
15
+ @l1 = @y_position
12
16
  end
13
17
 
14
18
  def render
@@ -1,22 +1,11 @@
1
1
  module BrDanfe
2
2
  module Logo
3
- class Config < OpenStruct
4
- DEFAULTOPTIONS = { logo: '', logo_dimensions: {} }.freeze
3
+ class Config
4
+ attr_accessor :logo, :logo_dimensions
5
5
 
6
6
  def initialize(new_options = {})
7
- options = DEFAULTOPTIONS.merge(config_yaml_load)
8
- super options.merge(new_options)
9
- end
10
-
11
- private
12
-
13
- def file
14
- File.exist?('config/br_danfe.yml') ? File.open('config/br_danfe.yml').read : ''
15
- end
16
-
17
- def config_yaml_load
18
- @file_read = YAML.safe_load(file)
19
- @file_read ? (@file_read['br_danfe'] || {})['options'] : {}
7
+ @logo = new_options[:logo] || ''
8
+ @logo_dimensions = new_options[:logo_dimensions] || {}
20
9
  end
21
10
  end
22
11
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = '0.19.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
data/lib/br_danfe.rb CHANGED
@@ -6,7 +6,6 @@ require 'barby/barcode/code_128'
6
6
  require 'barby/outputter/prawn_outputter'
7
7
  require 'nokogiri'
8
8
  require 'yaml'
9
- require 'ostruct'
10
9
  require 'i18n'
11
10
  require 'br_documents'
12
11
 
@@ -418,6 +418,79 @@ describe BrDanfe::DanfeLib::NfeLib::DetBody do
418
418
  end
419
419
  end
420
420
 
421
+ context 'with entrega' do
422
+ let(:products) do
423
+ <<~XML
424
+ <det nItem="1">
425
+ <prod>
426
+ <cProd>REF 06</cProd>
427
+ <xProd>Produto com FCI</xProd>
428
+ <NCM>90303329</NCM>
429
+ <EXTIPI>00</EXTIPI>
430
+ <CFOP>5101</cfop>
431
+ <uCom>PC</uCom>
432
+ <qCom>1.00</qCom>
433
+ <vUnCom>49.23</vUnCom>
434
+ <vProd>49.23</vProd>
435
+ </prod>
436
+ <imposto>
437
+ <ICMS>
438
+ <ICMS00>
439
+ <orig>0</orig>
440
+ <CST>00</CST>
441
+ <modBC>3</modBC>
442
+ <vBC>49.23</vBC>
443
+ <pICMS>12.00</pICMS>
444
+ <vICMS>5.90</vICMS>
445
+ </ICMS00>
446
+ </ICMS>
447
+ <IPI>
448
+ <cEnq>999</cEnq>
449
+ <IPITrib>
450
+ <CST>50</CST>
451
+ <vBC>49.23</vBC>
452
+ <pIPI>5.00</pIPI>
453
+ <vIPI>2.46</vIPI>
454
+ </IPITrib>
455
+ </IPI>
456
+ </imposto>
457
+ </det>
458
+ XML
459
+ end
460
+
461
+ let(:xml_as_string) do
462
+ <<~XML
463
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
464
+ <infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
465
+ #{products}
466
+ <entrega>
467
+ <CNPJ>82743287000880</CNPJ>
468
+ <xNome>Schneider Electric Brasil Ltda</xNome>
469
+ <xLgr>Av da Saudade</xLgr>
470
+ <nro>1125</nro>
471
+ <xBairro>Frutal</xBairro>
472
+ <xCpl>Sala 01 e 02</xCpl>
473
+ <cMun>3552403</cMun>
474
+ <xMun>SUMARE</xMun>
475
+ <UF>SP</UF>
476
+ <CEP>13171320</CEP>
477
+ <fone>1921046300</fone>
478
+ <IE>671008375110</IE>
479
+ </entrega>
480
+ </infNFe>
481
+ </NFe>
482
+ XML
483
+ end
484
+
485
+ it 'renders xml to the pdf' do
486
+ expect(File.exist?(output_pdf)).to be_falsey
487
+
488
+ pdf.render_file output_pdf
489
+
490
+ expect("#{base_dir}det_body#render-with_entrega.pdf").to have_same_content_of file: output_pdf
491
+ end
492
+ end
493
+
421
494
  context 'when the product table occupies more than one page' do
422
495
  context 'when the product table occupies two pages' do
423
496
  let(:products) { ("#{product_1}\n#{product_2}" * 22) + "\n#{product_1}" }