Skip to content

Commit

Permalink
[IMP] l10n_br_nfe: some improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed May 10, 2024
1 parent eb07db6 commit 25a8c69
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 84 deletions.
315 changes: 232 additions & 83 deletions l10n_br_nfe/models/document.py

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions l10n_br_nfe/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ class ResCompany(spec_models.SpecModel):
default=NFE_ENVIRONMENT_DEFAULT,
)

nfe_synchronous_processing = fields.Boolean(
help=(
"When enabled, this option configures the system to transmit the "
"NFe (Electronic Invoice) using a synchronous method instead of an "
"asynchronous one. This means that the system will wait for an immediate "
"response from the tax authority's system (SEFAZ) upon submission of the "
"NFe, providing quicker feedback on the submission status. Before "
"activating this option, please ensure that the SEFAZ in your state "
"supports synchronous processing for NFe submissions. Failure to verify "
"compatibility may result in transmission errors or rejections."
),
)

nfe_transmission = fields.Selection(
selection=NFE_TRANSMISSIONS,
string="Transmission Type",
Expand Down
5 changes: 5 additions & 0 deletions l10n_br_nfe/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class ResConfigSettings(models.TransientModel):
readonly=False,
)

nfe_synchronous_processing = fields.Boolean(
related="company_id.nfe_synchronous_processing",
readonly=False,
)

nfe_danfe_layout = fields.Selection(
string="NFe Layout",
related="company_id.nfe_danfe_layout",
Expand Down
34 changes: 34 additions & 0 deletions l10n_br_nfe/tests/mocks/retConsSitNFe/autorizado.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<soap:Body>
<nfeResultMsg
xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeConsultaProtocolo4"
>
<retConsSitNFe versao="4.00" xmlns="http://www.portalfiscal.inf.br/nfe">
<tpAmb>2</tpAmb>
<verAplic>sefaz_mocked</verAplic>
<cStat>100</cStat>
<xMotivo>Autorizado o uso da NF-e</xMotivo>
<cUF>26</cUF>
<dhRecbto>2020-02-03T10:31:52-03:00</dhRecbto>
<chNFe>26200124494200000106550010000010111352744151</chNFe>
<protNFe versao="4.00">
<infProt Id="ID26200124494200000106550010000010111352744151">
<tpAmb>2</tpAmb>
<verAplic>sefaz_mocked.00.07.211</verAplic>
<chNFe>26200124494200000106550010000010111352744151</chNFe>
<dhRecbto>2020-01-13T14:20:52-03:00</dhRecbto>
<nProt>126200000020426</nProt>
<digVal>YRn2TFuteCw8/KW0mwxQBQGurlI=</digVal>
<cStat>100</cStat>
<xMotivo>Autorizado o uso da NF-e</xMotivo>
</infProt>
</protNFe>
</retConsSitNFe>
</nfeResultMsg>
</soap:Body>
</soap:Envelope>
34 changes: 34 additions & 0 deletions l10n_br_nfe/tests/mocks/retConsSitNFe/cancelado.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<soap:Body>
<nfeResultMsg
xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NFeConsultaProtocolo4"
>
<retConsSitNFe versao="4.00" xmlns="http://www.portalfiscal.inf.br/nfe">
<tpAmb>2</tpAmb>
<verAplic>sefaz_mocked</verAplic>
<cStat>101</cStat>
<xMotivo>Cancelamento de NF-e homologado</xMotivo>
<cUF>26</cUF>
<dhRecbto>2020-02-03T10:31:52-03:00</dhRecbto>
<chNFe>26200124494200000106550010000010111352744151</chNFe>
<retCancNFe versao="4.00">
<infCanc Id="ID43060992665611012850550070000081711388781007">
<tpAmb>2</tpAmb>
<verAplic>2.2.21</verAplic>
<cStat>103</cStat>
<xMotivo>Lote recebido com sucesso</xMotivo>
<cUF>12</cUF>
<chNFe>43060992665611012850550070000081711388781007</chNFe>
<dhRecbto>1969-12-31T21:00:01.000-03:00</dhRecbto>
<nProt>143060000295038</nProt>
</infCanc>
</retCancNFe>
</retConsSitNFe>
</nfeResultMsg>
</soap:Body>
</soap:Envelope>
4 changes: 3 additions & 1 deletion l10n_br_nfe/tests/test_nfce.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ def test_atualiza_status_nfce(self):
mock_autorizada.protocolo.infProt.xMotivo = "TESTE AUTORIZADO"
mock_autorizada.protocolo.infProt.dhRecbto = datetime.now()
mock_autorizada.processo_xml = b"dummy"
self.document_id.atualiza_status_nfe(mock_autorizada)
mock_autorizada.resposta = mock.MagicMock()
mock_autorizada.webservice = "dummy_service"
self.document_id._nfe_update_status_and_save_data(mock_autorizada)

self.assertEqual(self.document_id.state_edoc, SITUACAO_EDOC_AUTORIZADA)
self.assertEqual(self.document_id.status_code, AUTORIZADO[0])
Expand Down
5 changes: 5 additions & 0 deletions l10n_br_nfe/views/res_company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
<field name="nfe_version" required="1" />
<field name="nfe_environment" required="1" />
<field name="nfe_transmission" required="1" />
<field
name="nfe_synchronous_processing"
string="Synchronous Processing"
required="1"
/>
<field name="nfe_danfe_layout" required="1" />
<field name="nfce_danfe_layout" required="1" />
<field
Expand Down
14 changes: 14 additions & 0 deletions l10n_br_nfe/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="nfe_synchronous_processing" />
</div>
<div class="o_setting_right_pane">
<label
for="nfe_synchronous_processing"
string="Synchronous Processing"
/>
<div class="text-muted">
Enables synchronous processing in the transmission of the NFe.
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label">DANFE Print Layout</span>
Expand Down

0 comments on commit 25a8c69

Please sign in to comment.