br_danfe 1.2.3 → 2.1.0
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/.github/workflows/config.yml +5 -7
- data/Gemfile +15 -0
- data/Gemfile.lock +45 -27
- data/br_danfe.gemspec +1 -12
- data/config/locales/pt-BR.yml +4 -3
- data/lib/br_danfe/cce_lib/document.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfce_lib/document.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfce_lib/header.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +2 -10
- data/lib/br_danfe/danfe_lib/nfe_lib/document.rb +9 -9
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +9 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/entrega.rb +2 -10
- data/lib/br_danfe/danfe_lib/nfe_lib/infadic.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/transp.rb +1 -1
- data/lib/br_danfe/document_builder.rb +2 -2
- data/lib/br_danfe/logo_options.rb +1 -1
- data/lib/br_danfe/mdfe_lib/document.rb +2 -2
- data/lib/br_danfe/version.rb +1 -1
- data/lib/br_danfe.rb +1 -1
- data/lib/prawn/font.rb +1 -1
- data/spec/br_danfe/cce_lib/barcode_spec.rb +1 -1
- data/spec/br_danfe/cce_lib/correction_spec.rb +1 -1
- data/spec/br_danfe/cce_lib/document_spec.rb +7 -7
- data/spec/br_danfe/cce_lib/footer_spec.rb +1 -1
- data/spec/br_danfe/cce_lib/header_spec.rb +1 -1
- data/spec/br_danfe/cce_lib/nfe_key_spec.rb +1 -1
- data/spec/br_danfe/cce_lib/protocol_spec.rb +1 -1
- data/spec/br_danfe/cce_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/document_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/footer_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/header_spec.rb +2 -2
- data/spec/br_danfe/danfe_lib/nfce_lib/key_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/nfce_identification_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/product_list_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/recipient_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_lib/total_list_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfce_spec.rb +3 -3
- data/spec/br_danfe/danfe_lib/nfe_lib/dest_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/det_body_spec.rb +8 -8
- data/spec/br_danfe/danfe_lib/nfe_lib/document_spec.rb +9 -9
- data/spec/br_danfe/danfe_lib/nfe_lib/dup_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +66 -3
- data/spec/br_danfe/danfe_lib/nfe_lib/entrega_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/icmstot_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/infadic_vol_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/ticket_spec.rb +3 -3
- data/spec/br_danfe/danfe_lib/nfe_lib/transp_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/vol_spec.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_spec.rb +6 -6
- data/spec/br_danfe/mdfe_lib/fisco_control_spec.rb +1 -1
- data/spec/br_danfe/mdfe_lib/header_spec.rb +1 -1
- data/spec/br_danfe/mdfe_lib/notes_spec.rb +1 -1
- data/spec/br_danfe/mdfe_spec.rb +2 -2
- data/spec/br_danfe/qr_code_spec.rb +1 -1
- data/spec/fixtures/nfe/lib/emit_header#render-nfe_key.pdf +16 -16
- data/spec/fixtures/nfe/lib/emit_header#render-second_page.pdf +16 -16
- data/spec/fixtures/nfe/lib/emit_header#render-with_cpf.pdf +1075 -2
- data/spec/fixtures/nfe/lib/emit_header#render-with_logo.pdf +16 -16
- data/spec/fixtures/nfe/lib/emit_header#render-without_logo.pdf +14 -14
- 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/v2.00/custom_options.fixture.pdf +17 -17
- data/spec/fixtures/nfe/v2.00/nfe_simples_nacional.xml.fixture.pdf +15 -15
- data/spec/fixtures/nfe/v2.00/nfe_with_entrega.xml.fixture.pdf +16 -16
- data/spec/fixtures/nfe/v2.00/nfe_with_extra_volumes.xml.fixture.pdf +24 -24
- data/spec/fixtures/nfe/v2.00/nfe_with_fci.xml.fixture.pdf +15 -15
- data/spec/fixtures/nfe/v2.00/nfe_with_ns.xml.fixture.pdf +19 -19
- data/spec/fixtures/nfe/v2.00/nfe_without_ns.xml.fixture.pdf +15 -15
- data/spec/fixtures/nfe/v3.10/multiples.xmls.on.the.same.pdf.pdf +19 -19
- data/spec/fixtures/nfe/v3.10/nfe_simples_nacional.xml.fixture.pdf +15 -15
- data/spec/fixtures/nfe/v3.10/with_footer.fixture.pdf +19 -19
- data/spec/fixtures/nfe/v3.10/with_issqn.fixture.pdf +15 -15
- data/spec/fixtures/nfe/v3.10/with_three_pages.fixture.pdf +23 -23
- data/spec/fixtures/nfe/v3.10/without_issqn.fixture.pdf +19 -19
- data/spec/spec_helper.rb +9 -1
- metadata +8 -160
- /data/spec/fixtures/nfe/lib/{document#lcnpj-blank.pdf → document#lcnpj_cpf-blank.pdf} +0 -0
- /data/spec/fixtures/nfe/lib/{document#lcnpj-invalid.pdf → document#lcnpj_cpf-invalid.pdf} +0 -0
- /data/spec/fixtures/nfe/lib/{document#lcnpj-valid.pdf → document#lcnpj_cpf-valid.pdf} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 262bed0c378422071afeb0a12ce50e4c4f4a5633266dd7893f2d0c280316a55e
|
|
4
|
+
data.tar.gz: 412bdf1269d5d8c542d1ce5504e3b219621215da71019c3e37b0441ddb06d28f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 811c26b219e61e7a125e9c212ee3750c3ab6016ae6937456397acafd9dce1a03da762f2f50b645b8784ed6c6f8334159933f9aae7b681857e9b439816936cc51
|
|
7
|
+
data.tar.gz: f396a32db9d675a68b87d62aa12d412e73930251c6278d3361cd34db6b7ba7a76048f4c8250335663dca19bac263dddde56f1a6a7506855469a8b715d09daa13
|
|
@@ -7,7 +7,7 @@ jobs:
|
|
|
7
7
|
strategy:
|
|
8
8
|
fail-fast: false # I understand this is to run on all versions.
|
|
9
9
|
matrix:
|
|
10
|
-
ruby: ['3.
|
|
10
|
+
ruby: ['3.3.5']
|
|
11
11
|
|
|
12
12
|
runs-on: ubuntu-latest
|
|
13
13
|
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
strategy:
|
|
26
26
|
fail-fast: false # I understand this is to run on all versions.
|
|
27
27
|
matrix:
|
|
28
|
-
ruby: ['3.
|
|
28
|
+
ruby: ['3.3.5']
|
|
29
29
|
|
|
30
30
|
runs-on: ubuntu-latest
|
|
31
31
|
|
|
@@ -38,12 +38,10 @@ jobs:
|
|
|
38
38
|
bundler-cache: true
|
|
39
39
|
|
|
40
40
|
- run: |
|
|
41
|
-
curl
|
|
42
|
-
chmod +x ./cc-test-reporter
|
|
41
|
+
curl https://qlty.sh | sh
|
|
43
42
|
|
|
44
43
|
- run: |
|
|
45
|
-
./cc-test-reporter before-build
|
|
46
44
|
bundle exec rspec
|
|
47
|
-
|
|
45
|
+
~/.qlty/bin/qlty coverage publish coverage/coverage.json
|
|
48
46
|
env:
|
|
49
|
-
|
|
47
|
+
QLTY_COVERAGE_TOKEN: ${{secrets.QLTY_COVERAGE_TOKEN}}
|
data/Gemfile
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
gemspec
|
|
4
|
+
|
|
5
|
+
group :development, :test do
|
|
6
|
+
gem 'byebug', '11.1.3'
|
|
7
|
+
gem 'guard', '~> 2.19.0'
|
|
8
|
+
gem 'guard-rspec', '~> 4.7.3'
|
|
9
|
+
gem 'pdf-inspector', '~> 1.3.0'
|
|
10
|
+
gem 'rake', '13.2.1'
|
|
11
|
+
gem 'rspec', '3.13.0'
|
|
12
|
+
gem 'rubocop', '~> 1.75.3'
|
|
13
|
+
gem 'rubocop-performance', '~> 1.19.0'
|
|
14
|
+
gem 'rubocop-rspec', '~> 2.25.0'
|
|
15
|
+
gem 'simplecov', '0.22.0'
|
|
16
|
+
gem 'simplecov-html', '0.13.1'
|
|
17
|
+
gem 'simplecov-json', '0.2.3'
|
|
18
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
br_danfe (1.
|
|
4
|
+
br_danfe (2.1.0)
|
|
5
5
|
barby (= 0.6.9)
|
|
6
6
|
br_documents (>= 0.1.3)
|
|
7
7
|
i18n (>= 0.8.6)
|
|
@@ -27,7 +27,7 @@ GEM
|
|
|
27
27
|
mutex_m
|
|
28
28
|
tzinfo (~> 2.0)
|
|
29
29
|
afm (0.2.2)
|
|
30
|
-
ast (2.4.
|
|
30
|
+
ast (2.4.3)
|
|
31
31
|
barby (0.6.9)
|
|
32
32
|
base64 (0.2.0)
|
|
33
33
|
bigdecimal (3.1.6)
|
|
@@ -62,6 +62,9 @@ GEM
|
|
|
62
62
|
hashery (2.1.2)
|
|
63
63
|
i18n (1.14.5)
|
|
64
64
|
concurrent-ruby (~> 1.0)
|
|
65
|
+
json (2.11.3)
|
|
66
|
+
language_server-protocol (3.17.0.4)
|
|
67
|
+
lint_roller (1.1.0)
|
|
65
68
|
listen (3.9.0)
|
|
66
69
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
67
70
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
@@ -78,9 +81,10 @@ GEM
|
|
|
78
81
|
notiffany (0.1.3)
|
|
79
82
|
nenv (~> 0.1)
|
|
80
83
|
shellany (~> 0.0)
|
|
81
|
-
parallel (1.
|
|
82
|
-
parser (3.
|
|
84
|
+
parallel (1.27.0)
|
|
85
|
+
parser (3.3.8.0)
|
|
83
86
|
ast (~> 2.4.1)
|
|
87
|
+
racc
|
|
84
88
|
pdf-core (0.10.0)
|
|
85
89
|
pdf-inspector (1.3.0)
|
|
86
90
|
pdf-reader (>= 1.0, < 3.0.a)
|
|
@@ -96,18 +100,17 @@ GEM
|
|
|
96
100
|
ttfunk (~> 1.8)
|
|
97
101
|
prawn-table (0.2.2)
|
|
98
102
|
prawn (>= 1.3.0, < 3.0.0)
|
|
103
|
+
prism (1.4.0)
|
|
99
104
|
pry (0.14.2)
|
|
100
105
|
coderay (~> 1.1)
|
|
101
106
|
method_source (~> 1.0)
|
|
102
107
|
racc (1.8.1)
|
|
103
|
-
rainbow (3.
|
|
108
|
+
rainbow (3.1.1)
|
|
104
109
|
rake (13.2.1)
|
|
105
110
|
rb-fsevent (0.11.2)
|
|
106
111
|
rb-inotify (0.11.1)
|
|
107
112
|
ffi (~> 1.0)
|
|
108
|
-
regexp_parser (2.
|
|
109
|
-
rexml (3.3.3)
|
|
110
|
-
strscan
|
|
113
|
+
regexp_parser (2.10.0)
|
|
111
114
|
rqrcode (2.2.0)
|
|
112
115
|
chunky_png (~> 1.0)
|
|
113
116
|
rqrcode_core (~> 1.0)
|
|
@@ -125,24 +128,34 @@ GEM
|
|
|
125
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
126
129
|
rspec-support (~> 3.13.0)
|
|
127
130
|
rspec-support (3.13.1)
|
|
128
|
-
rubocop (
|
|
131
|
+
rubocop (1.75.3)
|
|
132
|
+
json (~> 2.3)
|
|
133
|
+
language_server-protocol (~> 3.17.0.2)
|
|
134
|
+
lint_roller (~> 1.1.0)
|
|
129
135
|
parallel (~> 1.10)
|
|
130
|
-
parser (>=
|
|
136
|
+
parser (>= 3.3.0.2)
|
|
131
137
|
rainbow (>= 2.2.2, < 4.0)
|
|
132
|
-
regexp_parser (>=
|
|
133
|
-
|
|
134
|
-
rubocop-ast (>= 0.6.0)
|
|
138
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
139
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
135
140
|
ruby-progressbar (~> 1.7)
|
|
136
|
-
unicode-display_width (>=
|
|
137
|
-
rubocop-ast (1.
|
|
138
|
-
parser (>= 3.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
142
|
+
rubocop-ast (1.44.1)
|
|
143
|
+
parser (>= 3.3.7.2)
|
|
144
|
+
prism (~> 1.4)
|
|
145
|
+
rubocop-capybara (2.22.1)
|
|
146
|
+
lint_roller (~> 1.1)
|
|
147
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
148
|
+
rubocop-factory_bot (2.27.1)
|
|
149
|
+
lint_roller (~> 1.1)
|
|
150
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
151
|
+
rubocop-performance (1.19.1)
|
|
152
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
141
153
|
rubocop-ast (>= 0.4.0)
|
|
142
|
-
rubocop-rspec (
|
|
143
|
-
rubocop (~>
|
|
144
|
-
rubocop-
|
|
145
|
-
|
|
154
|
+
rubocop-rspec (2.25.0)
|
|
155
|
+
rubocop (~> 1.40)
|
|
156
|
+
rubocop-capybara (~> 2.17)
|
|
157
|
+
rubocop-factory_bot (~> 2.22)
|
|
158
|
+
ruby-progressbar (1.13.0)
|
|
146
159
|
ruby-rc4 (0.1.5)
|
|
147
160
|
ruby2_keywords (0.0.5)
|
|
148
161
|
shellany (0.0.1)
|
|
@@ -151,14 +164,18 @@ GEM
|
|
|
151
164
|
simplecov-html (~> 0.11)
|
|
152
165
|
simplecov_json_formatter (~> 0.1)
|
|
153
166
|
simplecov-html (0.13.1)
|
|
167
|
+
simplecov-json (0.2.3)
|
|
168
|
+
json
|
|
169
|
+
simplecov
|
|
154
170
|
simplecov_json_formatter (0.1.4)
|
|
155
|
-
strscan (3.1.0)
|
|
156
171
|
thor (1.3.2)
|
|
157
172
|
ttfunk (1.8.0)
|
|
158
173
|
bigdecimal (~> 3.1)
|
|
159
174
|
tzinfo (2.0.6)
|
|
160
175
|
concurrent-ruby (~> 1.0)
|
|
161
|
-
unicode-display_width (1.
|
|
176
|
+
unicode-display_width (3.1.4)
|
|
177
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
178
|
+
unicode-emoji (4.0.4)
|
|
162
179
|
|
|
163
180
|
PLATFORMS
|
|
164
181
|
ruby
|
|
@@ -171,11 +188,12 @@ DEPENDENCIES
|
|
|
171
188
|
pdf-inspector (~> 1.3.0)
|
|
172
189
|
rake (= 13.2.1)
|
|
173
190
|
rspec (= 3.13.0)
|
|
174
|
-
rubocop (~>
|
|
175
|
-
rubocop-performance (~> 1.
|
|
176
|
-
rubocop-rspec (~>
|
|
191
|
+
rubocop (~> 1.75.3)
|
|
192
|
+
rubocop-performance (~> 1.19.0)
|
|
193
|
+
rubocop-rspec (~> 2.25.0)
|
|
177
194
|
simplecov (= 0.22.0)
|
|
178
195
|
simplecov-html (= 0.13.1)
|
|
196
|
+
simplecov-json (= 0.2.3)
|
|
179
197
|
|
|
180
198
|
BUNDLED WITH
|
|
181
199
|
2.5.5
|
data/br_danfe.gemspec
CHANGED
|
@@ -11,7 +11,6 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.license = 'MIT'
|
|
12
12
|
|
|
13
13
|
spec.files = `git ls-files`.split("\n")
|
|
14
|
-
spec.test_files = `git ls-files -- { test,spec,features }/*`.split("\n")
|
|
15
14
|
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
16
15
|
spec.require_paths = ['lib']
|
|
17
16
|
spec.required_ruby_version = '>= 3.0'
|
|
@@ -24,15 +23,5 @@ Gem::Specification.new do |spec|
|
|
|
24
23
|
spec.add_dependency 'prawn-table', '0.2.2'
|
|
25
24
|
spec.add_dependency 'rqrcode', '>= 2.1', '< 2.3'
|
|
26
25
|
|
|
27
|
-
spec.
|
|
28
|
-
spec.add_development_dependency 'guard', '~> 2.19.0'
|
|
29
|
-
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
|
30
|
-
spec.add_development_dependency 'pdf-inspector', '~> 1.3.0'
|
|
31
|
-
spec.add_development_dependency 'rake', '13.2.1'
|
|
32
|
-
spec.add_development_dependency 'rspec', '3.13.0'
|
|
33
|
-
spec.add_development_dependency 'rubocop', '~> 0.93.1'
|
|
34
|
-
spec.add_development_dependency 'rubocop-performance', '~> 1.10.2'
|
|
35
|
-
spec.add_development_dependency 'rubocop-rspec', '~> 1.44.1'
|
|
36
|
-
spec.add_development_dependency 'simplecov', '0.22.0'
|
|
37
|
-
spec.add_development_dependency 'simplecov-html', '0.13.1'
|
|
26
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
38
27
|
end
|
data/config/locales/pt-BR.yml
CHANGED
|
@@ -47,7 +47,8 @@ pt-BR:
|
|
|
47
47
|
IM: "INSCRIÇÃO MUNICIPAL"
|
|
48
48
|
IE: "INSCRIÇÃO ESTADUAL"
|
|
49
49
|
IEST: "INSC.ESTADUAL DO SUBST. TRIBUTÁRIO"
|
|
50
|
-
CNPJ: "CNPJ"
|
|
50
|
+
CNPJ: "CNPJ/CPF"
|
|
51
|
+
CPF: "CNPJ/CPF"
|
|
51
52
|
dup:
|
|
52
53
|
title: "FATURA / DUPLICATAS"
|
|
53
54
|
nDup: "NRO"
|
|
@@ -146,8 +147,8 @@ pt-BR:
|
|
|
146
147
|
document: "NF-e\nN°. %{nNF}\nSÉRIE %{serie}"
|
|
147
148
|
entrega:
|
|
148
149
|
title: "INFORMAÇÕES DO LOCAL DE ENTREGA"
|
|
149
|
-
CNPJ: "CNPJ"
|
|
150
|
-
CPF: "CPF"
|
|
150
|
+
CNPJ: "CNPJ/CPF"
|
|
151
|
+
CPF: "CNPJ/CPF"
|
|
151
152
|
xNome: "NOME/RAZÃO SOCIAL"
|
|
152
153
|
xLgr: "ENDEREÇO"
|
|
153
154
|
nro: "NÚMERO"
|
|
@@ -15,9 +15,9 @@ module BrDanfe
|
|
|
15
15
|
@document.line_width = 0.3
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def method_missing(method_name,
|
|
18
|
+
def method_missing(method_name, ...)
|
|
19
19
|
if @document.respond_to? method_name
|
|
20
|
-
@document.send
|
|
20
|
+
@document.send(method_name, ...)
|
|
21
21
|
else
|
|
22
22
|
super
|
|
23
23
|
end
|
|
@@ -20,9 +20,9 @@ module BrDanfe
|
|
|
20
20
|
@document.text ' ', size: font_size
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def method_missing(method_name,
|
|
23
|
+
def method_missing(method_name, ...)
|
|
24
24
|
if @document.respond_to? method_name
|
|
25
|
-
@document.send
|
|
25
|
+
@document.send(method_name, ...)
|
|
26
26
|
else
|
|
27
27
|
super
|
|
28
28
|
end
|
|
@@ -24,7 +24,7 @@ module BrDanfe
|
|
|
24
24
|
def render_company_info
|
|
25
25
|
one_line = 1
|
|
26
26
|
|
|
27
|
-
@pdf.text_box
|
|
27
|
+
@pdf.text_box @xml['emit/xNome'].to_s, at: [x_position, @pdf.cursor], height: 36, size: 9, align: :left, style: :bold, overflow: :shrink_to_fit
|
|
28
28
|
@pdf.move_down 36
|
|
29
29
|
|
|
30
30
|
@pdf.text_box cnpj(@xml['emit/CNPJ']), at: [x_position, @pdf.cursor], height: 9, size: 9, align: :left, overflow: :shrink_to_fit
|
|
@@ -34,16 +34,8 @@ module BrDanfe
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def render_cnpj_cpf
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
else
|
|
40
|
-
@pdf.lcnpj LINE_HEIGHT, 4.37, 12.57, @l1, @xml, 'dest/CNPJ'
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def cpf
|
|
45
|
-
cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['dest/CPF'])
|
|
46
|
-
cpf.formatted
|
|
37
|
+
xpath = @xml['dest/CNPJ'].present? ? 'dest/CNPJ' : 'dest/CPF'
|
|
38
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 4.37, 12.57, @l1, @xml, xpath
|
|
47
39
|
end
|
|
48
40
|
|
|
49
41
|
def render_line2
|
|
@@ -17,9 +17,9 @@ module BrDanfe
|
|
|
17
17
|
@document.line_width = 0.3
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def method_missing(method_name,
|
|
20
|
+
def method_missing(method_name, ...)
|
|
21
21
|
if @document.respond_to? method_name
|
|
22
|
-
@document.send
|
|
22
|
+
@document.send(method_name, ...)
|
|
23
23
|
else
|
|
24
24
|
super
|
|
25
25
|
end
|
|
@@ -64,12 +64,12 @@ module BrDanfe
|
|
|
64
64
|
i18n_lbox(h, w, x, y, i18n, data, options)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
def
|
|
67
|
+
def lcnpj_cpf(h, w, x, y, xml, xpath, options = {})
|
|
68
68
|
i18n = xpath.tr('/', '.')
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
data = if
|
|
72
|
-
|
|
69
|
+
document_class = xpath.include?('CNPJ') ? BrDocuments::CnpjCpf::Cnpj : BrDocuments::CnpjCpf::Cpf
|
|
70
|
+
cnpj_cpf = document_class.new(xml[xpath])
|
|
71
|
+
data = if cnpj_cpf.valid?
|
|
72
|
+
cnpj_cpf.formatted
|
|
73
73
|
else
|
|
74
74
|
''
|
|
75
75
|
end
|
|
@@ -97,12 +97,12 @@ module BrDanfe
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def inumeric(h, w, x, y, i18n = '', data = '', options = {})
|
|
100
|
-
label = i18n
|
|
100
|
+
label = i18n == '' ? '' : I18n.t("danfe.#{i18n}")
|
|
101
101
|
numeric [x.cm, Helper.invert(y.cm)], w.cm, h.cm, label, data, options
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def i18n_lbox(h, w, x, y, i18n = '', info = '', options = {})
|
|
105
|
-
label = i18n
|
|
105
|
+
label = i18n == '' ? '' : I18n.t("danfe.#{i18n}")
|
|
106
106
|
ibox h, w, x, y, label, info, options
|
|
107
107
|
end
|
|
108
108
|
|
|
@@ -108,7 +108,15 @@ module BrDanfe
|
|
|
108
108
|
|
|
109
109
|
@pdf.lie LINE_HEIGHT, 6.36, 0.75, y_second_line, @xml, 'enderEmit/UF', 'emit/IE'
|
|
110
110
|
@pdf.lie LINE_HEIGHT, 6.86, 7.11, y_second_line, @xml, 'enderDest/UF', 'emit/IEST'
|
|
111
|
-
@pdf.
|
|
111
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 6.34, 13.97, y_second_line, @xml, cnpj_cpf
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def cnpj_cpf
|
|
115
|
+
if @xml['emit/CNPJ'].present?
|
|
116
|
+
'emit/CNPJ'
|
|
117
|
+
else
|
|
118
|
+
'emit/CPF'
|
|
119
|
+
end
|
|
112
120
|
end
|
|
113
121
|
end
|
|
114
122
|
end
|
|
@@ -39,16 +39,8 @@ module BrDanfe
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def render_cnpj_cpf
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
@pdf.lcnpj LINE_HEIGHT, 4.37, 12.57, @l1, @xml, 'entrega/CNPJ'
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def cpf
|
|
50
|
-
cpf = BrDocuments::CnpjCpf::Cpf.new(@xml['entrega/CPF'])
|
|
51
|
-
cpf.formatted
|
|
42
|
+
xpath = @xml['entrega/CNPJ'].present? ? 'entrega/CNPJ' : 'entrega/CPF'
|
|
43
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 4.37, 12.57, @l1, @xml, xpath
|
|
52
44
|
end
|
|
53
45
|
|
|
54
46
|
def render_line2
|
|
@@ -25,7 +25,7 @@ module BrDanfe
|
|
|
25
25
|
@pdf.lbox LINE_HEIGHT, 1.78, 12.06, @l1, @xml, 'veicTransp/RNTC'
|
|
26
26
|
@pdf.i18n_lbox LINE_HEIGHT, 2.29, 13.84, @l1, 'veicTransp.placa', plate
|
|
27
27
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l1, @xml, 'veicTransp/UF'
|
|
28
|
-
@pdf.
|
|
28
|
+
@pdf.lcnpj_cpf LINE_HEIGHT, 3.44, 16.89, @l1, @xml, 'transporta/CNPJ'
|
|
29
29
|
@pdf.lbox LINE_HEIGHT, 8.52, 0.75, @l2, @xml, 'transporta/xEnder'
|
|
30
30
|
@pdf.lbox LINE_HEIGHT, 6.86, 9.27, @l2, @xml, 'transporta/xMun'
|
|
31
31
|
@pdf.lbox LINE_HEIGHT, 0.76, 16.13, @l2, @xml, 'transporta/UF'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module BrDanfe
|
|
2
2
|
class DocumentBuilder
|
|
3
|
-
def self.build(
|
|
4
|
-
document = Prawn::Document.new(
|
|
3
|
+
def self.build(...)
|
|
4
|
+
document = Prawn::Document.new(...)
|
|
5
5
|
|
|
6
6
|
document.font_families['tinos'] = {
|
|
7
7
|
bold: "#{BrDanfe.root_path}/fonts/tinos_bold.ttf",
|
|
@@ -10,9 +10,9 @@ module BrDanfe
|
|
|
10
10
|
@document.font 'tinos'
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def method_missing(method_name,
|
|
13
|
+
def method_missing(method_name, ...)
|
|
14
14
|
if @document.respond_to? method_name
|
|
15
|
-
@document.send
|
|
15
|
+
@document.send(method_name, ...)
|
|
16
16
|
else
|
|
17
17
|
super
|
|
18
18
|
end
|
data/lib/br_danfe/version.rb
CHANGED
data/lib/br_danfe.rb
CHANGED
|
@@ -9,7 +9,7 @@ require 'yaml'
|
|
|
9
9
|
require 'i18n'
|
|
10
10
|
require 'br_documents'
|
|
11
11
|
|
|
12
|
-
Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f }
|
|
12
|
+
Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f } # rubocop:disable Lint/RedundantDirGlobSort
|
|
13
13
|
|
|
14
14
|
I18n.load_path << File.expand_path('../config/locales/pt-BR.yml', __dir__)
|
|
15
15
|
I18n.available_locales = ['pt-BR']
|
data/lib/prawn/font.rb
CHANGED
|
@@ -7,7 +7,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
7
7
|
describe '#box' do
|
|
8
8
|
context "when a block isn't passed" do
|
|
9
9
|
before do
|
|
10
|
-
|
|
10
|
+
FileUtils.rm_f(output_pdf)
|
|
11
11
|
subject.box(height: 50)
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -22,7 +22,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
22
22
|
|
|
23
23
|
context 'when a block is passed' do
|
|
24
24
|
before do
|
|
25
|
-
|
|
25
|
+
FileUtils.rm_f(output_pdf)
|
|
26
26
|
subject.box(height: 50) { subject.text 'sample text' }
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -39,7 +39,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
39
39
|
describe '#text' do
|
|
40
40
|
context 'when is a simple text' do
|
|
41
41
|
before do
|
|
42
|
-
|
|
42
|
+
FileUtils.rm_f(output_pdf)
|
|
43
43
|
subject.text 'simple text'
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -54,7 +54,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
54
54
|
|
|
55
55
|
context 'when is a text with style' do
|
|
56
56
|
before do
|
|
57
|
-
|
|
57
|
+
FileUtils.rm_f(output_pdf)
|
|
58
58
|
subject.text 'bold text', style: :bold
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
69
69
|
|
|
70
70
|
context 'when is a text with size' do
|
|
71
71
|
before do
|
|
72
|
-
|
|
72
|
+
FileUtils.rm_f(output_pdf)
|
|
73
73
|
subject.text 'big text', size: 25
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -84,7 +84,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
84
84
|
|
|
85
85
|
context 'when is a text with pad' do
|
|
86
86
|
before do
|
|
87
|
-
|
|
87
|
+
FileUtils.rm_f(output_pdf)
|
|
88
88
|
subject.text 'text with pad', pad: 50
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -99,7 +99,7 @@ describe BrDanfe::CceLib::Document do
|
|
|
99
99
|
|
|
100
100
|
context 'when is a text with align' do
|
|
101
101
|
before do
|
|
102
|
-
|
|
102
|
+
FileUtils.rm_f(output_pdf)
|
|
103
103
|
subject.text 'text in center', align: :center
|
|
104
104
|
end
|
|
105
105
|
|
data/spec/br_danfe/cce_spec.rb
CHANGED
|
@@ -8,14 +8,14 @@ describe BrDanfe::Cce do
|
|
|
8
8
|
|
|
9
9
|
describe '#render_pdf' do
|
|
10
10
|
it 'renders the correction letter' do
|
|
11
|
-
expected =
|
|
11
|
+
expected = File.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
17
|
describe '#save_pdf' do
|
|
18
|
-
before {
|
|
18
|
+
before { FileUtils.rm_f(output_pdf) }
|
|
19
19
|
|
|
20
20
|
it 'saves the pdf' do
|
|
21
21
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
@@ -6,7 +6,7 @@ describe BrDanfe::DanfeLib::NfceLib::ProductList do
|
|
|
6
6
|
|
|
7
7
|
let(:subject) { BrDanfe::DanfeLib::NfceLib::Document.new(8.cm, 1.8.cm) }
|
|
8
8
|
|
|
9
|
-
before {
|
|
9
|
+
before { FileUtils.rm_f(output_pdf) }
|
|
10
10
|
|
|
11
11
|
it 'render the document with blank lines' do
|
|
12
12
|
expect(File.exist?(output_pdf)).to be_falsey
|
|
@@ -27,7 +27,7 @@ describe BrDanfe::DanfeLib::NfceLib::Footer do
|
|
|
27
27
|
subject { described_class.new pdf, xml_footer }
|
|
28
28
|
|
|
29
29
|
describe '#render' do
|
|
30
|
-
before {
|
|
30
|
+
before { FileUtils.rm_f(output_pdf) }
|
|
31
31
|
|
|
32
32
|
it 'renders footer to the pdf' do
|
|
33
33
|
subject.render
|
|
@@ -49,10 +49,10 @@ describe BrDanfe::DanfeLib::NfceLib::Header do
|
|
|
49
49
|
describe '#render' do
|
|
50
50
|
before do
|
|
51
51
|
subject.render
|
|
52
|
-
|
|
52
|
+
FileUtils.rm_f(output_pdf)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
after {
|
|
55
|
+
after { FileUtils.rm_f(output_pdf) }
|
|
56
56
|
|
|
57
57
|
context 'when has a short name' do
|
|
58
58
|
let(:company_name) { 'Test company' }
|