br_danfe 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +15 -25
  3. data/Gemfile.lock +1 -1
  4. data/README.md +5 -5
  5. data/lib/br_danfe.rb +0 -1
  6. data/lib/br_danfe/danfe.rb +6 -90
  7. data/lib/br_danfe/danfe_lib/base.rb +33 -0
  8. data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
  9. data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
  10. data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
  11. data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
  12. data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
  13. data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
  14. data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
  15. data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
  16. data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
  17. data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
  18. data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
  19. data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
  20. data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
  21. data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
  22. data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
  23. data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
  24. data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
  25. data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
  26. data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
  27. data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
  28. data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
  29. data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
  30. data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +109 -0
  31. data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
  32. data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
  33. data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
  34. data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
  35. data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
  36. data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
  37. data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
  38. data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
  39. data/lib/br_danfe/helper.rb +8 -0
  40. data/lib/br_danfe/version.rb +1 -1
  41. data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
  42. data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
  43. data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
  44. data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
  45. data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
  46. data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
  47. data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
  48. data/spec/{features → br_danfe}/cce_spec.rb +0 -0
  49. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
  50. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
  51. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
  52. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
  53. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
  54. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
  55. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
  56. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
  57. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
  58. data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
  59. data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
  60. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
  61. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
  62. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
  63. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
  64. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
  65. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
  66. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
  67. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
  68. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
  69. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +2 -2
  70. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
  71. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
  72. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
  73. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
  74. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
  75. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
  76. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
  77. data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
  78. data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
  79. data/spec/br_danfe/danfe_spec.rb +35 -0
  80. data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
  81. data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
  82. data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
  83. data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
  84. data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
  85. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
  86. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
  87. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
  88. data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
  89. data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
  90. data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
  91. data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
  92. metadata +82 -75
  93. data/lib/br_danfe/danfe_lib/cep.rb +0 -9
  94. data/lib/br_danfe/danfe_lib/consts.rb +0 -6
  95. data/lib/br_danfe/danfe_lib/cst.rb +0 -32
  96. data/lib/br_danfe/danfe_lib/dest.rb +0 -94
  97. data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
  98. data/lib/br_danfe/danfe_lib/document.rb +0 -140
  99. data/lib/br_danfe/danfe_lib/dup.rb +0 -53
  100. data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
  101. data/lib/br_danfe/danfe_lib/helper.rb +0 -61
  102. data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
  103. data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
  104. data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
  105. data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
  106. data/lib/br_danfe/danfe_lib/phone.rb +0 -13
  107. data/lib/br_danfe/danfe_lib/plate.rb +0 -9
  108. data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
  109. data/lib/br_danfe/danfe_lib/transp.rb +0 -56
  110. data/lib/br_danfe/danfe_lib/vol.rb +0 -42
  111. data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
  112. data/lib/br_danfe/danfe_nfce.rb +0 -43
  113. data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
  114. data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
  115. data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
  116. data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
  117. data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
  118. data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
  119. data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
  120. data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
  121. data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
  122. data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
  123. data/spec/features/danfe_nfce_spec.rb +0 -31
