diff --git a/pytrustnfe/nfse/goiania/__init__.py b/pytrustnfe/nfse/goiania/__init__.py
index 832f1d9..ed790fa 100644
--- a/pytrustnfe/nfse/goiania/__init__.py
+++ b/pytrustnfe/nfse/goiania/__init__.py
@@ -10,6 +10,9 @@ from pytrustnfe.xml import render_xml, sanitize_response
from .assinatura import Assinatura
+NAMESPACE = './/{http://nfse.goiania.go.gov.br/xsd/nfse_gyn_v02.xsd}'
+
+
def _render(certificado, method, **kwargs):
path = os.path.join(os.path.dirname(__file__), "templates")
xml_send = render_xml(path, f"{method}.xml", False, **kwargs)
@@ -39,16 +42,22 @@ def _send(certificado, method, **kwargs):
return {"send_xml": str(xml_send), "received_xml": str(response), "object": obj}
-def xml_gerar_nfse(certificado, **kwargs):
- return _render(certificado, "GerarNfse", **kwargs)
-
-
def gerar_nfse(certificado, **kwargs):
+ """" Gera uma NFSe de saída """
+
if "xml" not in kwargs:
- kwargs["xml"] = xml_gerar_nfse(certificado, **kwargs)
+ kwargs["xml"] = _render(certificado, "GerarNfse", **kwargs)
return _send(certificado, "GerarNfse", **kwargs)
+def consulta_nfse_por_rps(certificado, **kwargs):
+ """ Consulta os dados de um NFSe já emitida """
+
+ if "xml" not in kwargs:
+ kwargs["xml"] = _render(certificado, "ConsultarNfseRps", **kwargs)
+ return _send(certificado, "ConsultarNfseRps", **kwargs)
+
+
def split_result(xml_received: str):
""" Retorna o código e a mensagem de retorno vindo do webservice """
@@ -57,10 +66,9 @@ def split_result(xml_received: str):
if xml is None:
return None, None
- ns = './/{http://nfse.goiania.go.gov.br/xsd/nfse_gyn_v02.xsd}'
- msg_return = xml.find(f'{ns}MensagemRetorno')
- code = msg_return.find(f"{ns}Codigo").text
- msg = msg_return.find(f"{ns}Mensagem").text
+ msg_return = xml.find(f'{NAMESPACE}MensagemRetorno')
+ code = msg_return.find(f"{NAMESPACE}Codigo").text
+ msg = msg_return.find(f"{NAMESPACE}Mensagem").text
return code, msg
diff --git a/pytrustnfe/nfse/goiania/templates/ConsultarNfseRps.xml b/pytrustnfe/nfse/goiania/templates/ConsultarNfseRps.xml
new file mode 100644
index 0000000..32085c3
--- /dev/null
+++ b/pytrustnfe/nfse/goiania/templates/ConsultarNfseRps.xml
@@ -0,0 +1,19 @@
+
+
+
+ {{ numero }}
+ {{ serie }}
+ {{ tipo }}
+
+
+
+ {% if cnpj_cpf|length == 14 %}
+ {{ cnpj_cpf }}
+ {% endif %}
+ {% if cnpj_cpf|length == 11 %}
+ {{ cnpj_cpf }}
+ {% endif %}
+
+ {{ inscricao_municipal }}
+
+
diff --git a/pytrustnfe/nfse/goiania/templates/Rps.xml b/pytrustnfe/nfse/goiania/templates/Rps.xml
index e4785f9..8160243 100644
--- a/pytrustnfe/nfse/goiania/templates/Rps.xml
+++ b/pytrustnfe/nfse/goiania/templates/Rps.xml
@@ -47,6 +47,7 @@
{% endif %}
{{ tomador.razao_social }}
+ {% if tomador.endereco %}
{{ tomador.endereco.rua }}
{{ tomador.endereco.numero }}
@@ -55,6 +56,7 @@
{{ tomador.endereco.codigo_municipio }}
{{ tomador.endereco.uf }}
+ {% endif %}