Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP] Paulistana Status Consulta #3527

Draft
wants to merge 2 commits into
base: 14.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 _document_status(self):
status = super()._document_status()
for record in self.filtered(filter_oca_nfse).filtered(filter_paulistana):
vals = dict()

Check warning on line 387 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L387

Added line #L387 was not covered by tests
processador = record._processador_erpbrasil_nfse()
processo = processador.consulta_nfse_rps(
numero_rps=record.rps_number,
Expand All @@ -394,25 +395,31 @@
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)

Check warning on line 400 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L400

Added line #L400 was not covered by tests

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

Check warning on line 404 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L404

Added line #L404 was not covered by tests

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"] = ""

Check warning on line 411 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L406-L411

Added lines #L406 - L411 were not covered by tests

record.authorization_event_id.set_done(

Check warning on line 413 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L413

Added line #L413 was not covered by tests
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)

Check warning on line 422 in l10n_br_nfse_paulistana/models/document.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_nfse_paulistana/models/document.py#L421-L422

Added lines #L421 - L422 were not covered by tests
status = _(consulta)
return status

Expand Down
Loading