-
Notifications
You must be signed in to change notification settings - Fork 212
WIP feat: add recepcao evento cte #418
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
base: main
Are you sure you want to change the base?
WIP feat: add recepcao evento cte #418
Conversation
|
Os testes estão falhando, e consegue colocar uma descrição por favor? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the CTe “recepção de evento” endpoint by updating dependency requirements, service URLs, and SOAP communication methods.
- Adds
pytzto dependencies for timezone handling - Extends
webservices.pywith newRECEPCAO_EVENTOendpoints per state - Implements
prestacao_em_desacordoandeventomethods and enhances SOAP envelope construction and headers incomunicacao.py
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| setup.py | Added pytz to install_requires |
| pynfe/utils/webservices.py | Introduced RECEPCAO_EVENTO URL entries for each state |
| pynfe/processamento/comunicacao.py | Added event methods, updated _construir_xml_soap, _cabecalho_soap, and _post_header logic |
Comments suppressed due to low confidence (2)
pynfe/processamento/comunicacao.py:1267
- [nitpick] Consider adding a docstring to
prestacao_em_desacordoexplaining its purpose, parameters, and returned value to improve readability and maintainability.
def prestacao_em_desacordo(self, chave_cte, cnpj, id_lote=1):
pynfe/processamento/comunicacao.py:1410
- This method defines
headersbut does not explicitly return them in all code paths. Addreturn headersat the end of_post_headerto ensure the caller receives the header dict.
def _post_header(self, soap_action=None):
| elif metodo == 'CTeRecepcaoEventoV4': | ||
| a = etree.SubElement( | ||
| body, "cteDadosMsg", xmlns=NAMESPACE_CTE_METODO + metodo | ||
| ) |
Copilot
AI
Jun 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch creates the same element as the else block below, making it redundant. You can remove this elif and let the else handle it.
| elif metodo == 'CTeRecepcaoEventoV4': | |
| a = etree.SubElement( | |
| body, "cteDadosMsg", xmlns=NAMESPACE_CTE_METODO + metodo | |
| ) | |
| # Removed redundant elif block; handled by the else block below. |
| dt_com_fuso = datetime.datetime.now(fuso_horario) | ||
| data_hora_evento_str = dt_com_fuso.strftime('%Y-%m-%dT%H:%M:%S%z') | ||
| data_hora = data_hora_evento_str[:-2] + ':' + data_hora_evento_str[-2:] | ||
| id_evento = f"ID610110{chave_cte}{str('1').zfill(3)}" # 610110 é o código do evento de prestacao de servico em desacordo |
Copilot
AI
Jun 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The use of str('1') is redundant; you can simply write '1'.zfill(3) to achieve the same result.
| id_evento = f"ID610110{chave_cte}{str('1').zfill(3)}" # 610110 é o código do evento de prestacao de servico em desacordo | |
| id_evento = f"ID610110{chave_cte}{'1'.zfill(3)}" # 610110 é o código do evento de prestacao de servico em desacordo |
| "requests", | ||
| "lxml", | ||
| "signxml", | ||
| "pytz" |
Copilot
AI
Jun 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] It’s often safer to pin third-party dependencies to a version range (e.g., pytz>=2021.1,<2025.0) to avoid unexpected breaking changes when new releases come out.
| "pytz" | |
| "pytz>=2021.1,<2025.0" |
|
não é necessário adicionar a dependencia pytz, dá para fazer sem. Outra ponto é fixar o timezone. |
No description provided.