br_danfe 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rubocop.yml +113 -0
- data/Gemfile.lock +40 -19
- data/Rakefile +3 -3
- data/br_danfe.gemspec +7 -7
- data/lib/br_danfe.rb +14 -14
- data/lib/br_danfe/cce.rb +1 -0
- data/lib/br_danfe/cce_lib/barcode.rb +3 -2
- data/lib/br_danfe/cce_lib/correction.rb +3 -2
- data/lib/br_danfe/cce_lib/document.rb +15 -5
- data/lib/br_danfe/cce_lib/footer.rb +1 -1
- data/lib/br_danfe/cce_lib/header.rb +1 -1
- data/lib/br_danfe/cce_lib/nfe_key.rb +4 -3
- data/lib/br_danfe/cce_lib/protocol.rb +4 -3
- data/lib/br_danfe/danfe.rb +17 -17
- data/lib/br_danfe/danfe_lib/cep.rb +1 -1
- data/lib/br_danfe/danfe_lib/cst.rb +8 -6
- data/lib/br_danfe/danfe_lib/dest.rb +21 -23
- data/lib/br_danfe/danfe_lib/det_body.rb +20 -20
- data/lib/br_danfe/danfe_lib/document.rb +49 -36
- data/lib/br_danfe/danfe_lib/dup.rb +11 -10
- data/lib/br_danfe/danfe_lib/emit_header.rb +38 -34
- data/lib/br_danfe/danfe_lib/helper.rb +23 -23
- data/lib/br_danfe/danfe_lib/icmstot.rb +12 -12
- data/lib/br_danfe/danfe_lib/infadic.rb +1 -0
- data/lib/br_danfe/danfe_lib/issqn.rb +6 -6
- data/lib/br_danfe/danfe_lib/options.rb +6 -5
- data/lib/br_danfe/danfe_lib/phone.rb +2 -2
- data/lib/br_danfe/danfe_lib/ticket.rb +6 -4
- data/lib/br_danfe/danfe_lib/transp.rb +27 -26
- data/lib/br_danfe/danfe_lib/vol.rb +9 -8
- data/lib/br_danfe/danfe_lib/xml.rb +6 -6
- data/lib/br_danfe/danfe_lib/xprod.rb +22 -23
- data/lib/br_danfe/uf.rb +1 -4
- data/lib/br_danfe/version.rb +1 -1
- data/spec/features/cce_spec.rb +6 -6
- data/spec/features/danfe_spec.rb +25 -25
- data/spec/fixtures/cce/lib/barcode#render.pdf +5 -1
- data/spec/fixtures/cce/lib/correction#render.pdf +6 -2
- data/spec/fixtures/cce/lib/document#box.pdf +5 -1
- data/spec/fixtures/cce/lib/document#box.with.block.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.align.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.pad.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.simple.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.size.pdf +6 -2
- data/spec/fixtures/cce/lib/document#text.style.pdf +6 -2
- data/spec/fixtures/cce/lib/footer#render.pdf +6 -2
- data/spec/fixtures/cce/lib/header#render.pdf +6 -2
- data/spec/fixtures/cce/lib/nfe_key#render.pdf +7 -3
- data/spec/fixtures/cce/lib/protocol#render.pdf +7 -3
- data/spec/fixtures/cce/v1.00/cce.fixture.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v2.00.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v3.10.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-v4.00.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_cpf.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-with_ie.pdf +7 -3
- data/spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf +7 -3
- data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +383 -379
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +233 -229
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +3697 -3685
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +3540 -3532
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +158 -154
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +1665 -1657
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +1665 -1657
- data/spec/fixtures/nfe/lib/document#lcnpj-blank.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lcnpj-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lcnpj-valid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-blank.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-invalid.pdf +6 -2
- data/spec/fixtures/nfe/lib/document#lie-valid.pdf +6 -2
- data/spec/fixtures/nfe/lib/dup#render.pdf +8 -4
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +9 -5
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +9 -5
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +7 -3
- data/spec/fixtures/nfe/lib/icmstot#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +8 -4
- data/spec/fixtures/nfe/lib/infadic#render-difal.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-extra_volume.pdf +8 -4
- data/spec/fixtures/nfe/lib/infadic#render-with_complementary_information.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-with_fisco_additional_information.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render-with_street_data.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/infadic_vol#render-extra_volume.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-with_issqn.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +7 -3
- data/spec/fixtures/nfe/lib/issqn#render-without_issqn.pdf +5 -1
- data/spec/fixtures/nfe/lib/ticket#render.pdf +6 -2
- data/spec/fixtures/nfe/lib/transp#render-modfrete_0.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_1.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_2.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_3.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_4.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render-modfrete_9.pdf +7 -3
- data/spec/fixtures/nfe/lib/transp#render.pdf +7 -3
- data/spec/fixtures/nfe/lib/vol#render-blank-boxes.pdf +6 -2
- data/spec/fixtures/nfe/lib/vol#render.pdf +6 -2
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +317 -313
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +315 -311
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +1297 -1289
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +165 -161
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +1297 -1289
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +314 -310
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +765 -761
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +1222 -1214
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +1222 -1214
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +4004 -3992
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +1522 -1514
- data/spec/lib/cce_lib/barcode_spec.rb +5 -5
- data/spec/lib/cce_lib/correction_spec.rb +5 -5
- data/spec/lib/cce_lib/document_spec.rb +23 -23
- data/spec/lib/cce_lib/footer_spec.rb +4 -4
- data/spec/lib/cce_lib/header_spec.rb +4 -4
- data/spec/lib/cce_lib/nfe_key_spec.rb +5 -5
- data/spec/lib/cce_lib/protocol_spec.rb +5 -5
- data/spec/lib/danfe_lib/cep_spec.rb +5 -5
- data/spec/lib/danfe_lib/cst_spec.rb +8 -8
- data/spec/lib/danfe_lib/dest_spec.rb +23 -23
- data/spec/lib/danfe_lib/det_body_spec.rb +26 -26
- data/spec/lib/danfe_lib/document_spec.rb +25 -25
- data/spec/lib/danfe_lib/dup_spec.rb +4 -4
- data/spec/lib/danfe_lib/emit_header_spec.rb +13 -13
- data/spec/lib/danfe_lib/helper_spec.rb +74 -74
- data/spec/lib/danfe_lib/icmstot_spec.rb +4 -4
- data/spec/lib/danfe_lib/infadic_spec.rb +6 -13
- data/spec/lib/danfe_lib/infadic_vol_spec.rb +1 -4
- data/spec/lib/danfe_lib/issqn_spec.rb +11 -11
- data/spec/lib/danfe_lib/logo_options_spec.rb +18 -18
- data/spec/lib/danfe_lib/options_spec.rb +7 -7
- data/spec/lib/danfe_lib/phone_spec.rb +10 -10
- data/spec/lib/danfe_lib/plate_spec.rb +9 -9
- data/spec/lib/danfe_lib/ticket_spec.rb +4 -4
- data/spec/lib/danfe_lib/transp_spec.rb +10 -10
- data/spec/lib/danfe_lib/vol_spec.rb +7 -7
- data/spec/lib/danfe_lib/xml_spec.rb +5 -5
- data/spec/lib/danfe_lib/xprod_spec.rb +48 -50
- data/spec/lib/uf_spec.rb +12 -12
- data/spec/support/have_same_content_of.rb +6 -6
- metadata +40 -10
@@ -13,24 +13,25 @@ module BrDanfe
|
|
13
13
|
def render
|
14
14
|
nVol = 0
|
15
15
|
|
16
|
-
@xml.collect(
|
16
|
+
@xml.collect('xmlns', 'vol') do |det|
|
17
17
|
nVol += 1
|
18
18
|
render_vol(det) if nVol < 2
|
19
19
|
end
|
20
20
|
|
21
|
-
render_blank_boxes if nVol
|
21
|
+
render_blank_boxes if nVol.zero?
|
22
22
|
|
23
23
|
nVol
|
24
24
|
end
|
25
25
|
|
26
26
|
private
|
27
|
+
|
27
28
|
def render_vol(det)
|
28
|
-
@pdf.ibox 0.85, 2.42, 0.75, @l1, I18n.t(
|
29
|
-
@pdf.ibox 0.85, 3.05, 3.17, @l1, I18n.t(
|
30
|
-
@pdf.ibox 0.85, 3.05, 6.22, @l1, I18n.t(
|
31
|
-
@pdf.ibox 0.85, 4.83, 9.27, @l1, I18n.t(
|
32
|
-
@pdf.inumeric 0.85, 3.43, 14.10, @l1,
|
33
|
-
@pdf.inumeric 0.85, 2.80, 17.53, @l1,
|
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 }
|
34
35
|
end
|
35
36
|
|
36
37
|
def render_blank_boxes
|
@@ -11,18 +11,18 @@ module BrDanfe
|
|
11
11
|
|
12
12
|
def [](xpath)
|
13
13
|
node = @xml.css(xpath)
|
14
|
-
|
14
|
+
node ? node.text : ''
|
15
15
|
end
|
16
16
|
|
17
|
-
def collect(ns, tag
|
17
|
+
def collect(ns, tag)
|
18
18
|
result = []
|
19
|
-
#
|
19
|
+
# With namespace
|
20
20
|
begin
|
21
21
|
@xml.xpath("//#{ns}:#{tag}").each do |det|
|
22
22
|
result << yield(det)
|
23
23
|
end
|
24
|
-
rescue
|
25
|
-
#
|
24
|
+
rescue StandardError
|
25
|
+
# Without namespace
|
26
26
|
@xml.xpath("//#{tag}").each do |det|
|
27
27
|
result << yield(det)
|
28
28
|
end
|
@@ -31,7 +31,7 @@ module BrDanfe
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def version_is_310_or_newer?
|
34
|
-
@xml.css(
|
34
|
+
@xml.css('infNFe').attr('versao').to_s.to_f >= 3.10
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -6,9 +6,9 @@ module BrDanfe
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def render
|
9
|
-
xprod =
|
9
|
+
xprod = @det.css('prod/xProd').text.to_s
|
10
10
|
|
11
|
-
xprod += infAdProd if
|
11
|
+
xprod += infAdProd if infAdProd?
|
12
12
|
xprod += fci if fci?
|
13
13
|
xprod += icms_st if icms_st?
|
14
14
|
xprod += fcp if fcp?
|
@@ -24,13 +24,13 @@ module BrDanfe
|
|
24
24
|
"\n#{@det.css('infAdProd').text}"
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
!@det.css(
|
27
|
+
def infAdProd?
|
28
|
+
!@det.css('infAdProd').text.empty?
|
29
29
|
end
|
30
30
|
|
31
31
|
def fci
|
32
32
|
"\n#{I18n.t('danfe.det.prod.xProdFCI',
|
33
|
-
|
33
|
+
nFCI: @det.css('prod/nFCI').text)}"
|
34
34
|
end
|
35
35
|
|
36
36
|
def fci?
|
@@ -39,18 +39,18 @@ module BrDanfe
|
|
39
39
|
|
40
40
|
def icms_st
|
41
41
|
"\n#{I18n.t('danfe.det.prod.xProdST',
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
pMVAST: Helper.numerify(@det.css('ICMS/*/pMVAST').text),
|
43
|
+
pICMSST: Helper.numerify(@det.css('ICMS/*/pICMSST').text),
|
44
|
+
vBCST: Helper.numerify(@det.css('ICMS/*/vBCST').text),
|
45
|
+
vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text))}"
|
46
46
|
end
|
47
47
|
|
48
48
|
def icms_st?
|
49
|
-
@det.css('ICMS/*/vBCST').text.to_i
|
49
|
+
@det.css('ICMS/*/vBCST').text.to_i.positive?
|
50
50
|
end
|
51
51
|
|
52
52
|
def fcp?
|
53
|
-
@det.css('ICMS/*/vFCP').text.to_i
|
53
|
+
@det.css('ICMS/*/vFCP').text.to_i.positive?
|
54
54
|
end
|
55
55
|
|
56
56
|
def fcp
|
@@ -63,26 +63,26 @@ module BrDanfe
|
|
63
63
|
|
64
64
|
def fcp_for_icms00
|
65
65
|
"\n#{I18n.t('danfe.det.prod.xProdFCPICMS00',
|
66
|
-
|
67
|
-
|
66
|
+
vFCP: Helper.numerify(@det.css('ICMS00/vFCP').text),
|
67
|
+
pFCP: Helper.numerify(@det.css('ICMS00/pFCP').text))}"
|
68
68
|
end
|
69
69
|
|
70
70
|
def fcp_complete
|
71
71
|
"\n#{I18n.t('danfe.det.prod.xProdFCP',
|
72
|
-
|
73
|
-
|
74
|
-
|
72
|
+
vBCFCP: Helper.numerify(@det.css('ICMS/*/vBCFCP').text),
|
73
|
+
vFCP: Helper.numerify(@det.css('ICMS/*/vFCP').text),
|
74
|
+
pFCP: Helper.numerify(@det.css('ICMS/*/pFCP').text))}"
|
75
75
|
end
|
76
76
|
|
77
77
|
def fcp_st?
|
78
|
-
@det.css('ICMS/*/vFCPST').text.to_i
|
78
|
+
@det.css('ICMS/*/vFCPST').text.to_i.positive?
|
79
79
|
end
|
80
80
|
|
81
81
|
def fcp_st
|
82
82
|
"\n#{I18n.t('danfe.det.prod.xProdFCPST',
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
vBCFCPST: Helper.numerify(@det.css('ICMS/*/vBCFCPST').text),
|
84
|
+
pFCPST: Helper.numerify(@det.css('ICMS/*/pFCPST').text),
|
85
|
+
vFCPST: Helper.numerify(@det.css('ICMS/*/vFCPST').text))}"
|
86
86
|
end
|
87
87
|
|
88
88
|
def add_icms_st_ret_to_product
|
@@ -90,9 +90,8 @@ module BrDanfe
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def icms_st_ret?
|
93
|
-
@det.css('ICMS/*/vBCSTRet').text.to_i
|
94
|
-
@det.css('ICMS/*/
|
95
|
-
@det.css('ICMS/*/pST').text.to_i > 0
|
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?
|
96
95
|
end
|
97
96
|
|
98
97
|
def icms_st_ret
|
data/lib/br_danfe/uf.rb
CHANGED
@@ -5,10 +5,7 @@ module BrDanfe
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.all
|
8
|
-
|
9
|
-
AC AL AP AM BA CE DF ES GO MA MT MS MG PA PB PR PE PI RJ RN RS RO RR SC
|
10
|
-
SP SE TO
|
11
|
-
]
|
8
|
+
[:AC, :AL, :AP, :AM, :BA, :CE, :DF, :ES, :GO, :MA, :MT, :MS, :MG, :PA, :PB, :PR, :PE, :PI, :RJ, :RN, :RS, :RO, :RR, :SC, :SP, :SE, :TO]
|
12
9
|
end
|
13
10
|
private_class_method :all
|
14
11
|
end
|
data/lib/br_danfe/version.rb
CHANGED
data/spec/features/cce_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::Cce do
|
4
|
-
let(:base_dir) {
|
4
|
+
let(:base_dir) { './spec/fixtures/cce/v1.00/' }
|
5
5
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
6
6
|
let(:xml) { File.read("#{base_dir}cce.xml") }
|
7
7
|
subject { described_class.new(xml) }
|
8
8
|
|
9
|
-
describe
|
10
|
-
it
|
9
|
+
describe '#render_pdf' do
|
10
|
+
it 'renders the correction letter' do
|
11
11
|
expected = IO.binread("#{base_dir}cce.fixture.pdf")
|
12
12
|
|
13
13
|
expect(subject.render_pdf).to eq expected
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe '#save_pdf' do
|
18
18
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'saves the pdf' do
|
21
21
|
expect(File.exist?(output_pdf)).to be_falsey
|
22
22
|
|
23
23
|
subject.save_pdf output_pdf
|
data/spec/features/danfe_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe BrDanfe::Danfe do
|
4
4
|
let(:output_pdf) { "#{base_dir}output.pdf" }
|
5
5
|
|
6
|
-
describe
|
7
|
-
let(:base_dir) {
|
6
|
+
describe '#render_pdf' do
|
7
|
+
let(:base_dir) { './spec/fixtures/nfe/v3.10/' }
|
8
8
|
|
9
|
-
it
|
9
|
+
it 'renders a Simples Nacional NF-e using CSOSN' do
|
10
10
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
11
11
|
|
12
12
|
expected = IO.binread("#{base_dir}nfe_simples_nacional.xml.fixture.pdf")
|
@@ -15,17 +15,17 @@ describe BrDanfe::Danfe do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
context
|
20
|
-
let(:base_dir) {
|
18
|
+
describe '#save_pdf' do
|
19
|
+
context 'when danfe has custom options' do
|
20
|
+
let(:base_dir) { './spec/fixtures/nfe/v2.00/' }
|
21
21
|
|
22
22
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
23
23
|
|
24
|
-
it
|
24
|
+
it 'render a NF-e with customized options' do
|
25
25
|
expect(File.exist?(output_pdf)).to be_falsey
|
26
26
|
|
27
27
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}custom_options.fixture.xml"))
|
28
|
-
danfe.options.logo =
|
28
|
+
danfe.options.logo = 'spec/fixtures/logo.png'
|
29
29
|
danfe.options.logo_dimensions = { width: 100, height: 100 }
|
30
30
|
|
31
31
|
danfe.save_pdf output_pdf
|
@@ -35,11 +35,11 @@ describe BrDanfe::Danfe do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
context "when xml's version is v2.00" do
|
38
|
-
let(:base_dir) {
|
38
|
+
let(:base_dir) { './spec/fixtures/nfe/v2.00/' }
|
39
39
|
|
40
40
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
41
41
|
|
42
|
-
it
|
42
|
+
it 'renders a basic NF-e with namespace' do
|
43
43
|
expect(File.exist?(output_pdf)).to be_falsey
|
44
44
|
|
45
45
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_ns.xml"))
|
@@ -48,7 +48,7 @@ describe BrDanfe::Danfe do
|
|
48
48
|
expect("#{base_dir}nfe_with_ns.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
51
|
+
it 'renders another basic NF-e without namespace' do
|
52
52
|
expect(File.exist?(output_pdf)).to be_falsey
|
53
53
|
|
54
54
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_without_ns.xml"))
|
@@ -57,7 +57,7 @@ describe BrDanfe::Danfe do
|
|
57
57
|
expect("#{base_dir}nfe_without_ns.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
58
58
|
end
|
59
59
|
|
60
|
-
it
|
60
|
+
it 'renders a NF-e having FCI in its items' do
|
61
61
|
expect(File.exist?(output_pdf)).to be_falsey
|
62
62
|
|
63
63
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_fci.xml"))
|
@@ -66,7 +66,7 @@ describe BrDanfe::Danfe do
|
|
66
66
|
expect("#{base_dir}nfe_with_fci.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
69
|
+
it 'renders a Simples Nacional NF-e using CSOSN' do
|
70
70
|
expect(File.exist?(output_pdf)).to be_falsey
|
71
71
|
|
72
72
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
@@ -75,7 +75,7 @@ describe BrDanfe::Danfe do
|
|
75
75
|
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
76
76
|
end
|
77
77
|
|
78
|
-
it
|
78
|
+
it 'renders a NF-e with extra volumes' do
|
79
79
|
expect(File.exist?(output_pdf)).to be_falsey
|
80
80
|
|
81
81
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_with_extra_volumes.xml"))
|
@@ -86,11 +86,11 @@ describe BrDanfe::Danfe do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
context "when xml's version is v3.10" do
|
89
|
-
let(:base_dir) {
|
89
|
+
let(:base_dir) { './spec/fixtures/nfe/v3.10/' }
|
90
90
|
|
91
91
|
before { File.delete(output_pdf) if File.exist?(output_pdf) }
|
92
92
|
|
93
|
-
it
|
93
|
+
it 'renders a Simples Nacional NF-e using CSOSN' do
|
94
94
|
expect(File.exist?(output_pdf)).to be_falsey
|
95
95
|
|
96
96
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}nfe_simples_nacional.xml"))
|
@@ -99,8 +99,8 @@ describe BrDanfe::Danfe do
|
|
99
99
|
expect("#{base_dir}nfe_simples_nacional.xml.fixture.pdf").to have_same_content_of file: output_pdf
|
100
100
|
end
|
101
101
|
|
102
|
-
context
|
103
|
-
it
|
102
|
+
context 'when there are more than one page' do
|
103
|
+
it 'renders xml to the pdf' do
|
104
104
|
expect(File.exist?(output_pdf)).to be_falsey
|
105
105
|
|
106
106
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}with_three_pages.xml"))
|
@@ -110,8 +110,8 @@ describe BrDanfe::Danfe do
|
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
context
|
114
|
-
it
|
113
|
+
context 'when there is ISSQN' do
|
114
|
+
it 'renders xml to the pdf' do
|
115
115
|
expect(File.exist?(output_pdf)).to be_falsey
|
116
116
|
|
117
117
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}with_issqn.xml"))
|
@@ -122,7 +122,7 @@ describe BrDanfe::Danfe do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
context "when there isn't ISSQN" do
|
125
|
-
it
|
125
|
+
it 'renders xml to the pdf' do
|
126
126
|
expect(File.exist?(output_pdf)).to be_falsey
|
127
127
|
|
128
128
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}without_issqn.xml"))
|
@@ -132,11 +132,11 @@ describe BrDanfe::Danfe do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
context
|
136
|
-
it
|
135
|
+
context 'when there is footer information' do
|
136
|
+
it 'renders xml to the pdf' do
|
137
137
|
expect(File.exist?(output_pdf)).to be_falsey
|
138
138
|
|
139
|
-
footer =
|
139
|
+
footer = 'Gerado através do Teste'
|
140
140
|
danfe = BrDanfe::Danfe.new(File.read("#{base_dir}with_footer.xml"))
|
141
141
|
danfe.save_pdf output_pdf, footer
|
142
142
|
|
@@ -488,6 +488,10 @@ endobj
|
|
488
488
|
<< /Type /Page
|
489
489
|
/Parent 3 0 R
|
490
490
|
/MediaBox [0 0 595.28 841.89]
|
491
|
+
/CropBox [0 0 595.28 841.89]
|
492
|
+
/BleedBox [0 0 595.28 841.89]
|
493
|
+
/TrimBox [0 0 595.28 841.89]
|
494
|
+
/ArtBox [0 0 595.28 841.89]
|
491
495
|
/Contents 4 0 R
|
492
496
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
493
497
|
/Font << >>
|
@@ -508,5 +512,5 @@ trailer
|
|
508
512
|
/Info 1 0 R
|
509
513
|
>>
|
510
514
|
startxref
|
511
|
-
|
515
|
+
6362
|
512
516
|
%%EOF
|
@@ -67,6 +67,10 @@ endobj
|
|
67
67
|
<< /Type /Page
|
68
68
|
/Parent 3 0 R
|
69
69
|
/MediaBox [0 0 595.28 841.89]
|
70
|
+
/CropBox [0 0 595.28 841.89]
|
71
|
+
/BleedBox [0 0 595.28 841.89]
|
72
|
+
/TrimBox [0 0 595.28 841.89]
|
73
|
+
/ArtBox [0 0 595.28 841.89]
|
70
74
|
/Contents 4 0 R
|
71
75
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
72
76
|
/Font << /F1.0 6 0 R
|
@@ -89,12 +93,12 @@ xref
|
|
89
93
|
0000000158 00000 n
|
90
94
|
0000000215 00000 n
|
91
95
|
0000001556 00000 n
|
92
|
-
|
96
|
+
0000001852 00000 n
|
93
97
|
trailer
|
94
98
|
<< /Size 7
|
95
99
|
/Root 2 0 R
|
96
100
|
/Info 1 0 R
|
97
101
|
>>
|
98
102
|
startxref
|
99
|
-
|
103
|
+
1951
|
100
104
|
%%EOF
|
@@ -32,6 +32,10 @@ endobj
|
|
32
32
|
<< /Type /Page
|
33
33
|
/Parent 3 0 R
|
34
34
|
/MediaBox [0 0 595.28 841.89]
|
35
|
+
/CropBox [0 0 595.28 841.89]
|
36
|
+
/BleedBox [0 0 595.28 841.89]
|
37
|
+
/TrimBox [0 0 595.28 841.89]
|
38
|
+
/ArtBox [0 0 595.28 841.89]
|
35
39
|
/Contents 4 0 R
|
36
40
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
37
41
|
/Font << >>
|
@@ -52,5 +56,5 @@ trailer
|
|
52
56
|
/Info 1 0 R
|
53
57
|
>>
|
54
58
|
startxref
|
55
|
-
|
59
|
+
588
|
56
60
|
%%EOF
|
@@ -39,6 +39,10 @@ endobj
|
|
39
39
|
<< /Type /Page
|
40
40
|
/Parent 3 0 R
|
41
41
|
/MediaBox [0 0 595.28 841.89]
|
42
|
+
/CropBox [0 0 595.28 841.89]
|
43
|
+
/BleedBox [0 0 595.28 841.89]
|
44
|
+
/TrimBox [0 0 595.28 841.89]
|
45
|
+
/ArtBox [0 0 595.28 841.89]
|
42
46
|
/Contents 4 0 R
|
43
47
|
/Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
|
44
48
|
/Font << /F1.0 6 0 R
|
@@ -61,12 +65,12 @@ xref
|
|
61
65
|
0000000158 00000 n
|
62
66
|
0000000215 00000 n
|
63
67
|
0000000377 00000 n
|
64
|
-
|
68
|
+
0000000673 00000 n
|
65
69
|
trailer
|
66
70
|
<< /Size 7
|
67
71
|
/Root 2 0 R
|
68
72
|
/Info 1 0 R
|
69
73
|
>>
|
70
74
|
startxref
|
71
|
-
|
75
|
+
772
|
72
76
|
%%EOF
|