@@ -0,0 +1,11 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class Helper
5
+ def self.address(ender_tag)
6
+ "#{ender_tag.css('xLgr').text}, #{ender_tag.css('nro').text}, #{ender_tag.css('xBairro').text}, #{ender_tag.css('xMun').text} - #{ender_tag.css('UF').text}"
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class Key
5
+ def initialize(pdf, xml)
6
+ @pdf = pdf
7
+ @xml = xml
8
+ end
9
+
10
+ def render
11
+ @pdf.render_blank_line
12
+
13
+ @pdf.text 'Consulte pela Chave de Acesso em', size: 7, align: :center, style: :bold
14
+ @pdf.text @xml['urlChave'], size: 7, align: :center
15
+ @pdf.text @xml['chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), size: 6, align: :center
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class NfceIdentification
5
+ def initialize(pdf, xml)
6
+ @pdf = pdf
7
+ @xml = xml
8
+ end
9
+
10
+ def render
11
+ emitted_at = BrDanfe::Helper.format_datetime(@xml['ide/dhEmi'])
12
+ identification = "NFC-e nº #{@xml['ide/nNF']} Série #{@xml['ide/serie']} #{emitted_at}"
13
+
14
+ @pdf.render_blank_line
15
+ @pdf.text identification, size: 7, align: :center, style: :bold
16
+ @pdf.text "<b>Protocolo de autorização:</b> #{@xml['infProt/nProt']}", size: 7, align: :center, inline_format: true
17
+ @pdf.text "<b>Data de autorização: </b> #{BrDanfe::Helper.format_datetime(@xml['infProt/dhRecbto'])}", size: 7, align: :center, inline_format: true
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,102 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class ProductList
5
+ def initialize(pdf, xml)
6
+ @pdf = pdf
7
+ @xml = xml
8
+ end
9
+
10
+ def render
11
+ render_headers(headers)
12
+ render_products
13
+ end
14
+
15
+ private
16
+
17
+ def headers
18
+ [
19
+ header_column('Código', :left),
20
+ header_column('Descrição', :left),
21
+ header_column('Qtde', :right),
22
+ header_column('UN', :right),
23
+ header_column('Vl Unit', :right),
24
+ header_column('Vl Total', :right)
25
+ ]
26
+ end
27
+
28
+ def header_column(title, align)
29
+ { content: title, options: { align: align, size: 6, style: :bold } }
30
+ end
31
+
32
+ def products
33
+ @xml.collect('xmlns', 'det') { |det| product(det) }
34
+ end
35
+
36
+ def product(det)
37
+ [
38
+ cell_text(det.css('prod/cProd').text),
39
+ cell_text(det.css('prod/xProd').text),
40
+ cell_number(BrDanfe::Helper.numerify(det.css('prod/qCom').text)),
41
+ cell_text(det.css('prod/uCom').text, align: :right),
42
+ cell_number(BrDanfe::Helper.numerify(det.css('prod/vUnCom').text)),
43
+ cell_number(BrDanfe::Helper.numerify(det.css('prod/vProd').text))
44
+ ]
45
+ end
46
+
47
+ def cell_text(text, options = {})
48
+ cell = { content: text, options: { border_width: 0, size: 6 } }
49
+ cell[:options].merge!(options)
50
+ cell
51
+ end
52
+
53
+ def cell_number(text)
54
+ cell_text(text, align: :right)
55
+ end
56
+
57
+ def columns
58
+ [
59
+ { width: 0.9.cm, position: 0 },
60
+ { width: 2.6.cm, position: 0.9.cm },
61
+ { width: 1.1.cm, position: 3.5.cm },
62
+ { width: 0.4.cm, position: 4.6.cm },
63
+ { width: 1.2.cm, position: 5.cm },
64
+ { width: 1.2.cm, position: 6.2.cm }
65
+ ]
66
+ end
67
+
68
+ def render_headers(headers)
69
+ 2.times { @pdf.render_blank_line }
70
+ cursor = @pdf.cursor
71
+ headers.each_with_index do |header, index|
72
+ @pdf.bounding_box [columns[index][:position], cursor], width: columns[index][:width], height: 0.2.cm do
73
+ @pdf.text header[:content], header[:options]
74
+ end
75
+ end
76
+ end
77
+
78
+ def render_products
79
+ @pdf.render_blank_line
80
+ index_of_product_name = 1
81
+ products.each do |product|
82
+ box_height = box_height(product[index_of_product_name][:content])
83
+ cursor = @pdf.cursor
84
+
85
+ product.each_with_index do |cell, index|
86
+ @pdf.bounding_box [columns[index][:position], cursor], width: columns[index][:width], height: box_height do
87
+ @pdf.text cell[:content], cell[:options]
88
+ end
89
+ end
90
+ end
91
+ end
92
+
93
+ def box_height(content)
94
+ line_height_base = 0.23.cm
95
+
96
+ lines = content.scan(/[\s\S]{1,20}( |$)/).length
97
+ line_height_base * lines
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,25 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class QrCode
5
+ require 'rqrcode'
6
+ require 'chunky_png'
7
+ require 'tempfile'
8
+
9
+ def initialize(pdf, xml)
10
+ @pdf = pdf
11
+ @xml = xml
12
+ end
13
+
14
+ def render
15
+ qrcode = RQRCode::QRCode.new(@xml['qrCode'])
16
+ image = Tempfile.create('qrcode.png')
17
+ image.write(qrcode.as_png(module_px_size: 12).to_s)
18
+
19
+ box_size = 3.cm
20
+ @pdf.image image, width: box_size, height: box_size, position: :center
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,75 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class Recipient
5
+ def initialize(pdf, xml)
6
+ @pdf = pdf
7
+ @xml = xml
8
+ end
9
+
10
+ def render
11
+ @pdf.render_blank_line
12
+
13
+ if identified_recipient?
14
+ render_document
15
+
16
+ @pdf.text @xml['dest/xNome'], options
17
+ @pdf.text BrDanfe::DanfeLib::NfceLib::Helper.address(@xml.css('enderDest')), options
18
+ else
19
+ @pdf.text 'CONSUMIDOR NÃO IDENTIFICADO', options
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def options
26
+ { size: 7, align: :center }
27
+ end
28
+
29
+ def identified_recipient?
30
+ @xml['dest/xNome'].present?
31
+ end
32
+
33
+ def render_document
34
+ document_text = document
35
+
36
+ @pdf.text document_text, options if document_text.present?
37
+ end
38
+
39
+ def document
40
+ return company if company?
41
+ return individual if individual?
42
+ return foreign if foreign?
43
+
44
+ ''
45
+ end
46
+
47
+ def company?
48
+ @xml['dest/CNPJ'].present?
49
+ end
50
+
51
+ def company
52
+ cnpj = BrDocuments::CnpjCpf::Cnpj.new @xml['dest/CNPJ']
53
+ "CONSUMIDOR CNPJ: #{cnpj.formatted}"
54
+ end
55
+
56
+ def individual?
57
+ @xml['dest/CPF'].present?
58
+ end
59
+
60
+ def individual
61
+ cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['dest/CPF'])
62
+ "CONSUMIDOR CPF: #{cpf.formatted}"
63
+ end
64
+
65
+ def foreign?
66
+ @xml['dest/idEstrangeiro'].present?
67
+ end
68
+
69
+ def foreign
70
+ "CONSUMIDOR Id. Estrangeiro: #{@xml['dest/idEstrangeiro']}"
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,81 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfceLib
4
+ class TotalList
5
+ require 'bigdecimal'
6
+
7
+ def initialize(pdf, xml)
8
+ @pdf = pdf
9
+ @xml = xml
10
+ end
11
+
12
+ def render
13
+ subtotal
14
+ totals
15
+ payment_methods
16
+ end
17
+
18
+ private
19
+
20
+ def subtotal
21
+ cursor = @pdf.cursor
22
+ @pdf.bounding_box [4.8.cm, cursor], width: 1.4.cm, height: 0.2.cm do
23
+ @pdf.text 'Subtotal R$', size: 6, align: :left
24
+ end
25
+ @pdf.bounding_box [6.2.cm, cursor], width: 1.2.cm, height: 0.2.cm do
26
+ @pdf.text BrDanfe::Helper.numerify(@xml['ICMSTot > vProd'].to_f), size: 6, align: :right
27
+ end
28
+ end
29
+
30
+ def totals
31
+ @pdf.render_blank_line
32
+
33
+ cursor = @pdf.cursor
34
+ print_text('Qtde. total de itens', cursor, size: 7, align: :left)
35
+ print_text(@xml.css('det').count.to_s, cursor, size: 7, align: :right)
36
+
37
+ cursor = @pdf.cursor
38
+ print_text('Desconto R$', cursor, size: 7, align: :left)
39
+ print_text(BrDanfe::Helper.numerify(@xml['ICMSTot > vDesc'].to_f), cursor, size: 7, align: :right)
40
+
41
+ cursor = @pdf.cursor
42
+ print_text('Valor Total R$', cursor, size: 7, align: :left, style: :bold)
43
+ print_text(BrDanfe::Helper.numerify(@xml['ICMSTot > vNF'].to_f), cursor, size: 7, align: :right, style: :bold)
44
+ end
45
+
46
+ def payment_methods
47
+ payments = {}
48
+ without_payment = '90'
49
+
50
+ @xml.css('detPag').each do |detPag|
51
+ next if detPag.css('tPag').text == without_payment
52
+
53
+ payments[detPag.css('tPag').text] ||= BigDecimal('0')
54
+ actual_payment_value = BigDecimal(detPag.css('vPag').text)
55
+ payments[detPag.css('tPag').text] += actual_payment_value
56
+ end
57
+
58
+ if payments.present?
59
+ @pdf.render_blank_line
60
+
61
+ cursor = @pdf.cursor
62
+ print_text('Forma de pagamento', cursor, size: 7, align: :left, style: :bold)
63
+ print_text('Valor pago R$', cursor, size: 7, align: :right, style: :bold)
64
+
65
+ payments.each do |key, value|
66
+ cursor = @pdf.cursor
67
+ print_text(I18n.t("nfce.payment_methods.#{key}"), cursor, size: 7, align: :left)
68
+ print_text(BrDanfe::Helper.numerify(value.to_f), cursor, size: 7, align: :right)
69
+ end
70
+ end
71
+ end
72
+
73
+ def print_text(text, cursor, options)
74
+ @pdf.bounding_box [0, cursor], width: 7.4.cm, height: 0.25.cm do
75
+ @pdf.text text, options
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,83 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ class Nfe < Base
4
+ private
5
+
6
+ def document
7
+ NfeLib::Document.new
8
+ end
9
+
10
+ def create_watermark
11
+ @document.create_stamp('has_no_fiscal_value') do
12
+ @document.fill_color '7d7d7d'
13
+ @document.text_box I18n.t('danfe.others.has_no_fiscal_value'),
14
+ size: 2.2.cm,
15
+ width: @document.bounds.width,
16
+ height: @document.bounds.height,
17
+ align: :center,
18
+ valign: :center,
19
+ at: [0, @document.bounds.height],
20
+ rotate: 45,
21
+ rotate_around: :center
22
+ end
23
+ end
24
+
25
+ def generate(footer_info)
26
+ render_on_first_page
27
+ render_on_each_page footer_info
28
+ @document
29
+ end
30
+
31
+ def render_on_first_page
32
+ NfeLib::Ticket.new(@document, @xml).render
33
+ NfeLib::Dest.new(@document, @xml).render
34
+ NfeLib::Dup.new(@document, @xml).render
35
+ NfeLib::Icmstot.new(@document, @xml).render
36
+ NfeLib::Transp.new(@document, @xml).render
37
+ n_vol = NfeLib::Vol.new(@document, @xml).render
38
+ has_issqn = NfeLib::Issqn.new(@document, @xml).render
39
+ NfeLib::Infadic.new(@document, @xml).render(n_vol)
40
+
41
+ render_products has_issqn
42
+ end
43
+
44
+ def render_products(has_issqn)
45
+ NfeLib::DetBody.new(@document, @xml).render(has_issqn)
46
+ end
47
+
48
+ def render_on_each_page(footer_info)
49
+ emitter = NfeLib::EmitHeader.new(@document, @xml, @options.logo, @options.logo_dimensions)
50
+
51
+ @document.page_count.times do |i|
52
+ page = i + 1
53
+ position = page == 1 ? 3.96 : 1.85
54
+ repeated_information page, position, emitter, footer_info
55
+ end
56
+ end
57
+
58
+ def repeated_information(page, y_position, emitter, footer_info)
59
+ @document.go_to_page(page)
60
+
61
+ emitter.render page, y_position
62
+ render_product_table_title page
63
+ render_footer_information footer_info
64
+ render_no_fiscal_value
65
+ end
66
+
67
+ def render_product_table_title(page)
68
+ y_position = page == 1 ? 18.91 : 7.40
69
+ @document.ititle 0.42, 10.00, 0.75, y_position, 'det.title'
70
+ end
71
+
72
+ def render_footer_information(footer_info)
73
+ if footer_info.present?
74
+ @document.ibox 0.35, 12.45, 0.75, 30.21, '', footer_info, size: 5, border: 0
75
+ end
76
+ end
77
+
78
+ def render_no_fiscal_value
79
+ @document.stamp('has_no_fiscal_value') if BrDanfe::Helper.no_fiscal_value?(@xml)
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,11 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfeLib
4
+ class Cep
5
+ def self.format(cep)
6
+ cep.sub(/(\d{2})(\d{3})(\d{3})/, '\\1.\\2-\\3')
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ module BrDanfe
2
+ module DanfeLib
3
+ module NfeLib
4
+ LINE_HEIGHT = 0.80
5
+ SPACE_BETWEEN_GROUPS = 0.52
6
+ end
7
+ end
8
+ end