br_danfe 0.14.2 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +23 -21
- data/README.md +16 -0
- data/br_danfe.gemspec +2 -2
- data/config/locales/pt-BR.yml +1 -0
- data/lib/br_danfe/danfe.rb +8 -5
- data/lib/br_danfe/danfe_lib/base.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfce.rb +14 -12
- data/lib/br_danfe/danfe_lib/nfe.rb +39 -27
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +4 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/xprod.rb +5 -5
- data/lib/br_danfe/helper.rb +6 -0
- data/lib/br_danfe/version.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +12 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfe_lib/xprod_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfe_spec.rb +17 -1
- data/spec/br_danfe/danfe_spec.rb +16 -0
- data/spec/fixtures/cce/lib/barcode#render.pdf +5 -3
- data/spec/fixtures/cce/v1.00/cce.fixture.pdf +15 -13
- data/spec/fixtures/nfce/lib/document#render.pdf +17 -17
- data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +12 -12
- data/spec/fixtures/nfce/lib/footer#render.pdf +10 -10
- data/spec/fixtures/nfce/lib/header#render-homologation.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-long_name_with_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-long_name_without_logo.pdf +16 -16
- data/spec/fixtures/nfce/lib/header#render-short_name_with_logo.pdf +0 -0
- data/spec/fixtures/nfce/lib/header#render-short_name_without_logo.pdf +16 -16
- data/spec/fixtures/nfce/lib/key#render.pdf +14 -14
- data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +16 -16
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +43 -43
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +47 -47
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +25 -25
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +27 -27
- data/spec/fixtures/nfce/lib/qr_code#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-company.pdf +13 -13
- data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +12 -12
- data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +13 -13
- data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +13 -13
- data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +11 -11
- data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +19 -19
- data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +26 -26
- data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +19 -19
- data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +28 -28
- data/spec/fixtures/nfce/lib/total_list#render.pdf +28 -28
- data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +1229 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-hom.fixture.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/nfce-unauthorized-prod.fixture.pdf +0 -0
- 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/dest#render-v2.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-v3.10.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-v4.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with-address-bigger.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_cnpj.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_cpf.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-with_ie.pdf +0 -0
- data/spec/fixtures/nfe/lib/dest#render-without-address-complement.pdf +0 -0
- data/spec/fixtures/nfe/lib/det_body#render-csosn.pdf +662 -662
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +410 -410
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +272 -272
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +272 -272
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +270 -270
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +6213 -6213
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +6083 -6083
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +270 -270
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +272 -272
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +2859 -2859
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +2859 -2859
- data/spec/fixtures/nfe/lib/document#lcnpj-blank.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lcnpj-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lcnpj-valid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-blank-uf-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-blank.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-invalid.pdf +0 -0
- data/spec/fixtures/nfe/lib/document#lie-valid.pdf +0 -0
- data/spec/fixtures/nfe/lib/dup#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +511 -509
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +510 -508
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +507 -505
- data/spec/fixtures/nfe/lib/icmstot#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#address-shipment.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-all_the_informations.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-difal.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-extra_volume.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_complementary_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_fisco_additional_information.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render-with_street_data.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/infadic_vol#render-extra_volume.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_issqn.pdf +0 -0
- data/spec/fixtures/nfe/lib/issqn#render-with_one_issqn_value.pdf +0 -0
- data/spec/fixtures/nfe/lib/ticket#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_0.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_1.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_2.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_3.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_4.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render-modfrete_9.pdf +0 -0
- data/spec/fixtures/nfe/lib/transp#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render-blank-boxes.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render.pdf +0 -0
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +733 -733
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +730 -730
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +3449 -3445
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +929 -927
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +3424 -3420
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +1178 -1176
- data/spec/fixtures/nfe/v3.10/multiples.xmls.on.the.same.pdf.pdf +11471 -0
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +1495 -1495
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +2444 -2444
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +2142 -2142
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +7096 -7096
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +2811 -2811
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 210c7c1c3a0ea98ed48753e1432c91ae8f4795400d5df40d7d9c2e0a91d4c502
|
4
|
+
data.tar.gz: 611c666027eca9cac90640753446085f58b4b9deacc43c8d0df5f7150d623a1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c04ab16fdac8a9285024a018b2c23cdd5d65c6e2748b8cafa9e97ec67cf10f49cc0e0766a475e060f2c65793a6400795988e299d6931bd4cacb2ed01d18092f
|
7
|
+
data.tar.gz: b894f40fba2376bd795beadfbf47dabe2db2c9d7a40e69c728d29550397c6df2baf14acb39ff73cface9df9ffd2de7832b2762647ccf2ab6715134fcfb740c82
|
data/Gemfile.lock
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
br_danfe (0.
|
5
|
-
barby (= 0.
|
4
|
+
br_danfe (0.15.1)
|
5
|
+
barby (= 0.6.8)
|
6
6
|
br_documents (>= 0.1.3)
|
7
7
|
i18n (>= 0.8.6)
|
8
8
|
nokogiri (>= 1.8)
|
9
|
-
prawn (~> 2.0)
|
9
|
+
prawn (~> 2.4.0)
|
10
10
|
prawn-table (= 0.2.2)
|
11
11
|
rqrcode (~> 1.1.1)
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
activemodel (6.1.
|
17
|
-
activesupport (= 6.1.
|
18
|
-
activesupport (6.1.
|
16
|
+
activemodel (6.1.3.2)
|
17
|
+
activesupport (= 6.1.3.2)
|
18
|
+
activesupport (6.1.3.2)
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
20
|
i18n (>= 1.6, < 2)
|
21
21
|
minitest (>= 5.1)
|
22
22
|
tzinfo (~> 2.0)
|
23
23
|
zeitwerk (~> 2.3)
|
24
24
|
ast (2.4.0)
|
25
|
-
barby (0.
|
26
|
-
br_documents (0.
|
25
|
+
barby (0.6.8)
|
26
|
+
br_documents (0.2.0)
|
27
27
|
activemodel (>= 4.0.0)
|
28
28
|
i18n (>= 0.6.5)
|
29
29
|
byebug (11.1.3)
|
30
|
-
chunky_png (1.
|
30
|
+
chunky_png (1.4.0)
|
31
31
|
coderay (1.1.3)
|
32
|
-
concurrent-ruby (1.1.
|
32
|
+
concurrent-ruby (1.1.9)
|
33
33
|
diff-lcs (1.4.4)
|
34
34
|
docile (1.3.2)
|
35
35
|
ffi (1.13.1)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
guard (~> 2.1)
|
49
49
|
guard-compat (~> 1.1)
|
50
50
|
rspec (>= 2.99.0, < 4.0)
|
51
|
-
i18n (1.8.
|
51
|
+
i18n (1.8.10)
|
52
52
|
concurrent-ruby (~> 1.0)
|
53
53
|
jaro_winkler (1.5.4)
|
54
54
|
json (2.3.0)
|
@@ -57,27 +57,29 @@ GEM
|
|
57
57
|
rb-inotify (~> 0.9, >= 0.9.10)
|
58
58
|
lumberjack (1.2.8)
|
59
59
|
method_source (1.0.0)
|
60
|
-
mini_portile2 (2.
|
61
|
-
minitest (5.14.
|
60
|
+
mini_portile2 (2.5.3)
|
61
|
+
minitest (5.14.4)
|
62
62
|
nenv (0.3.0)
|
63
|
-
nokogiri (1.
|
64
|
-
mini_portile2 (~> 2.
|
63
|
+
nokogiri (1.11.7)
|
64
|
+
mini_portile2 (~> 2.5.0)
|
65
|
+
racc (~> 1.4)
|
65
66
|
notiffany (0.1.3)
|
66
67
|
nenv (~> 0.1)
|
67
68
|
shellany (~> 0.0)
|
68
69
|
parallel (1.19.1)
|
69
70
|
parser (2.7.0.4)
|
70
71
|
ast (~> 2.4.0)
|
71
|
-
pdf-core (0.
|
72
|
-
prawn (2.
|
73
|
-
pdf-core (~> 0.
|
74
|
-
ttfunk (~> 1.
|
72
|
+
pdf-core (0.9.0)
|
73
|
+
prawn (2.4.0)
|
74
|
+
pdf-core (~> 0.9.0)
|
75
|
+
ttfunk (~> 1.7)
|
75
76
|
prawn-table (0.2.2)
|
76
77
|
prawn (>= 1.3.0, < 3.0.0)
|
77
78
|
pry (0.13.1)
|
78
79
|
coderay (~> 1.1)
|
79
80
|
method_source (~> 1.0)
|
80
81
|
psych (3.1.0)
|
82
|
+
racc (1.5.2)
|
81
83
|
rainbow (3.0.0)
|
82
84
|
rake (13.0.1)
|
83
85
|
rb-fsevent (0.10.4)
|
@@ -86,7 +88,7 @@ GEM
|
|
86
88
|
rqrcode (1.1.2)
|
87
89
|
chunky_png (~> 1.0)
|
88
90
|
rqrcode_core (~> 0.1)
|
89
|
-
rqrcode_core (0.
|
91
|
+
rqrcode_core (0.2.0)
|
90
92
|
rspec (3.10.0)
|
91
93
|
rspec-core (~> 3.10.0)
|
92
94
|
rspec-expectations (~> 3.10.0)
|
@@ -118,7 +120,7 @@ GEM
|
|
118
120
|
simplecov-html (~> 0.10.0)
|
119
121
|
simplecov-html (0.10.2)
|
120
122
|
thor (1.0.1)
|
121
|
-
ttfunk (1.
|
123
|
+
ttfunk (1.7.0)
|
122
124
|
tzinfo (2.0.4)
|
123
125
|
concurrent-ruby (~> 1.0)
|
124
126
|
unicode-display_width (1.5.0)
|
data/README.md
CHANGED
@@ -45,6 +45,22 @@ XML version | Supported?
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
#### Usage in Rails Controller with more than one xml
|
49
|
+
class DanfeController < ApplicationController
|
50
|
+
def new
|
51
|
+
invoices = Invoice.where(ids: params[:ids])
|
52
|
+
xmls_as_string = []
|
53
|
+
|
54
|
+
invoices.each do |invoice|
|
55
|
+
xmls_as_string << invoice.generate_xml # your method that generates the NF-e's xml
|
56
|
+
end
|
57
|
+
|
58
|
+
danfe = BrDanfe::Danfe.new(xmls_as_string)
|
59
|
+
|
60
|
+
send_data danfe.render_pdf, filename: "danfe.pdf", type: "application/pdf"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
48
64
|
### Options
|
49
65
|
|
50
66
|
* `logo_path`: Path of sender's logo image.
|
data/br_danfe.gemspec
CHANGED
@@ -16,11 +16,11 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.5.1'
|
18
18
|
|
19
|
-
spec.add_dependency 'barby', '0.
|
19
|
+
spec.add_dependency 'barby', '0.6.8'
|
20
20
|
spec.add_dependency 'br_documents', '>= 0.1.3'
|
21
21
|
spec.add_dependency 'i18n', '>= 0.8.6'
|
22
22
|
spec.add_dependency 'nokogiri', '>= 1.8'
|
23
|
-
spec.add_dependency 'prawn', '~> 2.0'
|
23
|
+
spec.add_dependency 'prawn', '~> 2.4.0'
|
24
24
|
spec.add_dependency 'prawn-table', '0.2.2'
|
25
25
|
spec.add_dependency 'rqrcode', '~> 1.1.1'
|
26
26
|
|
data/config/locales/pt-BR.yml
CHANGED
data/lib/br_danfe/danfe.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
module BrDanfe
|
2
2
|
class Danfe
|
3
|
-
def self.new(
|
4
|
-
|
3
|
+
def self.new(xmls)
|
4
|
+
xmls = [xmls] unless xmls.is_a?(Array)
|
5
|
+
|
6
|
+
parsed_xmls = xmls.map { |xml| BrDanfe::XML.new(xml) }
|
7
|
+
|
8
|
+
create_danfe(parsed_xmls)
|
5
9
|
end
|
6
10
|
|
7
|
-
def self.create_danfe(
|
8
|
-
|
9
|
-
xml['ide > mod'] == nfe_code ? DanfeLib::Nfe.new(xml) : DanfeLib::Nfce.new(xml)
|
11
|
+
def self.create_danfe(xmls)
|
12
|
+
BrDanfe::Helper.nfe?(xmls.first) ? DanfeLib::Nfe.new(xmls) : DanfeLib::Nfce.new(xmls)
|
10
13
|
end
|
11
14
|
private_class_method :create_danfe
|
12
15
|
end
|
@@ -24,21 +24,23 @@ module BrDanfe
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def generate(footer_info)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
@xmls.each do |xml|
|
28
|
+
NfceLib::Header.new(@document, xml, @options.logo, @options.logo_dimensions).render
|
29
|
+
NfceLib::ProductList.new(@document, xml).render
|
30
|
+
NfceLib::TotalList.new(@document, xml).render
|
31
|
+
NfceLib::Key.new(@document, xml).render
|
32
|
+
NfceLib::Recipient.new(@document, xml).render
|
33
|
+
NfceLib::NfceIdentification.new(@document, xml).render
|
34
|
+
NfceLib::QrCode.new(@document, xml).render
|
35
|
+
NfceLib::Footer.new(@document, xml).render(footer_info)
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
render_no_fiscal_value(xml)
|
38
|
+
resize_page_height
|
39
|
+
end
|
38
40
|
end
|
39
41
|
|
40
|
-
def render_no_fiscal_value
|
41
|
-
@document.stamp('has_no_fiscal_value') if BrDanfe::Helper.unauthorized?(
|
42
|
+
def render_no_fiscal_value(xml)
|
43
|
+
@document.stamp('has_no_fiscal_value') if BrDanfe::Helper.unauthorized?(xml)
|
42
44
|
end
|
43
45
|
|
44
46
|
def resize_page_height
|
@@ -23,45 +23,57 @@ module BrDanfe
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def generate(footer_info)
|
26
|
-
|
27
|
-
|
26
|
+
last_index = @xmls.size - 1
|
27
|
+
|
28
|
+
@xmls.each_with_index do |xml, index|
|
29
|
+
break unless BrDanfe::Helper.nfe?(xml)
|
30
|
+
|
31
|
+
initial_number_of_pages = @document.page_count
|
32
|
+
render_on_first_page(xml)
|
33
|
+
render_on_each_page(footer_info, xml, initial_number_of_pages)
|
34
|
+
@document.start_new_page unless index == last_index
|
35
|
+
end
|
36
|
+
|
28
37
|
@document
|
29
38
|
end
|
30
39
|
|
31
|
-
def render_on_first_page
|
32
|
-
NfeLib::Ticket.new(@document,
|
33
|
-
NfeLib::Dest.new(@document,
|
34
|
-
NfeLib::Dup.new(@document,
|
35
|
-
NfeLib::Icmstot.new(@document,
|
36
|
-
NfeLib::Transp.new(@document,
|
37
|
-
n_vol = NfeLib::Vol.new(@document,
|
38
|
-
has_issqn = NfeLib::Issqn.new(@document,
|
39
|
-
NfeLib::Infadic.new(@document,
|
40
|
-
|
41
|
-
render_products
|
40
|
+
def render_on_first_page(xml)
|
41
|
+
NfeLib::Ticket.new(@document, xml).render
|
42
|
+
NfeLib::Dest.new(@document, xml).render
|
43
|
+
NfeLib::Dup.new(@document, xml).render
|
44
|
+
NfeLib::Icmstot.new(@document, xml).render
|
45
|
+
NfeLib::Transp.new(@document, xml).render
|
46
|
+
n_vol = NfeLib::Vol.new(@document, xml).render
|
47
|
+
has_issqn = NfeLib::Issqn.new(@document, xml).render
|
48
|
+
NfeLib::Infadic.new(@document, xml).render(n_vol)
|
49
|
+
|
50
|
+
render_products(has_issqn, xml)
|
42
51
|
end
|
43
52
|
|
44
|
-
def render_products(has_issqn)
|
45
|
-
NfeLib::DetBody.new(@document,
|
53
|
+
def render_products(has_issqn, xml)
|
54
|
+
NfeLib::DetBody.new(@document, xml).render(has_issqn)
|
46
55
|
end
|
47
56
|
|
48
|
-
def render_on_each_page(footer_info)
|
49
|
-
|
57
|
+
def render_on_each_page(footer_info, xml, initial_number_of_pages)
|
58
|
+
total_pages = @document.page_count + 1 - initial_number_of_pages
|
59
|
+
|
60
|
+
emitter = NfeLib::EmitHeader.new(@document, xml, @options.logo, @options.logo_dimensions)
|
61
|
+
|
62
|
+
total_pages.times do |page_index|
|
63
|
+
page = page_index + initial_number_of_pages
|
50
64
|
|
51
|
-
|
52
|
-
page
|
53
|
-
position = page == 1 ? 3.96 : 1.85
|
54
|
-
repeated_information page, position, emitter, footer_info
|
65
|
+
position = page_index + 1 == 1 ? 3.96 : 1.85
|
66
|
+
repeated_information(page, position, emitter, footer_info, xml, total_pages, page_index + 1)
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
58
|
-
def repeated_information(page, y_position, emitter, footer_info)
|
70
|
+
def repeated_information(page, y_position, emitter, footer_info, xml, total_pages, initial_page_of_pdf)
|
59
71
|
@document.go_to_page(page)
|
60
72
|
|
61
|
-
emitter.render
|
62
|
-
render_product_table_title
|
73
|
+
emitter.render(initial_page_of_pdf, y_position, total_pages)
|
74
|
+
render_product_table_title initial_page_of_pdf
|
63
75
|
render_footer_information footer_info
|
64
|
-
render_no_fiscal_value
|
76
|
+
render_no_fiscal_value(xml)
|
65
77
|
end
|
66
78
|
|
67
79
|
def render_product_table_title(page)
|
@@ -75,8 +87,8 @@ module BrDanfe
|
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
78
|
-
def render_no_fiscal_value
|
79
|
-
@document.stamp('has_no_fiscal_value') if BrDanfe::Helper.no_fiscal_value?(
|
90
|
+
def render_no_fiscal_value(xml)
|
91
|
+
@document.stamp('has_no_fiscal_value') if BrDanfe::Helper.no_fiscal_value?(xml)
|
80
92
|
end
|
81
93
|
end
|
82
94
|
end
|
@@ -9,10 +9,10 @@ module BrDanfe
|
|
9
9
|
@logo_dimensions = logo_dimensions
|
10
10
|
end
|
11
11
|
|
12
|
-
def render(page, y_position)
|
12
|
+
def render(page, y_position, total)
|
13
13
|
@y_position = y_position
|
14
14
|
company_box
|
15
|
-
danfe_box
|
15
|
+
danfe_box(page, total)
|
16
16
|
access_key_box
|
17
17
|
sefaz_box
|
18
18
|
render_emit y_position
|
@@ -64,7 +64,7 @@ module BrDanfe
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def danfe_box(page)
|
67
|
+
def danfe_box(page, total)
|
68
68
|
@pdf.ibox 3.92, 2.08, 8.21, @y_position
|
69
69
|
|
70
70
|
@pdf.ibox 0.60, 2.08, 8.21, @y_position, '', 'DANFE',
|
@@ -83,7 +83,7 @@ module BrDanfe
|
|
83
83
|
size: 8, align: :center, valign: :center, border: 0, style: :bold
|
84
84
|
|
85
85
|
@pdf.ibox 1.00, 2.08, 8.21, @y_position + 3.00, '',
|
86
|
-
I18n.t('danfe.others.page', current: page, total:
|
86
|
+
I18n.t('danfe.others.page', current: page, total: total),
|
87
87
|
size: 8, align: :center, valign: :center, border: 0, style: :bold
|
88
88
|
end
|
89
89
|
|
@@ -47,11 +47,11 @@ module BrDanfe
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def icms_st?
|
50
|
-
@det.css('ICMS/*/vBCST').text.
|
50
|
+
@det.css('ICMS/*/vBCST').text.to_f.positive?
|
51
51
|
end
|
52
52
|
|
53
53
|
def fcp?
|
54
|
-
@det.css('ICMS/*/vFCP').text.
|
54
|
+
@det.css('ICMS/*/vFCP').text.to_f.positive?
|
55
55
|
end
|
56
56
|
|
57
57
|
def fcp
|
@@ -76,7 +76,7 @@ module BrDanfe
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def fcp_st?
|
79
|
-
@det.css('ICMS/*/vFCPST').text.
|
79
|
+
@det.css('ICMS/*/vFCPST').text.to_f.positive?
|
80
80
|
end
|
81
81
|
|
82
82
|
def fcp_st
|
@@ -91,8 +91,8 @@ module BrDanfe
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def icms_st_ret?
|
94
|
-
@det.css('ICMS/*/vBCSTRet').text.
|
95
|
-
@det.css('ICMS/*/pST').text.
|
94
|
+
@det.css('ICMS/*/vBCSTRet').text.to_f.positive? || @det.css('ICMS/*/vICMSSTRet').text.to_f.positive? ||
|
95
|
+
@det.css('ICMS/*/pST').text.to_f.positive?
|
96
96
|
end
|
97
97
|
|
98
98
|
def icms_st_ret
|
data/lib/br_danfe/helper.rb
CHANGED
data/lib/br_danfe/version.rb
CHANGED
@@ -5,7 +5,7 @@ describe BrDanfe::DanfeLib::Nfce do
|
|
5
5
|
let(:base_dir) { './spec/fixtures/nfce/v4.00/' }
|
6
6
|
let(:xml) { BrDanfe::XML.new(File.read("#{base_dir}nfce.xml")) }
|
7
7
|
|
8
|
-
subject { described_class.new xml }
|
8
|
+
subject { described_class.new [xml] }
|
9
9
|
|
10
10
|
before do
|
11
11
|
subject.options.logo = 'spec/fixtures/logo.png'
|
@@ -53,5 +53,16 @@ describe BrDanfe::DanfeLib::Nfce do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
context 'when there is more than one xml' do
|
58
|
+
it 'renders multiple danfes on the same pdf' do
|
59
|
+
subject = described_class.new [xml, xml]
|
60
|
+
|
61
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
62
|
+
subject.save_pdf output_pdf
|
63
|
+
|
64
|
+
expect("#{base_dir}multiples_xmls_on_the_same_pdf.pdf").to have_same_content_of file: output_pdf
|
65
|
+
end
|
66
|
+
end
|
56
67
|
end
|
57
68
|
end
|