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
@@ -0,0 +1,37 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Issqn
|
5
|
+
Y_POSITION = 25.72 + SPACE_BETWEEN_GROUPS
|
6
|
+
|
7
|
+
def initialize(pdf, xml)
|
8
|
+
@pdf = pdf
|
9
|
+
@xml = xml
|
10
|
+
|
11
|
+
@title = Y_POSITION - 0.42
|
12
|
+
@y_position = Y_POSITION
|
13
|
+
|
14
|
+
@serv = 'total/ISSQNtot/vServ'
|
15
|
+
@bc = 'total/ISSQNtot/vBC'
|
16
|
+
@iss = 'total/ISSQNtot/vISS'
|
17
|
+
end
|
18
|
+
|
19
|
+
def render
|
20
|
+
if can_render?
|
21
|
+
@pdf.ititle 0.42, 10.00, 0.75, @title, 'issqn.title'
|
22
|
+
@pdf.lbox LINE_HEIGHT, 4.64, 0.75, @y_position, @xml, 'emit/IM'
|
23
|
+
@pdf.lnumeric LINE_HEIGHT, 5.14, 5.39, @y_position, @xml, @serv
|
24
|
+
@pdf.lnumeric LINE_HEIGHT, 5.14, 10.53, @y_position, @xml, @bc
|
25
|
+
@pdf.lnumeric LINE_HEIGHT, 4.64, 15.67, @y_position, @xml, @iss
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def can_render?
|
32
|
+
@xml[@serv].to_i.positive? || @xml[@bc].to_i.positive? || @xml[@iss].to_i.positive?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Phone
|
5
|
+
def self.format(phone)
|
6
|
+
if phone.length == 10
|
7
|
+
phone.sub(/(\d{2})(\d{4})(\d{4})/, '(\\1) \\2-\\3')
|
8
|
+
else
|
9
|
+
phone.sub(/(\d{2})(\d{5})(\d{4})/, '(\\1) \\2-\\3')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Ticket
|
5
|
+
def initialize(pdf, xml)
|
6
|
+
@pdf = pdf
|
7
|
+
@xml = xml
|
8
|
+
end
|
9
|
+
|
10
|
+
def render
|
11
|
+
@pdf.ibox 0.85, 15.60, 0.75, 1.85, I18n.t('danfe.ticket.xNome', xNome: @xml['emit/xNome'])
|
12
|
+
@pdf.ibox 0.85, 3.85, 0.75, 2.7, I18n.t('danfe.ticket.received_at')
|
13
|
+
@pdf.ibox 0.85, 11.75, 4.60, 2.7, I18n.t('danfe.ticket.receiver')
|
14
|
+
@pdf.ibox 1.70, 4.00, 16.35, 1.85, '',
|
15
|
+
I18n.t('danfe.ticket.document', nNF: @xml['ide/nNF'], serie: @xml['ide/serie']),
|
16
|
+
align: :center, valign: :center
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Transp
|
5
|
+
Y = 15.89 + SPACE_BETWEEN_GROUPS
|
6
|
+
|
7
|
+
def initialize(pdf, xml)
|
8
|
+
@pdf = pdf
|
9
|
+
@xml = xml
|
10
|
+
|
11
|
+
@ltitle = Y - 0.42
|
12
|
+
@l1 = Y
|
13
|
+
@l2 = Y + LINE_HEIGHT
|
14
|
+
end
|
15
|
+
|
16
|
+
def render
|
17
|
+
@pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'transporta.title'
|
18
|
+
|
19
|
+
@pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l1, @xml, 'transporta/xNome'
|
20
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.79, 9.27, @l1, 'transp.modFrete.title', mod_frete
|
21
|
+
@pdf.lbox LINE_HEIGHT, 1.78, 12.06, @l1, @xml, 'veicTransp/RNTC'
|
22
|
+
@pdf.i18n_lbox LINE_HEIGHT, 2.29, 13.84, @l1, 'veicTransp.placa', plate
|
23
|
+
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l1, @xml, 'veicTransp/UF'
|
24
|
+
@pdf.lcnpj LINE_HEIGHT, 3.44, 16.89, @l1, @xml, 'transporta/CNPJ'
|
25
|
+
@pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l2, @xml, 'transporta/xEnder'
|
26
|
+
@pdf.lbox LINE_HEIGHT, 6.86, 9.27, @l2, @xml, 'transporta/xMun'
|
27
|
+
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l2, @xml, 'transporta/UF'
|
28
|
+
@pdf.lie LINE_HEIGHT, 3.44, 16.89, @l2, @xml, 'transporta/UF', 'transporta/IE'
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def plate
|
34
|
+
Plate.format(@xml['veicTransp/placa'])
|
35
|
+
end
|
36
|
+
|
37
|
+
def mod_frete
|
38
|
+
case @xml['transp/modFrete']
|
39
|
+
when '0'
|
40
|
+
modality = 'emitter'
|
41
|
+
when '1'
|
42
|
+
modality = 'recipient'
|
43
|
+
when '2'
|
44
|
+
modality = 'third_party'
|
45
|
+
when '3'
|
46
|
+
modality = 'own_emitter'
|
47
|
+
when '4'
|
48
|
+
modality = 'own_recipient'
|
49
|
+
when '9'
|
50
|
+
modality = 'no_freight'
|
51
|
+
end
|
52
|
+
|
53
|
+
I18n.t("danfe.transp.modFrete.#{modality}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Vol
|
5
|
+
Y = 18.01
|
6
|
+
|
7
|
+
def initialize(pdf, xml)
|
8
|
+
@pdf = pdf
|
9
|
+
@xml = xml
|
10
|
+
|
11
|
+
@l1 = Y
|
12
|
+
end
|
13
|
+
|
14
|
+
def render
|
15
|
+
nVol = 0
|
16
|
+
|
17
|
+
@xml.collect('xmlns', 'vol') do |det|
|
18
|
+
nVol += 1
|
19
|
+
render_vol(det) if nVol < 2
|
20
|
+
end
|
21
|
+
|
22
|
+
render_blank_boxes if nVol.zero?
|
23
|
+
|
24
|
+
nVol
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def render_vol(det)
|
30
|
+
@pdf.ibox 0.85, 2.42, 0.75, @l1, I18n.t('danfe.vol.qVol'), det.css('qVol').text
|
31
|
+
@pdf.ibox 0.85, 3.05, 3.17, @l1, I18n.t('danfe.vol.esp'), det.css('esp').text
|
32
|
+
@pdf.ibox 0.85, 3.05, 6.22, @l1, I18n.t('danfe.vol.marca'), det.css('marca').text
|
33
|
+
@pdf.ibox 0.85, 4.83, 9.27, @l1, I18n.t('danfe.vol.nVol')
|
34
|
+
@pdf.inumeric 0.85, 3.43, 14.10, @l1, 'vol.pesoB', det.css('pesoB').text, decimals: 3
|
35
|
+
@pdf.inumeric 0.85, 2.80, 17.53, @l1, 'vol.pesoL', det.css('pesoL').text, decimals: 3
|
36
|
+
end
|
37
|
+
|
38
|
+
def render_blank_boxes
|
39
|
+
render_vol(@xml)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module BrDanfe
|
2
|
+
module DanfeLib
|
3
|
+
module NfeLib
|
4
|
+
class Xprod
|
5
|
+
def initialize(det)
|
6
|
+
@det = det
|
7
|
+
end
|
8
|
+
|
9
|
+
def render
|
10
|
+
xprod = @det.css('prod/xProd').text.to_s
|
11
|
+
|
12
|
+
xprod += infAdProd if infAdProd?
|
13
|
+
xprod += fci if fci?
|
14
|
+
xprod += icms_st if icms_st?
|
15
|
+
xprod += fcp if fcp?
|
16
|
+
xprod += fcp_st if fcp_st?
|
17
|
+
xprod += add_icms_st_ret_to_product
|
18
|
+
|
19
|
+
xprod
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def infAdProd
|
25
|
+
"\n#{@det.css('infAdProd').text}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def infAdProd?
|
29
|
+
!@det.css('infAdProd').text.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def fci
|
33
|
+
"\n#{I18n.t('danfe.det.prod.xProdFCI',
|
34
|
+
nFCI: @det.css('prod/nFCI').text)}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def fci?
|
38
|
+
!@det.css('prod/nFCI').text.empty?
|
39
|
+
end
|
40
|
+
|
41
|
+
def icms_st
|
42
|
+
"\n#{I18n.t('danfe.det.prod.xProdST',
|
43
|
+
pMVAST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pMVAST').text),
|
44
|
+
pICMSST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pICMSST').text),
|
45
|
+
vBCST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCST').text),
|
46
|
+
vICMSST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vICMSST').text))}"
|
47
|
+
end
|
48
|
+
|
49
|
+
def icms_st?
|
50
|
+
@det.css('ICMS/*/vBCST').text.to_i.positive?
|
51
|
+
end
|
52
|
+
|
53
|
+
def fcp?
|
54
|
+
@det.css('ICMS/*/vFCP').text.to_i.positive?
|
55
|
+
end
|
56
|
+
|
57
|
+
def fcp
|
58
|
+
icms00? ? fcp_for_icms00 : fcp_complete
|
59
|
+
end
|
60
|
+
|
61
|
+
def icms00?
|
62
|
+
@det.at_css('ICMS00')
|
63
|
+
end
|
64
|
+
|
65
|
+
def fcp_for_icms00
|
66
|
+
"\n#{I18n.t('danfe.det.prod.xProdFCPICMS00',
|
67
|
+
vFCP: BrDanfe::Helper.numerify(@det.css('ICMS00/vFCP').text),
|
68
|
+
pFCP: BrDanfe::Helper.numerify(@det.css('ICMS00/pFCP').text))}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def fcp_complete
|
72
|
+
"\n#{I18n.t('danfe.det.prod.xProdFCP',
|
73
|
+
vBCFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCFCP').text),
|
74
|
+
vFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/vFCP').text),
|
75
|
+
pFCP: BrDanfe::Helper.numerify(@det.css('ICMS/*/pFCP').text))}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def fcp_st?
|
79
|
+
@det.css('ICMS/*/vFCPST').text.to_i.positive?
|
80
|
+
end
|
81
|
+
|
82
|
+
def fcp_st
|
83
|
+
"\n#{I18n.t('danfe.det.prod.xProdFCPST',
|
84
|
+
vBCFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCFCPST').text),
|
85
|
+
pFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pFCPST').text),
|
86
|
+
vFCPST: BrDanfe::Helper.numerify(@det.css('ICMS/*/vFCPST').text))}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_icms_st_ret_to_product
|
90
|
+
icms_st_ret? ? icms_st_ret : ''
|
91
|
+
end
|
92
|
+
|
93
|
+
def icms_st_ret?
|
94
|
+
@det.css('ICMS/*/vBCSTRet').text.to_i.positive? || @det.css('ICMS/*/vICMSSTRet').text.to_i.positive? ||
|
95
|
+
@det.css('ICMS/*/pST').text.to_i.positive?
|
96
|
+
end
|
97
|
+
|
98
|
+
def icms_st_ret
|
99
|
+
"\n#{I18n.t(
|
100
|
+
'danfe.det.prod.xProdSTRet',
|
101
|
+
vBCSTRet: BrDanfe::Helper.numerify(@det.css('ICMS/*/vBCSTRet').text),
|
102
|
+
vICMSSTRet: BrDanfe::Helper.numerify(@det.css('ICMS/*/vICMSSTRet').text),
|
103
|
+
pST: BrDanfe::Helper.numerify(@det.css('ICMS/*/pST').text)
|
104
|
+
)}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/br_danfe/helper.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Helper
|
3
|
+
def self.no_fiscal_value?(xml)
|
4
|
+
homologation?(xml) || unauthorized?(xml)
|
5
|
+
end
|
6
|
+
|
3
7
|
def self.homologation?(xml)
|
4
8
|
xml.css('nfeProc/NFe/infNFe/ide/tpAmb').text == '2'
|
5
9
|
end
|
6
10
|
|
11
|
+
def self.unauthorized?(xml)
|
12
|
+
xml.css('nfeProc/protNFe/infProt/dhRecbto').empty?
|
13
|
+
end
|
14
|
+
|
7
15
|
def self.numerify(number)
|
8
16
|
return '' if !number || number == ''
|
9
17
|
|
data/lib/br_danfe/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::ProductList do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
let(:subject) { BrDanfe::
|
7
|
+
let(:subject) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 1.8.cm) }
|
8
8
|
|
9
9
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
10
10
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::Footer do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
let(:pdf) { BrDanfe::
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
|
9
9
|
let(:xml_footer) do
|
10
10
|
xml = <<-eos
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::Header do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
let(:logo) { './spec/fixtures/logo.png' }
|
@@ -42,7 +42,7 @@ describe BrDanfe::DanfeNfceLib::Header do
|
|
42
42
|
BrDanfe::XML.new(xml)
|
43
43
|
end
|
44
44
|
|
45
|
-
let(:pdf) { BrDanfe::
|
45
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
46
46
|
|
47
47
|
subject { described_class.new pdf, xml, logo, logo_options }
|
48
48
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::Key do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
@@ -24,7 +24,7 @@ describe BrDanfe::DanfeNfceLib::Key do
|
|
24
24
|
BrDanfe::XML.new(xml)
|
25
25
|
end
|
26
26
|
|
27
|
-
let(:pdf) { BrDanfe::
|
27
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
28
28
|
|
29
29
|
subject { described_class.new pdf, xml_key }
|
30
30
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::NfceIdentification do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
let(:pdf) { BrDanfe::
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
|
9
9
|
let(:xml) do
|
10
10
|
xml = <<-eos
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::ProductList do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}#{xml_name}.xml")) }
|
7
7
|
|
8
|
-
let(:pdf) { BrDanfe::
|
8
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
9
9
|
|
10
10
|
subject { described_class.new pdf, xml }
|
11
11
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe BrDanfe::
|
3
|
+
describe BrDanfe::DanfeLib::NfceLib::QrCode do
|
4
4
|
let(:base_dir) { './spec/fixtures/nfce/lib/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
|
7
|
-
let(:pdf) { BrDanfe::
|
7
|
+
let(:pdf) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 5.cm) }
|
8
8
|
|
9
9
|
let(:xml) do
|
10
10
|
xml = <<-eos
|