br_danfe 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +19 -16
- data/README.md +10 -4
- data/br_danfe.gemspec +3 -3
- data/config/locales/pt-BR.yml +3 -3
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +31 -18
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +23 -5
- data/lib/br_danfe/version.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +53 -3
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +234 -0
- data/spec/fixtures/cce/lib/barcode#render.pdf +14 -14
- data/spec/fixtures/cce/lib/correction#render.pdf +0 -0
- data/spec/fixtures/cce/lib/document#box.pdf +14 -14
- data/spec/fixtures/cce/lib/document#box.with.block.pdf +0 -0
- data/spec/fixtures/cce/lib/document#text.align.pdf +0 -0
- data/spec/fixtures/cce/lib/document#text.pad.pdf +0 -0
- data/spec/fixtures/cce/lib/document#text.simple.pdf +0 -0
- data/spec/fixtures/cce/lib/document#text.size.pdf +0 -0
- data/spec/fixtures/cce/lib/document#text.style.pdf +0 -0
- data/spec/fixtures/cce/lib/footer#render.pdf +0 -0
- data/spec/fixtures/cce/lib/header#render.pdf +0 -0
- data/spec/fixtures/cce/lib/nfe_key#render.pdf +0 -0
- data/spec/fixtures/cce/lib/protocol#render.pdf +0 -0
- data/spec/fixtures/cce/v1.00/cce.fixture.pdf +265 -149
- data/spec/fixtures/mdfe/lib/fisco_control#barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/fisco_control#without-barcode.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-qr-code.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-with_logo.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without-qr-code.pdf +0 -0
- data/spec/fixtures/mdfe/lib/header#render-without_logo.pdf +0 -0
- data/spec/fixtures/mdfe/lib/mdfe-with-multiple-pages.pdf +344 -176
- data/spec/fixtures/mdfe/lib/mdfe.fixture.pdf +336 -168
- data/spec/fixtures/mdfe/lib/notes#render-big-aditional-information.pdf +219 -151
- data/spec/fixtures/nfce/lib/document#render.pdf +20 -20
- data/spec/fixtures/nfce/lib/footer#render-with_additional_information.pdf +0 -0
- data/spec/fixtures/nfce/lib/footer#render.pdf +0 -0
- 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 +0 -0
- 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 +0 -0
- data/spec/fixtures/nfce/lib/key#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/nfce_identification#render.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_many_products_and_long_names.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product.pdf +0 -0
- data/spec/fixtures/nfce/lib/product_list#render-with_single_product_and_long_name.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-company.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-consumer_without_document.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-foreign.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-individual.pdf +0 -0
- data/spec/fixtures/nfce/lib/recipient#render-unidentified_consumer.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#does_not_render-payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-grouped_payment_methods.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-totals.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render-without_payment.pdf +0 -0
- data/spec/fixtures/nfce/lib/total_list#render.pdf +0 -0
- data/spec/fixtures/nfce/v4.00/multiples_xmls_on_the_same_pdf.pdf +336 -205
- 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 +144 -82
- data/spec/fixtures/nfe/lib/det_body#render-cst.pdf +129 -81
- data/spec/fixtures/nfe/lib/det_body#render-fci.pdf +124 -85
- data/spec/fixtures/nfe/lib/det_body#render-icms_st.pdf +133 -89
- data/spec/fixtures/nfe/lib/det_body#render-quantity_with_custom_precision.pdf +122 -84
- data/spec/fixtures/nfe/lib/det_body#render-three_pages.pdf +140 -85
- data/spec/fixtures/nfe/lib/det_body#render-two_pages.pdf +140 -85
- data/spec/fixtures/nfe/lib/det_body#render-unit_price_with_custom_precision.pdf +122 -84
- data/spec/fixtures/nfe/lib/det_body#render-with_entrega.pdf +118 -64
- data/spec/fixtures/nfe/lib/det_body#render-with_infadprod.pdf +131 -76
- data/spec/fixtures/nfe/lib/det_body#render-with_issqn.pdf +140 -85
- data/spec/fixtures/nfe/lib/det_body#render-without_issqn.pdf +140 -85
- 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-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/dup#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/emit_header#render-nfe_key.pdf +283 -151
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +283 -151
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +283 -151
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +264 -132
- data/spec/fixtures/nfe/lib/entrega#render-v2.00.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with-address-bigger.pdf +0 -0
- data/spec/fixtures/nfe/lib/entrega#render-with_cpf.pdf +0 -0
- data/spec/fixtures/nfe/lib/icmstot#render-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/icmstot#render.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_dup_additional_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-without_dup_additional_information.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_entrega.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/issqn#render-without_issqn.pdf +14 -14
- data/spec/fixtures/nfe/lib/ticket#render.pdf +0 -0
- data/spec/fixtures/nfe/lib/ticket#render_with_dEmit.pdf +0 -0
- data/spec/fixtures/nfe/lib/ticket#render_with_dhEmit.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-with_entrega.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-with_entrega.pdf +0 -0
- data/spec/fixtures/nfe/lib/vol#render.pdf +0 -0
- data/spec/fixtures/nfe/v2.00/custom_options.fixture.pdf +448 -355
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +424 -331
- data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml.fixture.pdf +427 -331
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +568 -251
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +468 -270
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +472 -284
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +458 -159
- data/spec/fixtures/nfe/v3.10/multiples.xmls.on.the.same.pdf.pdf +600 -340
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +456 -280
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +473 -311
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +458 -274
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +485 -306
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +469 -290
- data/spec/fixtures/qr_code/qr_code#render.pdf +0 -0
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b80a670ecd1d7c56bd346ad493a91e28d9b9f58aeff96e2feff598c56ac06d
|
4
|
+
data.tar.gz: a7fc99c996a113d9a0cade611c1f965ec0854313294004a026b772483b2cc765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d07ec3c1a879cf644791ed3eda0212e9e50dc25259deb5d52172f71f19f48a69955588034d4f36ca165e3ccbf58202e530a4fb8d311494c62907dc2c28e5211
|
7
|
+
data.tar.gz: 1333a3e830b1d8f3cd53d21dc7d9612153182fb381930a9bd9a773ea1e27c47a25e2d1da07a1da3dc3808ad74960a39436cdc16e32d27fd9e1d24561263bf4b0
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
br_danfe (1.2.
|
4
|
+
br_danfe (1.2.3)
|
5
5
|
barby (= 0.6.9)
|
6
6
|
br_documents (>= 0.1.3)
|
7
7
|
i18n (>= 0.8.6)
|
8
8
|
nokogiri (>= 1.8)
|
9
|
-
prawn (~> 2.
|
9
|
+
prawn (~> 2.5.0)
|
10
10
|
prawn-table (= 0.2.2)
|
11
11
|
rqrcode (>= 2.1, < 2.3)
|
12
12
|
|
@@ -43,9 +43,9 @@ GEM
|
|
43
43
|
docile (1.4.1)
|
44
44
|
drb (2.2.0)
|
45
45
|
ruby2_keywords
|
46
|
-
ffi (1.
|
46
|
+
ffi (1.17.0)
|
47
47
|
formatador (1.1.0)
|
48
|
-
guard (2.
|
48
|
+
guard (2.19.0)
|
49
49
|
formatador (>= 0.2.4)
|
50
50
|
listen (>= 2.7, < 4.0)
|
51
51
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -62,11 +62,12 @@ GEM
|
|
62
62
|
hashery (2.1.2)
|
63
63
|
i18n (1.14.5)
|
64
64
|
concurrent-ruby (~> 1.0)
|
65
|
-
listen (3.
|
65
|
+
listen (3.9.0)
|
66
66
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
67
67
|
rb-inotify (~> 0.9, >= 0.9.10)
|
68
68
|
lumberjack (1.2.10)
|
69
|
-
|
69
|
+
matrix (0.4.2)
|
70
|
+
method_source (1.1.0)
|
70
71
|
mini_portile2 (2.8.7)
|
71
72
|
minitest (5.21.2)
|
72
73
|
mutex_m (0.2.0)
|
@@ -80,7 +81,7 @@ GEM
|
|
80
81
|
parallel (1.21.0)
|
81
82
|
parser (3.0.2.0)
|
82
83
|
ast (~> 2.4.1)
|
83
|
-
pdf-core (0.
|
84
|
+
pdf-core (0.10.0)
|
84
85
|
pdf-inspector (1.3.0)
|
85
86
|
pdf-reader (>= 1.0, < 3.0.a)
|
86
87
|
pdf-reader (2.5.0)
|
@@ -89,9 +90,10 @@ GEM
|
|
89
90
|
hashery (~> 2.0)
|
90
91
|
ruby-rc4
|
91
92
|
ttfunk
|
92
|
-
prawn (2.
|
93
|
-
|
94
|
-
|
93
|
+
prawn (2.5.0)
|
94
|
+
matrix (~> 0.4)
|
95
|
+
pdf-core (~> 0.10.0)
|
96
|
+
ttfunk (~> 1.8)
|
95
97
|
prawn-table (0.2.2)
|
96
98
|
prawn (>= 1.3.0, < 3.0.0)
|
97
99
|
pry (0.14.2)
|
@@ -101,7 +103,7 @@ GEM
|
|
101
103
|
rainbow (3.0.0)
|
102
104
|
rake (13.2.1)
|
103
105
|
rb-fsevent (0.11.2)
|
104
|
-
rb-inotify (0.
|
106
|
+
rb-inotify (0.11.1)
|
105
107
|
ffi (~> 1.0)
|
106
108
|
regexp_parser (2.1.1)
|
107
109
|
rexml (3.3.3)
|
@@ -148,11 +150,12 @@ GEM
|
|
148
150
|
docile (~> 1.1)
|
149
151
|
simplecov-html (~> 0.11)
|
150
152
|
simplecov_json_formatter (~> 0.1)
|
151
|
-
simplecov-html (0.
|
153
|
+
simplecov-html (0.13.1)
|
152
154
|
simplecov_json_formatter (0.1.4)
|
153
155
|
strscan (3.1.0)
|
154
|
-
thor (1.3.
|
155
|
-
ttfunk (1.
|
156
|
+
thor (1.3.2)
|
157
|
+
ttfunk (1.8.0)
|
158
|
+
bigdecimal (~> 3.1)
|
156
159
|
tzinfo (2.0.6)
|
157
160
|
concurrent-ruby (~> 1.0)
|
158
161
|
unicode-display_width (1.8.0)
|
@@ -163,7 +166,7 @@ PLATFORMS
|
|
163
166
|
DEPENDENCIES
|
164
167
|
br_danfe!
|
165
168
|
byebug (= 11.1.3)
|
166
|
-
guard (~> 2.
|
169
|
+
guard (~> 2.19.0)
|
167
170
|
guard-rspec (~> 4.7.3)
|
168
171
|
pdf-inspector (~> 1.3.0)
|
169
172
|
rake (= 13.2.1)
|
@@ -172,7 +175,7 @@ DEPENDENCIES
|
|
172
175
|
rubocop-performance (~> 1.10.2)
|
173
176
|
rubocop-rspec (~> 1.44.1)
|
174
177
|
simplecov (= 0.22.0)
|
175
|
-
simplecov-html (= 0.
|
178
|
+
simplecov-html (= 0.13.1)
|
176
179
|
|
177
180
|
BUNDLED WITH
|
178
181
|
2.5.5
|
data/README.md
CHANGED
@@ -229,18 +229,24 @@ You can generate new data using [4devs generators](http://www.4devs.com.br).
|
|
229
229
|
|
230
230
|
## Deploy to Rubygems
|
231
231
|
|
232
|
-
1.
|
232
|
+
1. To deploy a new version:
|
233
233
|
|
234
|
-
|
234
|
+
* Define the new version at `lib/br_danfe/version.rb`;
|
235
|
+
* Execute `$ bundle`;
|
236
|
+
* Commit all and push to Github;
|
235
237
|
|
236
|
-
2.
|
238
|
+
2. Send the new version to Rubygems
|
239
|
+
|
240
|
+
* $ bundle exec rake release
|
241
|
+
|
242
|
+
3. Create a [new release on Github](https://github.com/asseinfo/br_danfe/releases/new)
|
237
243
|
|
238
244
|
* Choose **the new tag** (Ex.: v0.10.1)
|
239
245
|
* Fill the **Release title** (Ex.: 0.10.1)
|
240
246
|
* Click at **Generate release notes**
|
241
247
|
* Click at **Publish release**
|
242
248
|
|
243
|
-
|
249
|
+
4. Done!
|
244
250
|
|
245
251
|
You can build or install the gem using one of the above tasks
|
246
252
|
|
data/br_danfe.gemspec
CHANGED
@@ -20,12 +20,12 @@ Gem::Specification.new do |spec|
|
|
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.
|
23
|
+
spec.add_dependency 'prawn', '~> 2.5.0'
|
24
24
|
spec.add_dependency 'prawn-table', '0.2.2'
|
25
25
|
spec.add_dependency 'rqrcode', '>= 2.1', '< 2.3'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'byebug', '11.1.3'
|
28
|
-
spec.add_development_dependency 'guard', '~> 2.
|
28
|
+
spec.add_development_dependency 'guard', '~> 2.19.0'
|
29
29
|
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
30
30
|
spec.add_development_dependency 'pdf-inspector', '~> 1.3.0'
|
31
31
|
spec.add_development_dependency 'rake', '13.2.1'
|
@@ -34,5 +34,5 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'rubocop-performance', '~> 1.10.2'
|
35
35
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
|
36
36
|
spec.add_development_dependency 'simplecov', '0.22.0'
|
37
|
-
spec.add_development_dependency 'simplecov-html', '0.
|
37
|
+
spec.add_development_dependency 'simplecov-html', '0.13.1'
|
38
38
|
end
|
data/config/locales/pt-BR.yml
CHANGED
@@ -5,6 +5,7 @@ module BrDanfe
|
|
5
5
|
attr_reader :y_position
|
6
6
|
|
7
7
|
Y_POSITION = 12.92
|
8
|
+
DUP_MAX_QUANTITY = 12
|
8
9
|
|
9
10
|
def initialize(pdf, xml)
|
10
11
|
@pdf = pdf
|
@@ -16,28 +17,44 @@ module BrDanfe
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def render
|
19
|
-
@pdf.ititle 0.42, 10.00, 0.75, @ltitle, 'dup.title'
|
20
|
-
@pdf.ibox 0.85, 19.57, 0.75, @y_position
|
21
|
-
|
22
20
|
x = 0.75
|
23
21
|
y = @y_position
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
|
23
|
+
@pdf.ititle 0.42, 10.00, x, @ltitle, 'dup.title'
|
24
|
+
|
25
|
+
render_titles_and_box(x, y)
|
26
|
+
|
27
|
+
@xml.collect('xmlns', 'dup') { _1 }[..(DUP_MAX_QUANTITY - 1)].each_with_index do |det, index|
|
28
|
+
x = 0.75 unless index != DUP_MAX_QUANTITY / 2
|
29
|
+
|
30
|
+
y = if index < DUP_MAX_QUANTITY / 2
|
31
|
+
@y_position - 0.015
|
32
|
+
else
|
33
|
+
@y_position + 0.185
|
34
|
+
end
|
35
|
+
|
36
|
+
render_dup(det, x, y + 0.3)
|
37
|
+
x += 3.261666667
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
30
41
|
private
|
31
42
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
def render_titles_and_box(x, y)
|
44
|
+
(DUP_MAX_QUANTITY / 2).times do
|
45
|
+
@pdf.ibox 0.30, 3.261666667, x, y
|
46
|
+
@pdf.ibox 0.60, 3.261666667, x, y + 0.30
|
47
|
+
@pdf.ibox 0.85, 1.80, x, y - 0.05, '', I18n.t('danfe.dup.nDup'), normal
|
48
|
+
@pdf.ibox 0.85, 1.80, x + 0.87, y - 0.05, '', I18n.t('danfe.dup.dVenc'), normal
|
49
|
+
@pdf.ibox 0.85, 1.80, x + 2.35, y - 0.05, '', I18n.t('danfe.dup.vDup'), normal
|
50
|
+
x += 3.261666667
|
51
|
+
end
|
52
|
+
end
|
38
53
|
|
39
|
-
|
40
|
-
@pdf.
|
54
|
+
def render_dup(det, x, y)
|
55
|
+
@pdf.ibox 0.85, 2.12, x + 0.1, y, '', det.css('nDup').text, normal
|
56
|
+
@pdf.ibox 0.85, 2.12, x + 0.75, y, '', dtduplicata(det), normal
|
57
|
+
@pdf.inumeric 0.85, 2.12, x + 1.1, y, '', det.css('vDup').text, normal
|
41
58
|
end
|
42
59
|
|
43
60
|
def dtduplicata(det)
|
@@ -48,10 +65,6 @@ module BrDanfe
|
|
48
65
|
def normal
|
49
66
|
{ size: 6, border: 0 }
|
50
67
|
end
|
51
|
-
|
52
|
-
def italic
|
53
|
-
normal.merge(style: :italic)
|
54
|
-
end
|
55
68
|
end
|
56
69
|
end
|
57
70
|
end
|
@@ -15,7 +15,7 @@ module BrDanfe
|
|
15
15
|
render_title
|
16
16
|
render_subtitle
|
17
17
|
render_volumes if volumes_number > 1
|
18
|
-
render_additional_data generate_y_position(volumes_number) if
|
18
|
+
render_additional_data generate_y_position(volumes_number) if complementary? || address? || difal? || fisco? || dup_content.to_s.present?
|
19
19
|
render_reserved_fisco
|
20
20
|
end
|
21
21
|
|
@@ -44,6 +44,7 @@ module BrDanfe
|
|
44
44
|
additional_data.push(address_content) if address?
|
45
45
|
additional_data.push(difal_content) if difal?
|
46
46
|
additional_data.push(fisco_content) if fisco?
|
47
|
+
additional_data.push(dup_content) if dup_content.any?
|
47
48
|
additional_data.join(' * ')
|
48
49
|
end
|
49
50
|
|
@@ -89,6 +90,27 @@ module BrDanfe
|
|
89
90
|
@xml['infAdic/infAdFisco'].to_s.present?
|
90
91
|
end
|
91
92
|
|
93
|
+
def format_dup_date(_det, dup_date)
|
94
|
+
dtduplicata = dup_date
|
95
|
+
"#{dtduplicata[8, 2]}/#{dtduplicata[5, 2]}/#{dtduplicata[0, 4]}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def dup_content
|
99
|
+
value_dups = []
|
100
|
+
|
101
|
+
@xml.collect('xmlns', 'dup') { _1 }[NfeLib::Dup::DUP_MAX_QUANTITY..]&.each_with_index do |det, index|
|
102
|
+
value = "#{det.css('nDup').text} - #{format_dup_date(det, det.css('dVenc').text)} - R$ #{BrDanfe::Helper.numerify(det.css('vDup').text.to_f)}"
|
103
|
+
|
104
|
+
if index.zero?
|
105
|
+
value_dups.push("Faturas: #{value}")
|
106
|
+
elsif index.positive?
|
107
|
+
value_dups.push(value.to_s)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
value_dups
|
112
|
+
end
|
113
|
+
|
92
114
|
def generate_y_position(volumes_number)
|
93
115
|
if volumes_number > 1
|
94
116
|
return Y_POSITION + 0.30 + volumes_number * 0.15 + 0.2
|
@@ -97,10 +119,6 @@ module BrDanfe
|
|
97
119
|
Y_POSITION + 0.30
|
98
120
|
end
|
99
121
|
|
100
|
-
def additional_data?
|
101
|
-
complementary? || address? || difal? || fisco?
|
102
|
-
end
|
103
|
-
|
104
122
|
def render_reserved_fisco
|
105
123
|
@pdf.ibox 2.65, 7.15, 13.20, @y_position, I18n.t('danfe.infAdic.reserved')
|
106
124
|
end
|
data/lib/br_danfe/version.rb
CHANGED
@@ -56,17 +56,67 @@ describe BrDanfe::DanfeLib::NfeLib::Dup do
|
|
56
56
|
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
57
57
|
<cobr>
|
58
58
|
<dup>
|
59
|
-
<nDup>
|
59
|
+
<nDup>001</nDup>
|
60
60
|
<dVenc>2015-02-13</dVenc>
|
61
61
|
<vDup>25.56</vDup>
|
62
62
|
</dup>
|
63
63
|
<dup>
|
64
|
-
<nDup>
|
64
|
+
<nDup>002</nDup>
|
65
65
|
<dVenc>2015-03-15</dVenc>
|
66
66
|
<vDup>25.56</vDup>
|
67
67
|
</dup>
|
68
68
|
<dup>
|
69
|
-
<nDup>
|
69
|
+
<nDup>003</nDup>
|
70
|
+
<dVenc>2015-04-14</dVenc>
|
71
|
+
<vDup>25.55</vDup>
|
72
|
+
</dup>
|
73
|
+
<dup>
|
74
|
+
<nDup>004</nDup>
|
75
|
+
<dVenc>2015-02-13</dVenc>
|
76
|
+
<vDup>25.56</vDup>
|
77
|
+
</dup>
|
78
|
+
<dup>
|
79
|
+
<nDup>005</nDup>
|
80
|
+
<dVenc>2015-03-15</dVenc>
|
81
|
+
<vDup>25.56</vDup>
|
82
|
+
</dup>
|
83
|
+
<dup>
|
84
|
+
<nDup>006</nDup>
|
85
|
+
<dVenc>2015-04-14</dVenc>
|
86
|
+
<vDup>25.55</vDup>
|
87
|
+
</dup>
|
88
|
+
<dup>
|
89
|
+
<nDup>007</nDup>
|
90
|
+
<dVenc>2015-02-13</dVenc>
|
91
|
+
<vDup>25.56</vDup>
|
92
|
+
</dup>
|
93
|
+
<dup>
|
94
|
+
<nDup>008</nDup>
|
95
|
+
<dVenc>2015-03-15</dVenc>
|
96
|
+
<vDup>25.56</vDup>
|
97
|
+
</dup>
|
98
|
+
<dup>
|
99
|
+
<nDup>009</nDup>
|
100
|
+
<dVenc>2015-04-14</dVenc>
|
101
|
+
<vDup>25.55</vDup>
|
102
|
+
</dup>
|
103
|
+
<dup>
|
104
|
+
<nDup>010</nDup>
|
105
|
+
<dVenc>2015-02-13</dVenc>
|
106
|
+
<vDup>25.56</vDup>
|
107
|
+
</dup>
|
108
|
+
<dup>
|
109
|
+
<nDup>011</nDup>
|
110
|
+
<dVenc>2015-03-15</dVenc>
|
111
|
+
<vDup>25.56</vDup>
|
112
|
+
</dup>
|
113
|
+
<dup>
|
114
|
+
<nDup>012</nDup>
|
115
|
+
<dVenc>2015-04-14</dVenc>
|
116
|
+
<vDup>25.55</vDup>
|
117
|
+
</dup>
|
118
|
+
<dup>
|
119
|
+
<nDup>013</nDup>
|
70
120
|
<dVenc>2015-04-14</dVenc>
|
71
121
|
<vDup>25.55</vDup>
|
72
122
|
</dup>
|
@@ -262,6 +262,168 @@ describe BrDanfe::DanfeLib::NfeLib::Infadic do
|
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
|
+
context 'when has too much dups' do
|
266
|
+
let(:xml_as_string) do
|
267
|
+
<<~XML
|
268
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
269
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
270
|
+
<cobr>
|
271
|
+
<dup>
|
272
|
+
<nDup>001</nDup>
|
273
|
+
<dVenc>2015-02-13</dVenc>
|
274
|
+
<vDup>25.56</vDup>
|
275
|
+
</dup>
|
276
|
+
<dup>
|
277
|
+
<nDup>002</nDup>
|
278
|
+
<dVenc>2015-03-15</dVenc>
|
279
|
+
<vDup>25.56</vDup>
|
280
|
+
</dup>
|
281
|
+
<dup>
|
282
|
+
<nDup>003</nDup>
|
283
|
+
<dVenc>2015-04-14</dVenc>
|
284
|
+
<vDup>25.55</vDup>
|
285
|
+
</dup>
|
286
|
+
<dup>
|
287
|
+
<nDup>004</nDup>
|
288
|
+
<dVenc>2015-04-14</dVenc>
|
289
|
+
<vDup>25.55</vDup>
|
290
|
+
</dup>
|
291
|
+
<dup>
|
292
|
+
<nDup>005</nDup>
|
293
|
+
<dVenc>2015-02-13</dVenc>
|
294
|
+
<vDup>25.56</vDup>
|
295
|
+
</dup>
|
296
|
+
<dup>
|
297
|
+
<nDup>006</nDup>
|
298
|
+
<dVenc>2015-03-15</dVenc>
|
299
|
+
<vDup>25.56</vDup>
|
300
|
+
</dup>
|
301
|
+
<dup>
|
302
|
+
<nDup>007</nDup>
|
303
|
+
<dVenc>2015-04-14</dVenc>
|
304
|
+
<vDup>25.55</vDup>
|
305
|
+
</dup>
|
306
|
+
<dup>
|
307
|
+
<nDup>008</nDup>
|
308
|
+
<dVenc>2015-04-14</dVenc>
|
309
|
+
<vDup>25.55</vDup>
|
310
|
+
</dup>
|
311
|
+
<dup>
|
312
|
+
<nDup>009</nDup>
|
313
|
+
<dVenc>2015-02-13</dVenc>
|
314
|
+
<vDup>25.56</vDup>
|
315
|
+
</dup>
|
316
|
+
<dup>
|
317
|
+
<nDup>010</nDup>
|
318
|
+
<dVenc>2015-03-15</dVenc>
|
319
|
+
<vDup>25.56</vDup>
|
320
|
+
</dup>
|
321
|
+
<dup>
|
322
|
+
<nDup>011</nDup>
|
323
|
+
<dVenc>2015-04-14</dVenc>
|
324
|
+
<vDup>25.55</vDup>
|
325
|
+
</dup>
|
326
|
+
<dup>
|
327
|
+
<nDup>012</nDup>
|
328
|
+
<dVenc>2015-04-14</dVenc>
|
329
|
+
<vDup>25.55</vDup>
|
330
|
+
</dup>
|
331
|
+
<dup>
|
332
|
+
<nDup>013</nDup>
|
333
|
+
<dVenc>2015-04-14</dVenc>
|
334
|
+
<vDup>25.55</vDup>
|
335
|
+
</dup>
|
336
|
+
<dup>
|
337
|
+
<nDup>014</nDup>
|
338
|
+
<dVenc>2015-04-14</dVenc>
|
339
|
+
<vDup>25.55</vDup>
|
340
|
+
</dup>
|
341
|
+
</cobr>
|
342
|
+
</infNFe>
|
343
|
+
</NFe>
|
344
|
+
XML
|
345
|
+
end
|
346
|
+
|
347
|
+
it 'renders title with box, subtitle, dup box and additional information about dup on the pdf' do
|
348
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
349
|
+
|
350
|
+
pdf.render_file output_pdf
|
351
|
+
|
352
|
+
expect("#{base_dir}infadic#render-with_dup_additional_information.pdf").to have_same_content_of file: output_pdf
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
context 'when has less than NfeLib::Dup::DUP_MAX_QUANTITY dups' do
|
357
|
+
let(:xml_as_string) do
|
358
|
+
<<~XML
|
359
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
360
|
+
<infNFe Id="NFe25111012345678901234550020000134151000134151" versao="2.00">
|
361
|
+
<cobr>
|
362
|
+
<dup>
|
363
|
+
<nDup>001</nDup>
|
364
|
+
<dVenc>2015-02-13</dVenc>
|
365
|
+
<vDup>25.56</vDup>
|
366
|
+
</dup>
|
367
|
+
<dup>
|
368
|
+
<nDup>002</nDup>
|
369
|
+
<dVenc>2015-03-15</dVenc>
|
370
|
+
<vDup>25.56</vDup>
|
371
|
+
</dup>
|
372
|
+
<dup>
|
373
|
+
<nDup>003</nDup>
|
374
|
+
<dVenc>2015-04-14</dVenc>
|
375
|
+
<vDup>25.55</vDup>
|
376
|
+
</dup>
|
377
|
+
<dup>
|
378
|
+
<nDup>004</nDup>
|
379
|
+
<dVenc>2015-04-14</dVenc>
|
380
|
+
<vDup>25.55</vDup>
|
381
|
+
</dup>
|
382
|
+
<dup>
|
383
|
+
<nDup>005</nDup>
|
384
|
+
<dVenc>2015-02-13</dVenc>
|
385
|
+
<vDup>25.56</vDup>
|
386
|
+
</dup>
|
387
|
+
<dup>
|
388
|
+
<nDup>006</nDup>
|
389
|
+
<dVenc>2015-03-15</dVenc>
|
390
|
+
<vDup>25.56</vDup>
|
391
|
+
</dup>
|
392
|
+
<dup>
|
393
|
+
<nDup>007</nDup>
|
394
|
+
<dVenc>2015-04-14</dVenc>
|
395
|
+
<vDup>25.55</vDup>
|
396
|
+
</dup>
|
397
|
+
<dup>
|
398
|
+
<nDup>008</nDup>
|
399
|
+
<dVenc>2015-04-14</dVenc>
|
400
|
+
<vDup>25.55</vDup>
|
401
|
+
</dup>
|
402
|
+
<dup>
|
403
|
+
<nDup>009</nDup>
|
404
|
+
<dVenc>2015-02-13</dVenc>
|
405
|
+
<vDup>25.56</vDup>
|
406
|
+
</dup>
|
407
|
+
<dup>
|
408
|
+
<nDup>010</nDup>
|
409
|
+
<dVenc>2015-03-15</dVenc>
|
410
|
+
<vDup>25.56</vDup>
|
411
|
+
</dup>
|
412
|
+
</cobr>
|
413
|
+
</infNFe>
|
414
|
+
</NFe>
|
415
|
+
XML
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'renders title with box, subtitle and additional information without dup on the pdf' do
|
419
|
+
expect(File.exist?(output_pdf)).to be_falsey
|
420
|
+
|
421
|
+
pdf.render_file output_pdf
|
422
|
+
|
423
|
+
expect("#{base_dir}infadic#render-without_dup_additional_information.pdf").to have_same_content_of file: output_pdf
|
424
|
+
end
|
425
|
+
end
|
426
|
+
|
265
427
|
context 'when has extra volume' do
|
266
428
|
let(:xml_as_string) do
|
267
429
|
<<~XML
|
@@ -388,6 +550,78 @@ describe BrDanfe::DanfeLib::NfeLib::Infadic do
|
|
388
550
|
<pesoB>3300.000</pesoB>
|
389
551
|
</vol>
|
390
552
|
</transp>
|
553
|
+
<cobr>
|
554
|
+
<dup>
|
555
|
+
<nDup>001</nDup>
|
556
|
+
<dVenc>2015-02-13</dVenc>
|
557
|
+
<vDup>25.56</vDup>
|
558
|
+
</dup>
|
559
|
+
<dup>
|
560
|
+
<nDup>002</nDup>
|
561
|
+
<dVenc>2015-03-15</dVenc>
|
562
|
+
<vDup>25.56</vDup>
|
563
|
+
</dup>
|
564
|
+
<dup>
|
565
|
+
<nDup>003</nDup>
|
566
|
+
<dVenc>2015-04-14</dVenc>
|
567
|
+
<vDup>25.55</vDup>
|
568
|
+
</dup>
|
569
|
+
<dup>
|
570
|
+
<nDup>004</nDup>
|
571
|
+
<dVenc>2015-04-14</dVenc>
|
572
|
+
<vDup>25.55</vDup>
|
573
|
+
</dup>
|
574
|
+
<dup>
|
575
|
+
<nDup>005</nDup>
|
576
|
+
<dVenc>2015-02-13</dVenc>
|
577
|
+
<vDup>25.56</vDup>
|
578
|
+
</dup>
|
579
|
+
<dup>
|
580
|
+
<nDup>006</nDup>
|
581
|
+
<dVenc>2015-03-15</dVenc>
|
582
|
+
<vDup>25.56</vDup>
|
583
|
+
</dup>
|
584
|
+
<dup>
|
585
|
+
<nDup>007</nDup>
|
586
|
+
<dVenc>2015-04-14</dVenc>
|
587
|
+
<vDup>25.55</vDup>
|
588
|
+
</dup>
|
589
|
+
<dup>
|
590
|
+
<nDup>008</nDup>
|
591
|
+
<dVenc>2015-04-14</dVenc>
|
592
|
+
<vDup>25.55</vDup>
|
593
|
+
</dup>
|
594
|
+
<dup>
|
595
|
+
<nDup>009</nDup>
|
596
|
+
<dVenc>2015-02-13</dVenc>
|
597
|
+
<vDup>25.56</vDup>
|
598
|
+
</dup>
|
599
|
+
<dup>
|
600
|
+
<nDup>010</nDup>
|
601
|
+
<dVenc>2015-03-15</dVenc>
|
602
|
+
<vDup>25.56</vDup>
|
603
|
+
</dup>
|
604
|
+
<dup>
|
605
|
+
<nDup>011</nDup>
|
606
|
+
<dVenc>2015-04-14</dVenc>
|
607
|
+
<vDup>25.55</vDup>
|
608
|
+
</dup>
|
609
|
+
<dup>
|
610
|
+
<nDup>012</nDup>
|
611
|
+
<dVenc>2015-04-14</dVenc>
|
612
|
+
<vDup>25.55</vDup>
|
613
|
+
</dup>
|
614
|
+
<dup>
|
615
|
+
<nDup>013</nDup>
|
616
|
+
<dVenc>2015-04-14</dVenc>
|
617
|
+
<vDup>25.55</vDup>
|
618
|
+
</dup>
|
619
|
+
<dup>
|
620
|
+
<nDup>014</nDup>
|
621
|
+
<dVenc>2015-04-14</dVenc>
|
622
|
+
<vDup>25.55</vDup>
|
623
|
+
</dup>
|
624
|
+
</cobr>
|
391
625
|
<infAdic>
|
392
626
|
<infCpl>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec congue in dolor sed sagittis.</infCpl>
|
393
627
|
<infAdFisco>Total de FCP-ST: 348,96</infAdFisco>
|