br_danfe 3.2.0 → 3.2.1
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 +1 -1
- data/config/locales/pt-BR.yml +2 -0
- data/lib/br_danfe/danfe_lib/nfe.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/dest.rb +5 -4
- data/lib/br_danfe/danfe_lib/nfe_lib/det_body.rb +2 -2
- data/lib/br_danfe/danfe_lib/nfe_lib/dup.rb +1 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/emit_header.rb +12 -9
- data/lib/br_danfe/danfe_lib/nfe_lib/entrega.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/ibscbstot.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/icmstot.rb +1 -0
- data/lib/br_danfe/danfe_lib/nfe_lib/issqn.rb +1 -1
- data/lib/br_danfe/danfe_lib/nfe_lib/rtc_layout.rb +1 -1
- data/lib/br_danfe/version.rb +1 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/emit_header_spec.rb +40 -1
- data/spec/br_danfe/danfe_lib/nfe_lib/issqn_spec.rb +3 -2
- data/spec/br_danfe/danfe_lib/nfe_lib/rtc_layout_spec.rb +2 -2
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal.xml.fixture.pdf +585 -574
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal_with_entrega_and_issqn.xml +1 -1
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal_with_entrega_and_issqn.xml.fixture.pdf +667 -703
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal_with_fcp_difal_and_monophasic.xml.fixture.pdf +2094 -1028
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal_with_many_items.xml +1 -1
- data/spec/fixtures/nfe/v4.00/rtc_regime_normal_with_many_items.xml.fixture.pdf +6688 -6655
- data/spec/fixtures/nfe/v4.00/rtc_simples_nacional.xml.fixture.pdf +512 -501
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a5c768ac88fe2c6a25d1127239c06e4f7bc1dbdd6b2bd2265e31612c6e300e5a
|
|
4
|
+
data.tar.gz: 1b4a06529ad8c8c15ef874643fe355d53c51f6792dbd18126ebc078b4d565f75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee02fe9b2139f45652e81a1be6c59540e4596b05b4fbe92dab8933dda25f67d7a34c61ef3cf26b1294337778508d6388f353c2c547ded10c40df804aef1d4e00
|
|
7
|
+
data.tar.gz: 326c657486b139540f35250098a6d261c8e5e3c5734931fdf13bf01f98db7e54e0d1ea56f9990832d5a65cde765aa0e42e83c1a4305fdda1480f01557df0dfc7
|
data/Gemfile.lock
CHANGED
data/config/locales/pt-BR.yml
CHANGED
|
@@ -84,7 +84,7 @@ module BrDanfe
|
|
|
84
84
|
return if page == 1 && !@products_on_first_page
|
|
85
85
|
|
|
86
86
|
y_position = NfeLib::Entrega.delivery_local?(xml) && page == 1 ? 3.00 : 0
|
|
87
|
-
y_position += page == 1 ? 18.91 + NfeLib::RtcLayout.offset(xml) : 7.40
|
|
87
|
+
y_position += page == 1 ? 18.91 + NfeLib::RtcLayout.offset(xml) : 7.40 + NfeLib::EmitHeader.offset(xml)
|
|
88
88
|
@document.ititle 0.42, 10.00, 0.75, y_position, 'det.title'
|
|
89
89
|
end
|
|
90
90
|
|
|
@@ -10,10 +10,11 @@ module BrDanfe
|
|
|
10
10
|
@xml = xml
|
|
11
11
|
@xml_version_is_310_or_newer = @xml.version_is_310_or_newer?
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
@
|
|
15
|
-
@
|
|
16
|
-
@
|
|
13
|
+
y_position = Y + EmitHeader.offset(@xml)
|
|
14
|
+
@ltitle = y_position - 0.42
|
|
15
|
+
@l1 = y_position
|
|
16
|
+
@l2 = y_position + LINE_HEIGHT
|
|
17
|
+
@l3 = y_position + (LINE_HEIGHT * 2)
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
def render
|
|
@@ -98,11 +98,11 @@ module BrDanfe
|
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def table_position_on_next_pages
|
|
101
|
-
Helper.invert(6.57.cm)
|
|
101
|
+
Helper.invert((6.57 + EmitHeader.offset(@xml)).cm)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
def table_height_on_next_pages
|
|
105
|
-
22.58.cm
|
|
105
|
+
(22.58 - EmitHeader.offset(@xml)).cm
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
108
|
end
|
|
@@ -5,6 +5,10 @@ module BrDanfe
|
|
|
5
5
|
IDENTIFICATION_SIZE = 10
|
|
6
6
|
DESCRIPTION_SIZE = 8
|
|
7
7
|
|
|
8
|
+
def self.offset(xml)
|
|
9
|
+
RtcLayout.applies?(xml) ? LINE_HEIGHT : 0.0
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
def initialize(pdf, xml, logo, logo_dimensions)
|
|
9
13
|
@pdf = pdf
|
|
10
14
|
@xml = xml
|
|
@@ -124,7 +128,8 @@ module BrDanfe
|
|
|
124
128
|
@pdf.ibox LINE_HEIGHT, 9.52, 10.79, y_first_line, I18n.t('danfe.infProt'),
|
|
125
129
|
"#{@xml['infProt/nProt']} #{BrDanfe::Helper.format_datetime(@xml['infProt/dhRecbto'])}", align: :right
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
render_second_line(y_second_line)
|
|
132
|
+
render_tax_regime_line(y_second_line + LINE_HEIGHT) if RtcLayout.applies?(@xml)
|
|
128
133
|
end
|
|
129
134
|
|
|
130
135
|
def render_second_line(y_position)
|
|
@@ -133,16 +138,14 @@ module BrDanfe
|
|
|
133
138
|
@pdf.lcnpj_cpf LINE_HEIGHT, 6.34, 13.97, y_position, @xml, cnpj_cpf, align: :right
|
|
134
139
|
end
|
|
135
140
|
|
|
136
|
-
def
|
|
137
|
-
@pdf.
|
|
138
|
-
@pdf.
|
|
139
|
-
@pdf.i18n_lbox LINE_HEIGHT, 6.00, 9.55, y_position, 'emit.CRT.title', crt
|
|
140
|
-
@pdf.lcnpj_cpf LINE_HEIGHT, 4.76, 15.55, y_position, @xml, cnpj_cpf, align: :right
|
|
141
|
+
def render_tax_regime_line(y_position)
|
|
142
|
+
@pdf.i18n_lbox LINE_HEIGHT, 10.04, 0.75, y_position, 'emit.CRT.title', described_code('CRT')
|
|
143
|
+
@pdf.i18n_lbox LINE_HEIGHT, 9.52, 10.79, y_position, 'emit.tpRegimeIBSCBS.title', ''
|
|
141
144
|
end
|
|
142
145
|
|
|
143
|
-
def
|
|
144
|
-
code = @xml[
|
|
145
|
-
code.present? ? I18n.t("danfe.emit
|
|
146
|
+
def described_code(tag)
|
|
147
|
+
code = @xml["emit/#{tag}"]
|
|
148
|
+
code.present? ? I18n.t("danfe.emit.#{tag}.#{code}", default: code) : ''
|
|
146
149
|
end
|
|
147
150
|
|
|
148
151
|
def cnpj_cpf
|
|
@@ -17,7 +17,7 @@ module BrDanfe
|
|
|
17
17
|
@pdf = pdf
|
|
18
18
|
@xml = xml
|
|
19
19
|
@y_position = Entrega.delivery_local?(@xml) ? Transp::Y_POSITION + 3.00 : Transp::Y_POSITION
|
|
20
|
-
@y_position += Icmstot.offset(@xml)
|
|
20
|
+
@y_position += EmitHeader.offset(@xml) + Icmstot.offset(@xml)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def render
|
|
@@ -40,7 +40,7 @@ module BrDanfe
|
|
|
40
40
|
|
|
41
41
|
def position_below_the_tax_totals
|
|
42
42
|
y_position = Entrega.delivery_local?(@xml) ? Transp::Y_POSITION + 3.00 : Transp::Y_POSITION
|
|
43
|
-
y_position + Icmstot.offset(@xml) + Ibscbstot.offset(@xml)
|
|
43
|
+
y_position + EmitHeader.offset(@xml) + Icmstot.offset(@xml) + Ibscbstot.offset(@xml)
|
|
44
44
|
end
|
|
45
45
|
end
|
|
46
46
|
end
|
data/lib/br_danfe/version.rb
CHANGED
|
@@ -183,13 +183,16 @@ describe BrDanfe::DanfeLib::NfeLib::EmitHeader do
|
|
|
183
183
|
let(:pdf_text) { PDF::Inspector::Text.analyze(pdf.render).strings.join("\n") }
|
|
184
184
|
let(:issued_at) { '2026-12-02T10:00:00-03:00' }
|
|
185
185
|
let(:crt) { '3' }
|
|
186
|
+
let(:ibscbs_regime) { '' }
|
|
186
187
|
let(:xml_as_string) do
|
|
187
188
|
<<~XML
|
|
188
189
|
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
|
|
189
190
|
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
|
190
191
|
<infNFe versao="4.00">
|
|
191
192
|
<ide><dhEmi>#{issued_at}</dhEmi><tpNF>1</tpNF><nNF>1</nNF><serie>1</serie></ide>
|
|
192
|
-
<emit
|
|
193
|
+
<emit>
|
|
194
|
+
<xNome>Nome do Remetente Ltda</xNome><CNPJ>62013294000143</CNPJ><CRT>#{crt}</CRT>#{ibscbs_regime}
|
|
195
|
+
</emit>
|
|
193
196
|
</infNFe>
|
|
194
197
|
</NFe>
|
|
195
198
|
</nfeProc>
|
|
@@ -218,6 +221,42 @@ describe BrDanfe::DanfeLib::NfeLib::EmitHeader do
|
|
|
218
221
|
it 'does not render the tax regime code' do
|
|
219
222
|
expect(pdf_text).not_to include('CÓDIGO DO REGIME TRIBUTÁRIO')
|
|
220
223
|
end
|
|
224
|
+
|
|
225
|
+
it 'does not render the IBS/CBS regime type' do
|
|
226
|
+
expect(pdf_text).not_to include('TIPO DE REGIME DE APURAÇÃO DO IBS E DA CBS')
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
context 'when the NF-e has the IBS/CBS regime type' do
|
|
231
|
+
let(:crt) { '1' }
|
|
232
|
+
let(:ibscbs_regime) { '<tpRegimeIBSCBS>1</tpRegimeIBSCBS>' }
|
|
233
|
+
|
|
234
|
+
it 'renders only the IBS/CBS regime type title' do
|
|
235
|
+
expect(pdf_text).to end_with('TIPO DE REGIME DE APURAÇÃO DO IBS E DA CBS')
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
describe '.offset' do
|
|
241
|
+
subject { described_class.offset(xml) }
|
|
242
|
+
|
|
243
|
+
let(:issued_at) { '2026-12-02T10:00:00-03:00' }
|
|
244
|
+
let(:xml_as_string) do
|
|
245
|
+
<<~XML
|
|
246
|
+
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
|
|
247
|
+
<infNFe versao="4.00"><ide><dhEmi>#{issued_at}</dhEmi></ide></infNFe>
|
|
248
|
+
</NFe>
|
|
249
|
+
XML
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
context 'when the NF-e uses the NT 2026.010 layout' do
|
|
253
|
+
it('is the tax regime line') { is_expected.to eql 0.8 }
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
context 'when the NF-e uses the current layout' do
|
|
257
|
+
let(:issued_at) { '2026-11-20T10:00:00-03:00' }
|
|
258
|
+
|
|
259
|
+
it('adds nothing') { is_expected.to eql 0.0 }
|
|
221
260
|
end
|
|
222
261
|
end
|
|
223
262
|
end
|
|
@@ -145,18 +145,19 @@ describe BrDanfe::DanfeLib::NfeLib::Issqn do
|
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
let(:transporter_position) { 16.41 }
|
|
148
|
+
let(:tax_regime_line) { 0.8 }
|
|
148
149
|
let(:ibscbs_block) { 1.32 }
|
|
149
150
|
|
|
150
151
|
describe '#y_position' do
|
|
151
152
|
it 'is below the IBS/CBS/IS block, at the transporter position' do
|
|
152
|
-
expect(subject.y_position).to eql transporter_position + 0.0 + ibscbs_block
|
|
153
|
+
expect(subject.y_position).to eql transporter_position + tax_regime_line + 0.0 + ibscbs_block
|
|
153
154
|
end
|
|
154
155
|
|
|
155
156
|
context 'with entrega' do
|
|
156
157
|
let(:entrega) { '<entrega><xLgr>Rua Entrega</xLgr></entrega>' }
|
|
157
158
|
|
|
158
159
|
it 'moves down with the delivery place' do
|
|
159
|
-
expect(subject.y_position).to eql transporter_position + 3.0 + 0.0 + ibscbs_block
|
|
160
|
+
expect(subject.y_position).to eql transporter_position + 3.0 + tax_regime_line + 0.0 + ibscbs_block
|
|
160
161
|
end
|
|
161
162
|
end
|
|
162
163
|
|
|
@@ -99,8 +99,8 @@ describe BrDanfe::DanfeLib::NfeLib::RtcLayout do
|
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
context 'when the NF-e uses the new layout' do
|
|
102
|
-
it 'is the FCP line
|
|
103
|
-
expect(subject).to eql line_height + line_height + space_between_blocks
|
|
102
|
+
it 'is the tax regime line, the FCP line, the IBS/CBS/IS block and the space after it' do
|
|
103
|
+
expect(subject).to eql line_height + line_height + (line_height + space_between_blocks)
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|