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
@@ -1,101 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class InfadicVol
4
- def initialize(xml, pdf)
5
- @xml = xml
6
- @pdf = pdf
7
- @y_position = 27.56
8
- end
9
-
10
- def render
11
- render_volume_title
12
- render_volume
13
- end
14
-
15
- private
16
-
17
- def render_volume_title
18
- @pdf.ibox 2.65, 12.45, 0.75, @y_position + 0.30, '', I18n.t('danfe.infAdic.vol.title'), size: 5, valign: :top,
19
- border: 0
20
- end
21
-
22
- def render_volume
23
- volumes = 0
24
- y_position = @y_position + 0.47
25
-
26
- @xml.collect('xmlns', 'vol') do |det|
27
- volumes += 1
28
-
29
- if volumes > 1
30
- render_fields det, y_position
31
- y_position += 0.15
32
- end
33
- end
34
- end
35
-
36
- def render_fields(det, y_position)
37
- render_esp det, y_position
38
- render_marca det, y_position
39
- render_qvol det, y_position
40
- render_nvol det, y_position
41
- render_pesob det, y_position
42
- render_pesol det, y_position
43
- end
44
-
45
- def render_esp(det, y_position)
46
- render_item_title 0.5, 1.35, 'esp', y_position
47
- render_item_field det.css('esp').text, 3, 1.75, y_position
48
- end
49
-
50
- def render_item_title(width, x_position, field, y_position)
51
- label = I18n.t("danfe.infAdic.vol.#{field}")
52
- @pdf.ibox 0.35, width, x_position, y_position, '', label, style_normal
53
- end
54
-
55
- def style_normal
56
- { size: 4, border: 0 }
57
- end
58
-
59
- def render_item_field(value, width, x_position, y_position)
60
- @pdf.ibox 0.35, width, x_position, y_position, '', value, style_italic
61
- end
62
-
63
- def style_italic
64
- style_normal.merge(style: :italic)
65
- end
66
-
67
- def render_marca(det, y_position)
68
- render_item_title 0.7, 4.15, 'marca', y_position
69
- render_item_field det.css('marca').text, 2, 4.75, y_position
70
- end
71
-
72
- def render_qvol(det, y_position)
73
- render_item_title 0.7, 0.75, 'qVol', y_position
74
- render_item_field det.css('qVol').text, 0.7, 1.04, y_position
75
- end
76
-
77
- def render_nvol(det, y_position)
78
- render_item_title 1, 6.1, 'nVol', y_position
79
- render_item_field det.css('nVol').text, 1, 6.7, y_position
80
- end
81
-
82
- def render_pesob(det, y_position)
83
- render_item_title 1.3, 7, 'pesoB', y_position
84
- render_peso_item_field det.css('pesoB').text, 1.3, 7, y_position
85
- end
86
-
87
- def render_peso_item_field(value, width, x_position, y_pos)
88
- @pdf.inumeric 0.35, width, x_position, y_pos, '', value, style_decimal
89
- end
90
-
91
- def style_decimal
92
- style_italic.merge(decimals: 3)
93
- end
94
-
95
- def render_pesol(det, y_position)
96
- render_item_title 0.9, 8.5, 'pesoL', y_position
97
- render_peso_item_field det.css('pesoL').text, 1.5, 8.5, y_position
98
- end
99
- end
100
- end
101
- end
@@ -1,35 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Issqn
4
- Y_POSITION = 25.72 + SPACE_BETWEEN_GROUPS
5
-
6
- def initialize(pdf, xml)
7
- @pdf = pdf
8
- @xml = xml
9
-
10
- @title = Y_POSITION - 0.42
11
- @y_position = Y_POSITION
12
-
13
- @serv = 'total/ISSQNtot/vServ'
14
- @bc = 'total/ISSQNtot/vBC'
15
- @iss = 'total/ISSQNtot/vISS'
16
- end
17
-
18
- def render
19
- if can_render?
20
- @pdf.ititle 0.42, 10.00, 0.75, @title, 'issqn.title'
21
- @pdf.lbox LINE_HEIGHT, 4.64, 0.75, @y_position, @xml, 'emit/IM'
22
- @pdf.lnumeric LINE_HEIGHT, 5.14, 5.39, @y_position, @xml, @serv
23
- @pdf.lnumeric LINE_HEIGHT, 5.14, 10.53, @y_position, @xml, @bc
24
- @pdf.lnumeric LINE_HEIGHT, 4.64, 15.67, @y_position, @xml, @iss
25
- end
26
- end
27
-
28
- private
29
-
30
- def can_render?
31
- @xml[@serv].to_i.positive? || @xml[@bc].to_i.positive? || @xml[@iss].to_i.positive?
32
- end
33
- end
34
- end
35
- end
@@ -1,13 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Phone
4
- def self.format(phone)
5
- if phone.length == 10
6
- phone.sub(/(\d{2})(\d{4})(\d{4})/, '(\\1) \\2-\\3')
7
- else
8
- phone.sub(/(\d{2})(\d{5})(\d{4})/, '(\\1) \\2-\\3')
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,9 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Plate
4
- def self.format(plate)
5
- plate.delete('-').sub(/([A-Za-z]{3})/, '\\1-')
6
- end
7
- end
8
- end
9
- end
@@ -1,19 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Ticket
4
- def initialize(pdf, xml)
5
- @pdf = pdf
6
- @xml = xml
7
- end
8
-
9
- def render
10
- @pdf.ibox 0.85, 15.60, 0.75, 1.85, I18n.t('danfe.ticket.xNome', xNome: @xml['emit/xNome'])
11
- @pdf.ibox 0.85, 3.85, 0.75, 2.7, I18n.t('danfe.ticket.received_at')
12
- @pdf.ibox 0.85, 11.75, 4.60, 2.7, I18n.t('danfe.ticket.receiver')
13
- @pdf.ibox 1.70, 4.00, 16.35, 1.85, '',
14
- I18n.t('danfe.ticket.document', nNF: @xml['ide/nNF'], serie: @xml['ide/serie']),
15
- { align: :center, valign: :center }
16
- end
17
- end
18
- end
19
- end
@@ -1,56 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Transp
4
- Y = 15.89 + SPACE_BETWEEN_GROUPS
5
-
6
- def initialize(pdf, xml)
7
- @pdf = pdf
8
- @xml = xml
9
-
10
- @ltitle = Y - 0.42
11
- @l1 = Y
12
- @l2 = Y + LINE_HEIGHT
13
- end
14
-
15
- def render
16
- @pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'transporta.title'
17
-
18
- @pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l1, @xml, 'transporta/xNome'
19
- @pdf.i18n_lbox LINE_HEIGHT, 2.79, 9.27, @l1, 'transp.modFrete.title', mod_frete
20
- @pdf.lbox LINE_HEIGHT, 1.78, 12.06, @l1, @xml, 'veicTransp/RNTC'
21
- @pdf.i18n_lbox LINE_HEIGHT, 2.29, 13.84, @l1, 'veicTransp.placa', plate
22
- @pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l1, @xml, 'veicTransp/UF'
23
- @pdf.lcnpj LINE_HEIGHT, 3.44, 16.89, @l1, @xml, 'transporta/CNPJ'
24
- @pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l2, @xml, 'transporta/xEnder'
25
- @pdf.lbox LINE_HEIGHT, 6.86, 9.27, @l2, @xml, 'transporta/xMun'
26
- @pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l2, @xml, 'transporta/UF'
27
- @pdf.lie LINE_HEIGHT, 3.44, 16.89, @l2, @xml, 'transporta/UF', 'transporta/IE'
28
- end
29
-
30
- private
31
-
32
- def plate
33
- Plate.format(@xml['veicTransp/placa'])
34
- end
35
-
36
- def mod_frete
37
- case @xml['transp/modFrete']
38
- when '0'
39
- modality = 'emitter'
40
- when '1'
41
- modality = 'recipient'
42
- when '2'
43
- modality = 'third_party'
44
- when '3'
45
- modality = 'own_emitter'
46
- when '4'
47
- modality = 'own_recipient'
48
- when '9'
49
- modality = 'no_freight'
50
- end
51
-
52
- I18n.t("danfe.transp.modFrete.#{modality}")
53
- end
54
- end
55
- end
56
- end
@@ -1,42 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Vol
4
- Y = 18.01
5
-
6
- def initialize(pdf, xml)
7
- @pdf = pdf
8
- @xml = xml
9
-
10
- @l1 = Y
11
- end
12
-
13
- def render
14
- nVol = 0
15
-
16
- @xml.collect('xmlns', 'vol') do |det|
17
- nVol += 1
18
- render_vol(det) if nVol < 2
19
- end
20
-
21
- render_blank_boxes if nVol.zero?
22
-
23
- nVol
24
- end
25
-
26
- private
27
-
28
- def render_vol(det)
29
- @pdf.ibox 0.85, 2.42, 0.75, @l1, I18n.t('danfe.vol.qVol'), det.css('qVol').text
30
- @pdf.ibox 0.85, 3.05, 3.17, @l1, I18n.t('danfe.vol.esp'), det.css('esp').text
31
- @pdf.ibox 0.85, 3.05, 6.22, @l1, I18n.t('danfe.vol.marca'), det.css('marca').text
32
- @pdf.ibox 0.85, 4.83, 9.27, @l1, I18n.t('danfe.vol.nVol')
33
- @pdf.inumeric 0.85, 3.43, 14.10, @l1, 'vol.pesoB', det.css('pesoB').text, { decimals: 3 }
34
- @pdf.inumeric 0.85, 2.80, 17.53, @l1, 'vol.pesoL', det.css('pesoL').text, { decimals: 3 }
35
- end
36
-
37
- def render_blank_boxes
38
- render_vol(@xml)
39
- end
40
- end
41
- end
42
- end
@@ -1,107 +0,0 @@
1
- module BrDanfe
2
- module DanfeLib
3
- class Xprod
4
- def initialize(det)
5
- @det = det
6
- end
7
-
8
- def render
9
- xprod = @det.css('prod/xProd').text.to_s
10
-
11
- xprod += infAdProd if infAdProd?
12
- xprod += fci if fci?
13
- xprod += icms_st if icms_st?
14
- xprod += fcp if fcp?
15
- xprod += fcp_st if fcp_st?
16
- xprod += add_icms_st_ret_to_product
17
-
18
- xprod
19
- end
20
-
21
- private
22
-
23
- def infAdProd
24
- "\n#{@det.css('infAdProd').text}"
25
- end
26
-
27
- def infAdProd?
28
- !@det.css('infAdProd').text.empty?
29
- end
30
-
31
- def fci
32
- "\n#{I18n.t('danfe.det.prod.xProdFCI',
33
- nFCI: @det.css('prod/nFCI').text)}"
34
- end
35
-
36
- def fci?
37
- !@det.css('prod/nFCI').text.empty?
38
- end
39
-
40
- def icms_st
41
- "\n#{I18n.t('danfe.det.prod.xProdST',
42
- pMVAST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pMVAST').text),
43
- pICMSST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pICMSST').text),
44
- vBCST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCST').text),
45
- vICMSST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vICMSST').text))}"
46
- end
47
-
48
- def icms_st?
49
- @det.css('ICMS/*/vBCST').text.to_i.positive?
50
- end
51
-
52
- def fcp?
53
- @det.css('ICMS/*/vFCP').text.to_i.positive?
54
- end
55
-
56
- def fcp
57
- icms00? ? fcp_for_icms00 : fcp_complete
58
- end
59
-
60
- def icms00?
61
- @det.at_css('ICMS00')
62
- end
63
-
64
- def fcp_for_icms00
65
- "\n#{I18n.t('danfe.det.prod.xProdFCPICMS00',
66
- vFCP: BrDanfe::Helper.numerify(@det.css('ICMS00/vFCP').text),
67
- pFCP: BrDanfe::Helper.numerify(@det.css('ICMS00/pFCP').text))}"
68
- end
69
-
70
- def fcp_complete
71
- "\n#{I18n.t('danfe.det.prod.xProdFCP',
72
- vBCFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCFCP').text),
73
- vFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/vFCP').text),
74
- pFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/pFCP').text))}"
75
- end
76
-
77
- def fcp_st?
78
- @det.css('ICMS/*/vFCPST').text.to_i.positive?
79
- end
80
-
81
- def fcp_st
82
- "\n#{I18n.t('danfe.det.prod.xProdFCPST',
83
- vBCFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCFCPST').text),
84
- pFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pFCPST').text),
85
- vFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vFCPST').text))}"
86
- end
87
-
88
- def add_icms_st_ret_to_product
89
- icms_st_ret? ? icms_st_ret : ''
90
- end
91
-
92
- def icms_st_ret?
93
- @det.css('ICMS/*/vBCSTRet').text.to_i.positive? || @det.css('ICMS/*/vICMSSTRet').text.to_i.positive? ||
94
- @det.css('ICMS/*/pST').text.to_i.positive?
95
- end
96
-
97
- def icms_st_ret
98
- "\n#{I18n.t(
99
- 'danfe.det.prod.xProdSTRet',
100
- vBCSTRet: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCSTRet').text),
101
- vICMSSTRet: BrDanfe::Helper.numerify(@det.css('ICMS/*/vICMSSTRet').text),
102
- pST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pST').text)
103
- )}"
104
- end
105
- end
106
- end
107
- end
@@ -1,43 +0,0 @@
1
- module BrDanfe
2
- class DanfeNfce
3
- PAGE_WIDTH = 8.cm
4
- PAGE_HEIGHT = 100.cm
5
-
6
- attr_reader :options
7
-
8
- def initialize(xml)
9
- @xml = BrDanfe::XML.new(xml)
10
- @pdf = DanfeNfceLib::Document.new(PAGE_WIDTH, PAGE_HEIGHT)
11
- @options = BrDanfe::Logo::Config.new
12
- end
13
-
14
- def save_pdf(filename, footer_info = '')
15
- generate footer_info
16
- @pdf.render_file filename
17
- end
18
-
19
- def render_pdf(footer_info = '')
20
- generate footer_info
21
- @pdf.render
22
- end
23
-
24
- private
25
-
26
- def generate(footer_info)
27
- DanfeNfceLib::Header.new(@pdf, @xml, @options.logo, @options.logo_dimensions).render
28
- DanfeNfceLib::ProductList.new(@pdf, @xml).render
29
- DanfeNfceLib::TotalList.new(@pdf, @xml).render
30
- DanfeNfceLib::Key.new(@pdf, @xml).render
31
- DanfeNfceLib::Recipient.new(@pdf, @xml).render
32
- DanfeNfceLib::NfceIdentification.new(@pdf, @xml).render
33
- DanfeNfceLib::QrCode.new(@pdf, @xml).render
34
- DanfeNfceLib::Footer.new(@pdf, @xml).render(footer_info)
35
-
36
- resize_page_height
37
- end
38
-
39
- def resize_page_height
40
- @pdf.page.dictionary.data[:MediaBox] = [0, @pdf.y - 10, PAGE_WIDTH, PAGE_HEIGHT]
41
- end
42
- end
43
- end
@@ -1,35 +0,0 @@
1
- module BrDanfe
2
- module DanfeNfceLib
3
- class Document
4
- def initialize(page_width, page_height)
5
- @document = Prawn::Document.new(
6
- page_size: [page_width, page_height],
7
- page_layout: :portrait,
8
- left_margin: 0.3.cm,
9
- right_margin: 0.3.cm,
10
- top_margin: 0.3.cm,
11
- botton_margin: 0
12
- )
13
-
14
- @document.font 'Courier'
15
- @document.line_width = 0.3
16
- end
17
-
18
- def render_blank_line(font_size = 6)
19
- @document.text ' ', size: font_size
20
- end
21
-
22
- def method_missing(method_name, *args, &block)
23
- if @document.respond_to? method_name
24
- @document.send method_name, *args, &block
25
- else
26
- super
27
- end
28
- end
29
-
30
- def respond_to_missing?(method_name, include_private = false)
31
- @document.respond_to?(method_name, include_private) || super
32
- end
33
- end
34
- end
35
- end