Skip to content

Commit

Permalink
Merge PR #3527 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Jan 28, 2025
2 parents 27b16e8 + 0de7409 commit fea1117
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions l10n_br_nfse_paulistana/constants/paulistana.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

CONSULTA_LOTE = [
"ConsultaLote",
"ConsultaNFe",
]
43 changes: 25 additions & 18 deletions l10n_br_nfse_paulistana/models/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ def _eletronic_document_send(self):
def _document_status(self):
status = super()._document_status()
for record in self.filtered(filter_oca_nfse).filtered(filter_paulistana):
vals = dict()
processador = record._processador_erpbrasil_nfse()
processo = processador.consulta_nfse_rps(
numero_rps=record.rps_number,
Expand All @@ -394,25 +395,31 @@ def _document_status(self):
or None,
cnpj_prest=misc.punctuation_rm(record.company_id.partner_id.cnpj_cpf),
)

consulta = processador.analisa_retorno_consulta(processo)
data_emissao = datetime.strptime(
consulta["data_emissao"], "%Y-%m-%dT%H:%M:%S"
)
if isinstance(consulta, dict):
record.write(
{
"verify_code": consulta["codigo_verificacao"],
"document_number": consulta["numero"],
"authorization_date": data_emissao,
}
)
record.authorization_event_id.set_done(
status_code=4,
response=_("Procesado com Sucesso"),
protocol_date=data_emissao,
protocol_number=record.authorization_protocol,
file_response_xml=processo.retorno,
)
retorno = ET.fromstring(processo.retorno)

if processo.webservice in CONSULTA_LOTE:
if processo.resposta.Cabecalho.Sucesso:
nfse = retorno.find(".//NFe")

vals["document_number"] = nfse.find(".//NumeroNFe").text
vals["authorization_date"] = nfse.find(".//DataEmissaoRPS").text
vals["verify_code"] = nfse.find(".//CodigoVerificacao").text
vals["status_name"] = _("Procesado com Sucesso")
vals["status_code"] = 4
vals["edoc_error_message"] = ""

record.authorization_event_id.set_done(
status_code=4,
response=vals["status_name"],
protocol_date=vals["authorization_date"],
protocol_number=nfse.find(".//CodigoVerificacao").text,
file_response_xml=processo.retorno,
)

record._change_state(SITUACAO_EDOC_AUTORIZADA)
record.write(vals)
status = _(consulta)
return status

Expand Down

0 comments on commit fea1117

Please sign in to comment.