br_danfe 0.12.1 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +15 -25
- data/Gemfile.lock +54 -18
- data/Guardfile +14 -0
- data/README.md +5 -5
- data/br_danfe.gemspec +3 -1
- data/lib/br_danfe.rb +0 -1
- data/lib/br_danfe/danfe.rb +6 -90
- data/lib/br_danfe/danfe_lib/base.rb +33 -0
- data/lib/br_danfe/danfe_lib/nfce.rb +49 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/footer.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +69 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/helper.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/key.rb +20 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/nfce_identification.rb +22 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/product_list.rb +102 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb +25 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/recipient.rb +75 -0
- data/lib/br_danfe/danfe_lib/nfce_lib/total_list.rb +81 -0
- data/lib/br_danfe/danfe_lib/nfe.rb +83 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cep.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/consts.rb +8 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/cst.rb +34 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +96 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +137 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +142 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +117 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/helper.rb +55 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +35 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +125 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic_vol.rb +103 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +37 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/phone.rb +15 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/plate.rb +11 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/ticket.rb +21 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +58 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/vol.rb +44 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +109 -0
- data/lib/br_danfe/helper.rb +8 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/{lib → br_danfe}/cce_lib/barcode_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/correction_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/document_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/footer_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/header_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/nfe_key_spec.rb +0 -0
- data/spec/{lib → br_danfe}/cce_lib/protocol_spec.rb +0 -0
- data/spec/{features → br_danfe}/cce_spec.rb +0 -0
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/document_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/footer_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/header_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/helper_spec.rb +1 -1
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/key_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/nfce_identification_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/product_list_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/qr_code_spec.rb +2 -2
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/recipient_spec.rb +7 -7
- data/spec/{lib/danfe_nfce_lib → br_danfe/danfe_lib/nfce_lib}/total_list_spec.rb +4 -4
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +57 -0
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cep_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/cst_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dest_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/det_body_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/document_spec.rb +1 -1
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/dup_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/emit_header_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/helper_spec.rb +13 -87
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/icmstot_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_spec.rb +45 -4
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/infadic_vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/issqn_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/phone_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/plate_spec.rb +3 -3
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/ticket_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/transp_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/vol_spec.rb +2 -2
- data/spec/{lib/danfe_lib → br_danfe/danfe_lib/nfe_lib}/xprod_spec.rb +9 -9
- data/spec/{features/danfe_spec.rb → br_danfe/danfe_lib/nfe_spec.rb} +55 -47
- data/spec/br_danfe/danfe_spec.rb +40 -0
- data/spec/{lib → br_danfe}/helper_spec.rb +114 -0
- data/spec/{lib → br_danfe}/logo_config_spec.rb +1 -1
- data/spec/{lib → br_danfe}/logo_options_spec.rb +7 -7
- data/spec/{lib → br_danfe}/uf_spec.rb +0 -0
- data/spec/{lib → br_danfe}/xml_spec.rb +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.xml +358 -0
- data/spec/fixtures/nfce/v4.00/nfce.xml +2 -2
- data/spec/fixtures/nfce/v4.00/rendered_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/saved_nfce.fixture.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#address-shipment.pdf +108 -0
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +7 -7
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +7 -7
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +8 -8
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +10 -10
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +12 -12
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +10 -10
- metadata +114 -77
- data/lib/br_danfe/danfe_lib/cep.rb +0 -9
- data/lib/br_danfe/danfe_lib/consts.rb +0 -6
- data/lib/br_danfe/danfe_lib/cst.rb +0 -32
- data/lib/br_danfe/danfe_lib/dest.rb +0 -94
- data/lib/br_danfe/danfe_lib/det_body.rb +0 -135
- data/lib/br_danfe/danfe_lib/document.rb +0 -140
- data/lib/br_danfe/danfe_lib/dup.rb +0 -53
- data/lib/br_danfe/danfe_lib/emit_header.rb +0 -115
- data/lib/br_danfe/danfe_lib/helper.rb +0 -61
- data/lib/br_danfe/danfe_lib/icmstot.rb +0 -33
- data/lib/br_danfe/danfe_lib/infadic.rb +0 -107
- data/lib/br_danfe/danfe_lib/infadic_vol.rb +0 -101
- data/lib/br_danfe/danfe_lib/issqn.rb +0 -35
- data/lib/br_danfe/danfe_lib/phone.rb +0 -13
- data/lib/br_danfe/danfe_lib/plate.rb +0 -9
- data/lib/br_danfe/danfe_lib/ticket.rb +0 -19
- data/lib/br_danfe/danfe_lib/transp.rb +0 -56
- data/lib/br_danfe/danfe_lib/vol.rb +0 -42
- data/lib/br_danfe/danfe_lib/xprod.rb +0 -107
- data/lib/br_danfe/danfe_nfce.rb +0 -43
- data/lib/br_danfe/danfe_nfce_lib/document.rb +0 -35
- data/lib/br_danfe/danfe_nfce_lib/footer.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/header.rb +0 -67
- data/lib/br_danfe/danfe_nfce_lib/helper.rb +0 -9
- data/lib/br_danfe/danfe_nfce_lib/key.rb +0 -18
- data/lib/br_danfe/danfe_nfce_lib/nfce_identification.rb +0 -20
- data/lib/br_danfe/danfe_nfce_lib/product_list.rb +0 -100
- data/lib/br_danfe/danfe_nfce_lib/qr_code.rb +0 -23
- data/lib/br_danfe/danfe_nfce_lib/recipient.rb +0 -72
- data/lib/br_danfe/danfe_nfce_lib/total_list.rb +0 -78
- data/spec/features/danfe_nfce_spec.rb +0 -31
@@ -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
|
data/lib/br_danfe/danfe_nfce.rb
DELETED
@@ -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
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeNfceLib
|
3
|
-
class Footer
|
4
|
-
def initialize(pdf, xml)
|
5
|
-
@pdf = pdf
|
6
|
-
@xml = xml
|
7
|
-
end
|
8
|
-
|
9
|
-
def render(info = '')
|
10
|
-
tot_trib = @xml['ICMSTot/vTotTrib'].present? ? BrDanfe::Helper.numerify(@xml['ICMSTot/vTotTrib']) : '0,00'
|
11
|
-
@pdf.text "Tributos Totais Incidentes (Lei Federal 12.741/2012): R$ #{tot_trib}", size: 5, align: :center
|
12
|
-
|
13
|
-
if info.present?
|
14
|
-
@pdf.render_blank_line
|
15
|
-
@pdf.text info, size: 5, align: :center
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeNfceLib
|
3
|
-
class Header
|
4
|
-
def initialize(pdf, xml, logo, logo_dimensions)
|
5
|
-
@pdf = pdf
|
6
|
-
@xml = xml
|
7
|
-
@logo = logo
|
8
|
-
@logo_dimensions = logo_dimensions
|
9
|
-
end
|
10
|
-
|
11
|
-
def render
|
12
|
-
cursor = @pdf.cursor
|
13
|
-
|
14
|
-
render_company_info(cursor)
|
15
|
-
render_logo(cursor) if @logo.present?
|
16
|
-
|
17
|
-
render_homologation if BrDanfe::Helper.homologation?(@xml)
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def render_company_info(cursor)
|
23
|
-
one_line = 1
|
24
|
-
|
25
|
-
@pdf.bounding_box([x_position, cursor], width: width_box, height: 45) do
|
26
|
-
@pdf.text "#{@xml['emit/xNome']}", size: 7, align: :left, style: :bold
|
27
|
-
@pdf.text cnpj(@xml['emit/CNPJ']), size: 6, align: :left
|
28
|
-
@pdf.text BrDanfe::DanfeNfceLib::Helper.address(@xml.css('enderEmit')), size: 6, align: :left
|
29
|
-
@pdf.render_blank_line if count_name_lines(@xml['emit/xNome']) == one_line
|
30
|
-
@pdf.text 'Documento Auxiliar da Nota Fiscal de Consumidor Eletrônica', size: 6, align: :left
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def x_position
|
35
|
-
@logo.present? ? 1.7.cm : 0
|
36
|
-
end
|
37
|
-
|
38
|
-
def width_box
|
39
|
-
@logo.present? ? 5.7.cm : 7.4.cm
|
40
|
-
end
|
41
|
-
|
42
|
-
def cnpj(info)
|
43
|
-
cnpj = BrDocuments::CnpjCpf::Cnpj.new info
|
44
|
-
data = "CNPJ: #{cnpj.valid? ? cnpj.formatted : ''}"
|
45
|
-
data
|
46
|
-
end
|
47
|
-
|
48
|
-
def count_name_lines(company_name)
|
49
|
-
company_name.scan(/([\s\S]{1,38}( |$)|[\s\S]{1,38})/).length
|
50
|
-
end
|
51
|
-
|
52
|
-
def render_logo(cursor)
|
53
|
-
box_size = 45
|
54
|
-
logo_options = BrDanfe::Logo::Options.new(box_size, @logo_dimensions).options
|
55
|
-
|
56
|
-
@pdf.bounding_box([0, cursor], width: box_size, height: box_size) do
|
57
|
-
@pdf.image @logo, logo_options
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def render_homologation
|
62
|
-
@pdf.render_blank_line
|
63
|
-
@pdf.text 'EMITIDA EM AMBIENTE DE HOMOLOGAÇÃO – SEM VALOR FISCAL', size: 7, align: :center, style: :bold
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeNfceLib
|
3
|
-
class Helper
|
4
|
-
def self.address(ender_tag)
|
5
|
-
"#{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}"
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module BrDanfe
|
2
|
-
module DanfeNfceLib
|
3
|
-
class Key
|
4
|
-
def initialize(pdf, xml)
|
5
|
-
@pdf = pdf
|
6
|
-
@xml = xml
|
7
|
-
end
|
8
|
-
|
9
|
-
def render
|
10
|
-
@pdf.render_blank_line
|
11
|
-
|
12
|
-
@pdf.text 'Consulte pela Chave de Acesso em', size: 7, align: :center, style: :bold
|
13
|
-
@pdf.text @xml['urlChave'], size: 7, align: :center
|
14
|
-
@pdf.text @xml['chNFe'].gsub(/(\d)(?=(\d\d\d\d)+(?!\d))/, '\\1 '), size: 6, align: :center
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|