6 changed files with 193 additions and 0 deletions
-
75pytrustnfe/nfse/imperial/__init__.py
-
17pytrustnfe/nfse/imperial/templates/CANCELANOTAELETRONICA.xml
-
9pytrustnfe/nfse/imperial/templates/CONSULTANOTASPROTOCOLO.xml
-
9pytrustnfe/nfse/imperial/templates/CONSULTAPROTOCOLO.xml
-
78pytrustnfe/nfse/imperial/templates/PROCESSARPS.xml
-
5pytrustnfe/nfse/imperial/templates/SoapRequest.xml
@ -0,0 +1,75 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Danimar Ribeiro, Trustcode |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
import os |
|||
from pytrustnfe import HttpClient |
|||
from pytrustnfe.xml import render_xml, sanitize_response |
|||
|
|||
|
|||
def _render(certificado, method, **kwargs): |
|||
path = os.path.join(os.path.dirname(__file__), 'templates') |
|||
xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) |
|||
return xml_send |
|||
|
|||
|
|||
def _send(certificado, method, **kwargs): |
|||
base_url = '' |
|||
if kwargs['ambiente'] == 'producao': |
|||
base_url = 'https://producao.ginfes.com.br/ServiceGinfesImpl?wsdl' |
|||
else: |
|||
base_url = 'https://nfehomologacao.etransparencia.com.br/rj.petropolis/webservice/aws_nfe.aspx' # noqa |
|||
|
|||
xml_send = kwargs["xml"] |
|||
path = os.path.join(os.path.dirname(__file__), 'templates') |
|||
soap = render_xml(path, 'SoapRequest.xml', False, soap_body=xml_send) |
|||
|
|||
client = HttpClient(base_url) |
|||
response = client.post_soap(soap, 'NFeaction/AWS_NFE.%s' % method) |
|||
|
|||
response, obj = sanitize_response(response) |
|||
return { |
|||
'sent_xml': xml_send, |
|||
'received_xml': response, |
|||
'object': obj |
|||
} |
|||
|
|||
|
|||
def xml_processa_rps(certificado, **kwargs): |
|||
return _render(certificado, 'PROCESSARPS', **kwargs) |
|||
|
|||
|
|||
def processa_rps(certificado, **kwargs): |
|||
if "xml" not in kwargs: |
|||
kwargs['xml'] = xml_processa_rps(certificado, **kwargs) |
|||
return _send(certificado, 'PROCESSARPS', **kwargs) |
|||
|
|||
|
|||
def xml_consulta_protocolo(certificado, **kwargs): |
|||
return _render(certificado, 'CONSULTAPROTOCOLO', **kwargs) |
|||
|
|||
|
|||
def consulta_protocolo(certificado, **kwargs): |
|||
if "xml" not in kwargs: |
|||
kwargs['xml'] = xml_consulta_protocolo(certificado, **kwargs) |
|||
return _send(certificado, 'CONSULTAPROTOCOLO', **kwargs) |
|||
|
|||
|
|||
def xml_consulta_notas_protocolo(certificado, **kwargs): |
|||
return _render(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs) |
|||
|
|||
|
|||
def consulta_notas_protocolo(certificado, **kwargs): |
|||
if "xml" not in kwargs: |
|||
kwargs['xml'] = xml_consulta_notas_protocolo(certificado, **kwargs) |
|||
return _send(certificado, 'CONSULTANOTASPROTOCOLO', **kwargs) |
|||
|
|||
|
|||
def xml_cancelar_nfse(certificado, **kwargs): |
|||
return _render(certificado, 'CANCELANOTAELETRONICA', **kwargs) |
|||
|
|||
|
|||
def cancelar_nfse(certificado, **kwargs): |
|||
if "xml" not in kwargs: |
|||
kwargs['xml'] = xml_cancelar_nfse(certificado, **kwargs) |
|||
return _send(certificado, 'CANCELANOTAELETRONICA', **kwargs) |
|||
@ -0,0 +1,17 @@ |
|||
<ws_nfe.CANCELANOTAELETRONICA xmlns="NFe"> |
|||
<Sdt_cancelanfe> |
|||
<Login> |
|||
<CodigoUsuario>[string]</CodigoUsuario> |
|||
<CodigoContribuinte>[string]</CodigoContribuinte> |
|||
</Login> |
|||
<Nota> |
|||
<SerieNota>[string]</SerieNota> |
|||
<NumeroNota>[int]</NumeroNota> |
|||
<SerieRPS>[string]</SerieRPS> |
|||
<NumeroRps>[int]</NumeroRps> |
|||
<ValorNota>[double]</ValorNota> |
|||
<MotivoCancelamento>[string]</MotivoCancelamento> |
|||
<PodeCancelarGuia>[string]</PodeCancelarGuia> |
|||
</Nota> |
|||
</Sdt_cancelanfe> |
|||
</ws_nfe.CANCELANOTAELETRONICA> |
|||
@ -0,0 +1,9 @@ |
|||
<ws_nfe.CONSULTANOTASPROTOCOLO xmlns="NFe"> |
|||
<Sdt_consultanotasprotocoloin> |
|||
<Protocolo>[string]</Protocolo> |
|||
<Login> |
|||
<CodigoUsuario>[string]</CodigoUsuario> |
|||
<CodigoContribuinte>[string]</CodigoContribuinte> |
|||
</Login> |
|||
</Sdt_consultanotasprotocoloin> |
|||
</ws_nfe.CONSULTANOTASPROTOCOLO> |
|||
@ -0,0 +1,9 @@ |
|||
<ws_nfe.CONSULTAPROTOCOLO xmlns="NFe"> |
|||
<Sdt_consultaprotocoloin> |
|||
<Protocolo>[string]</Protocolo> |
|||
<Login> |
|||
<CodigoUsuario>[string]</CodigoUsuario> |
|||
<CodigoContribuinte>[string]</CodigoContribuinte> |
|||
</Login> |
|||
</Sdt_consultaprotocoloin> |
|||
</ws_nfe.CONSULTAPROTOCOLO> |
|||
@ -0,0 +1,78 @@ |
|||
<ws_nfe.PROCESSARPS xmlns="NFe"> |
|||
<Sdt_processarpsin> |
|||
<Login> |
|||
<CodigoUsuario>[string]</CodigoUsuario> |
|||
<CodigoContribuinte>[string]</CodigoContribuinte> |
|||
</Login> |
|||
<SDTRPS> |
|||
<Ano>[string]</Ano> |
|||
<Mes>[string]</Mes> |
|||
<CPFCNPJ>[string]</CPFCNPJ> |
|||
<DTIni>[string]</DTIni> |
|||
<DTFin>[string]</DTFin> |
|||
<TipoTrib>[string]</TipoTrib> |
|||
<DtAdeSN>[string]</DtAdeSN> |
|||
<AlqIssSN_IP>[string]</AlqIssSN_IP> |
|||
<Versao>[string]</Versao> |
|||
<Reg20> |
|||
<!-- Optional --> |
|||
<Reg20Item> |
|||
<TipoNFS>[string]</TipoNFS> |
|||
<NumRps>[string]</NumRps> |
|||
<SerRps>[string]</SerRps> |
|||
<DtEmi>[string]</DtEmi> |
|||
<RetFonte>[string]</RetFonte> |
|||
<CodSrv>[string]</CodSrv> |
|||
<DiscrSrv>[string]</DiscrSrv> |
|||
<VlNFS>[string]</VlNFS> |
|||
<VlDed>[string]</VlDed> |
|||
<DiscrDed>[string]</DiscrDed> |
|||
<VlBasCalc>[string]</VlBasCalc> |
|||
<AlqIss>[string]</AlqIss> |
|||
<VlIss>[string]</VlIss> |
|||
<VlIssRet>[string]</VlIssRet> |
|||
<CpfCnpTom>[string]</CpfCnpTom> |
|||
<RazSocTom>[string]</RazSocTom> |
|||
<TipoLogtom>[string]</TipoLogtom> |
|||
<LogTom>[string]</LogTom> |
|||
<NumEndTom>[string]</NumEndTom> |
|||
<ComplEndTom>[string]</ComplEndTom> |
|||
<BairroTom>[string]</BairroTom> |
|||
<MunTom>[string]</MunTom> |
|||
<SiglaUFTom>[string]</SiglaUFTom> |
|||
<CepTom>[string]</CepTom> |
|||
<Telefone>[string]</Telefone> |
|||
<InscricaoMunicipal>[string]</InscricaoMunicipal> |
|||
<TipoLogLocPre>[string]</TipoLogLocPre> |
|||
<LogLocPre>[string]</LogLocPre> |
|||
<NumEndLocPre>[string]</NumEndLocPre> |
|||
<ComplEndLocPre>[string]</ComplEndLocPre> |
|||
<BairroLocPre>[string]</BairroLocPre> |
|||
<MunLocPre>[string]</MunLocPre> |
|||
<SiglaUFLocpre>[string]</SiglaUFLocpre> |
|||
<CepLocPre>[string]</CepLocPre> |
|||
<Email1>[string]</Email1> |
|||
<Email2>[string]</Email2> |
|||
<Email3>[string]</Email3> |
|||
<Reg30> |
|||
<!-- Optional --> |
|||
<Reg30Item> |
|||
<TributoSigla>[string]</TributoSigla> |
|||
<TributoAliquota>[string]</TributoAliquota> |
|||
<TributoValor>[string]</TributoValor> |
|||
</Reg30Item> |
|||
</Reg30> |
|||
</Reg20Item> |
|||
</Reg20> |
|||
<Reg90> |
|||
<QtdRegNormal>[string]</QtdRegNormal> |
|||
<ValorNFS>[string]</ValorNFS> |
|||
<ValorISS>[string]</ValorISS> |
|||
<ValorDed>[string]</ValorDed> |
|||
<ValorIssRetTom>[string]</ValorIssRetTom> |
|||
<QtdReg30>[string]</QtdReg30> |
|||
<ValorTributos>[string]</ValorTributos> |
|||
</Reg90> |
|||
</SDTRPS> |
|||
</Sdt_processarpsin> |
|||
</ws_nfe.PROCESSARPS> |
|||
@ -0,0 +1,5 @@ |
|||
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> |
|||
<Body> |
|||
{{ soap_body }} |
|||
</Body> |
|||
</Envelope> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue