committed by
Danimar Ribeiro
13 changed files with 681 additions and 0 deletions
-
80pytrustnfe/nfse/campinas/__init__.py
-
30pytrustnfe/nfse/campinas/templates/ConsultaSeqRps.xsd
-
10pytrustnfe/nfse/campinas/templates/ConsultarLote.xml
-
46pytrustnfe/nfse/campinas/templates/ConsultarLote.xsd
-
18pytrustnfe/nfse/campinas/templates/cancelar.xml
-
55pytrustnfe/nfse/campinas/templates/cancelar.xsd
-
11pytrustnfe/nfse/campinas/templates/consulta_notas.xml
-
88pytrustnfe/nfse/campinas/templates/consulta_notas.xsd
-
19pytrustnfe/nfse/campinas/templates/consultarNFSeRps.xml
-
55pytrustnfe/nfse/campinas/templates/consultarNFSeRps.xsd
-
108pytrustnfe/nfse/campinas/templates/enviar.xml
-
149pytrustnfe/nfse/campinas/templates/enviar.xsd
-
12pytrustnfe/nfse/campinas/templates/soap_header.xml
@ -0,0 +1,80 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
# © 2017 Fábio Luna, Trustcode |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
import os |
||||
|
import suds |
||||
|
from lxml import etree |
||||
|
from pytrustnfe.xml import render_xml, sanitize_response |
||||
|
from pytrustnfe.nfse.assinatura import Assinatura |
||||
|
from pytrustnfe import HttpClient |
||||
|
|
||||
|
|
||||
|
def _render_xml(certificado, method, **kwargs): |
||||
|
path = os.path.join(os.path.dirname(__file__), 'templates') |
||||
|
xml_send = render_xml(path, '%s.xml' % method, True, **kwargs) |
||||
|
xml_send = etree.tostring(xml_send) |
||||
|
|
||||
|
return xml_send |
||||
|
|
||||
|
|
||||
|
def _validate(method, xml): |
||||
|
path = os.path.join(os.path.dirname(__file__), 'templates') |
||||
|
schema = os.path.join(path, '%s.xsd' % method) |
||||
|
|
||||
|
nfe = etree.fromstring(xml) |
||||
|
esquema = etree.XMLSchema(etree.parse(schema)) |
||||
|
esquema.validate(nfe) |
||||
|
erros = [x.message for x in esquema.error_log] |
||||
|
return erros |
||||
|
|
||||
|
|
||||
|
def _send(certificado, method, **kwargs): |
||||
|
url = 'http://issdigital.campinas.sp.gov.br/WsNFe2/LoteRps.jws?wsdl' # noqa |
||||
|
|
||||
|
path = os.path.join(os.path.dirname(__file__), 'templates') |
||||
|
|
||||
|
if method == "testeEnviar": |
||||
|
xml_send = render_xml(path, 'testeEnviar', **kwargs) |
||||
|
else: |
||||
|
xml_send = render_xml(path, '%s.xml' % method, False) |
||||
|
client = HttpClient(url) |
||||
|
|
||||
|
pfx_path = certificado.save_pfx() |
||||
|
signer = Assinatura(pfx_path, certificado.password) |
||||
|
xml_signed = signer.assina_xml(xml_send, '') |
||||
|
|
||||
|
try: |
||||
|
response = getattr(client.service, method)(xml_signed) |
||||
|
response, obj = sanitize_response(response) |
||||
|
except suds.WebFault as e: |
||||
|
return { |
||||
|
'sent_xml': xml_send, |
||||
|
'received_xml': e.fault.faultstring, |
||||
|
'object': None |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
'sent_xml': xml_send, |
||||
|
'received_xml': response, |
||||
|
'object': obj |
||||
|
} |
||||
|
|
||||
|
|
||||
|
def enviar(certificado, **kwargs): |
||||
|
if kwargs['ambiente'] == 'producao': |
||||
|
return _send(certificado, 'enviar', **kwargs) |
||||
|
else: |
||||
|
return _send(certificado, 'testeEnviar', **kwargs) |
||||
|
|
||||
|
|
||||
|
def cancelar(certificado, ** kwargs): |
||||
|
return _send(certificado, 'cancelar', **kwargs) |
||||
|
|
||||
|
|
||||
|
def consulta_lote(certificado, **kwargs): |
||||
|
return _send(certificado, 'ConsultarLote', **kwargs) |
||||
|
|
||||
|
|
||||
|
def consultar_lote_rps(certificado, **kwarg): |
||||
|
return _send(certificado, 'consultarNFSeRps', **kwarg) |
||||
@ -0,0 +1,30 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
|
||||
|
<xs:schema xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" |
||||
|
targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" |
||||
|
schemaLocation="Tipos.xsd" /> |
||||
|
<xs:element name="ConsultaSeqRps"> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCid" type="tipos:tpCodCidade" minOccurs="1" maxOccurs="1"/> |
||||
|
<xs:element name="IMPrestador" type="tipos:tpInscricaoMunicipal" minOccurs="1" maxOccurs="1"/> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" minOccurs="1" maxOccurs="1"/> |
||||
|
<xs:element name="SeriePrestacao" type="tipos:tpSeriePrestacao" minOccurs="0" maxOccurs="1"/> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" fixed="1" minOccurs="1" maxOccurs="1"/> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
</xs:schema> |
||||
@ -0,0 +1,10 @@ |
|||||
|
<ns1:ReqConsultaLote xmlns:ns1="http://localhost:8080/WsNFe2/lote" |
||||
|
xmlns:tipos="http://localhost:8080/WsNFe2/tp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://localhost:8080/WsNFe2/lote http://localhost:8080/WsNFe2/xsd/ReqConsultaLote.xsd"> |
||||
|
<Cabecalho> |
||||
|
<CodCidade>{{ consulta.cidade }}</CodCidade> |
||||
|
<CPFCNPJRemetente>{{ consulta.cpf_cnpj }}</CPFCNPJRemetente> |
||||
|
<Versao>1</Versao> |
||||
|
<NumeroLote>{{ consulta.lote }}</NumeroLote> |
||||
|
</Cabecalho> |
||||
|
</ns1:ReqConsultaLote> |
||||
@ -0,0 +1,46 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema |
||||
|
xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" schemaLocation="Tipos.xsd"/> |
||||
|
<xs:element name="ReqConsultaLote"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Schema utilizado para REQUISIçÂO de Consulta de Lote de RPS.</xs:documentation> |
||||
|
<xs:documentation>Este Schema XML é utilizado pelos Prestadores de serviços para consultarem Lote de RPS emitidos por eles.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Cabeçalho do pedido.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCidade" type="tipos:tpCodCidade" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Codigo da Cidade.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o CPF/CNPJ do Remetente autorizado a transmitir a mensagem XML.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" fixed="1" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a Versão do Schema XML utilizado.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="NumeroLote" type="tipos:tpNumero" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Número do Lote a ser consultado.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,18 @@ |
|||||
|
<ns1:ReqCancelamentoNFSe xmlns:ns1="http://localhost:8080/WsNFe2/lote" |
||||
|
xmlns:tipos="http://localhost:8080/WsNFe2/tp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://localhost:8080/WsNFe2/lote http://localhost:8080/WsNFe2/xsd/ReqCancelamentoNFSe.xsd"> |
||||
|
<Cabecalho> |
||||
|
<CodCidade>{{ cancelamento.cidade }}</CodCidade> |
||||
|
<CPFCNPJRemetente>{{ cancelamento.cpf_cnpj }}</CPFCNPJRemetente> |
||||
|
<transacao>true</transacao> |
||||
|
<Versao>1</Versao> |
||||
|
</Cabecalho> |
||||
|
<Lote Id="lote:1ABCDZ"> |
||||
|
<Nota Id="nota:{{ cancelamento.nota_id }}"> |
||||
|
<InscricaoMunicipalPrestador>{{ cancelamento.inscricao_municipal }}</InscricaoMunicipalPrestador> |
||||
|
<NumeroNota>{{ cancelamento.nota_id }}</NumeroNota> |
||||
|
<CodigoVerificacao>{{ cancelamento.assinatura }}</CodigoVerificacao> |
||||
|
<MotivoCancelamento>{{ cancelamento.motivo }}</MotivoCancelamento> |
||||
|
</Nota> |
||||
|
</Lote> |
||||
|
</ns1:ReqCancelamentoNFSe> |
||||
@ -0,0 +1,55 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by Marcel (DSF) --> |
||||
|
<xs:schema xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" |
||||
|
schemaLocation="Tipos.xsd" /> |
||||
|
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" |
||||
|
schemaLocation="xmldsig-core-schema_v1.01.xsd" /> |
||||
|
<xs:element name="ReqCancelamentoNFSe"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Schema utilizado para Cancelamento de NFSe.</xs:documentation> |
||||
|
<xs:documentation>Este Schema XML é utilizado pelos Prestadores de serviços cancelarem NFSe emitidas por eles.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Cabeçalho do pedido.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCidade" type="tipos:tpCodCidade" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Codigo da Cidade.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o CPF/CNPJ do Remetente autorizado a transmitir a mensagem XML.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="transacao" type="xs:boolean" default="true" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe se as NF-e a serem canceladas farão parte de uma mesma transação. True - As NF-e só serão canceladas se não ocorrer nenhum evento de erro durante o processamento de todo o lote; False - As NF-e aptas a serem canceladas serão canceladas, mesmo que ocorram eventos de erro durante processamento do cancelamento de outras NF-e deste lote.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" fixed="1" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a Versão do Schema XML utilizado.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
<xs:element name="Lote" type="tipos:tpLoteCancelamentoNFSe"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Detalhe do pedido de cancelamento de NFSe. Cada detalhe deverá conter a Chave de uma NFSe e sua respectiva assinatura de cancelamento.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element ref="ds:Signature" minOccurs="0" maxOccurs="1" /> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,11 @@ |
|||||
|
<ns1:ReqConsultaNotas xmlns:ns1="http://localhost:8080/WsNFe2/lote" xmlns:tipos="http://localhost:8080/WsNFe2/tp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost:8080/WsNFe2/lote http://localhost:8080/WsNFe2/xsd/ReqConsultaNotas.xsd"> |
||||
|
<Cabecalho Id="Consulta:notas"> |
||||
|
<CodCidade>{{ consulta.cidade }}</CodCidade> |
||||
|
<CPFCNPJRemetente>{{ consulta.cpf_cnpj }}</CPFCNPJRemetente> |
||||
|
<InscricaoMunicipalPrestador>{{ consulta.inscricao_municipal }}</InscricaoMunicipalPrestador> |
||||
|
<dtInicio>{{ consulta.data_inicio }}</dtInicio> |
||||
|
<dtFim>{{ consulta.data_final }}</dtFim> |
||||
|
<NotaInicial>{{ consulta.nota_inicial }}</NotaInicial> |
||||
|
<Versao>1</Versao> |
||||
|
</Cabecalho> |
||||
|
</ns1:ReqConsultaNotas> |
||||
@ -0,0 +1,88 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<xs:schema xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" |
||||
|
schemaLocation="Tipos.xsd" /> |
||||
|
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" |
||||
|
schemaLocation="xmldsig-core-schema_v1.01.xsd" /> |
||||
|
<xs:element name="ReqConsultaNotas"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Schema utilizado para REQUISIÇAO de consultas |
||||
|
de notas que foram enviadas por lote de RPS.</xs:documentation> |
||||
|
<xs:documentation>Este Schema XML é utilizado pelos prestadores |
||||
|
de serviços para consultas de notas que foram enviadas por lote de |
||||
|
RPS.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Cabeçalho do pedido.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCidade" type="tipos:tpCodCidade" |
||||
|
minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Codigo da Cidade. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" |
||||
|
minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o CPF/CNPJ do Remetente |
||||
|
autorizado a transmitir a mensagem XML.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="InscricaoMunicipalPrestador" type="tipos:tpInscricaoMunicipal" |
||||
|
minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a Inscrição Municipal do |
||||
|
Prestador</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="dtInicio" type="xs:date" minOccurs="1" |
||||
|
maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a data de início do período |
||||
|
transmitido (AAAA-MM-DD).</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="dtFim" type="xs:date" minOccurs="1" |
||||
|
maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a data final do período |
||||
|
transmitido (AAAA-MM-DD).</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="NotaInicial" type="tipos:tpNumero" |
||||
|
minOccurs="0" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Numero da nota inicial da consulta. Ou |
||||
|
seja a consulta ira retornar as notas no periodo, onde o |
||||
|
numero da nota seja maior ou igual a esse numero. O retorno |
||||
|
não pode ultrapassar 500Kb. Caso não tenha o numero da nota, |
||||
|
passar o valor Zero, será retornado as notas geradas no |
||||
|
periodo até o limite de 500kb.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" |
||||
|
minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a Versão.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
|
||||
|
</xs:sequence> |
||||
|
<xs:attribute name="Id" type="xs:string" use="optional"/> |
||||
|
</xs:complexType> |
||||
|
|
||||
|
</xs:element> |
||||
|
<xs:element ref="ds:Signature" minOccurs="0" |
||||
|
maxOccurs="1" /> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,19 @@ |
|||||
|
<ns1:ReqConsultaNFSeRPS xmlns:ns1="http://localhost:8080/WsNFe2/lote" |
||||
|
xmlns:tipos="http://localhost:8080/WsNFe2/tp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://localhost:8080/WsNFe2/lote http://localhost:8080/WsNFe2/xsd/ReqConsultaNFSeRPS.xsd"> |
||||
|
<Cabecalho> |
||||
|
<CodCidade>{{ consulta.cidade }}</CodCidade> |
||||
|
<CPFCNPJRemetente>{{ consulta.cpf_cnpj }}</CPFCNPJRemetente> |
||||
|
<transacao>true</transacao> |
||||
|
<Versao>1</Versao> |
||||
|
</Cabecalho> |
||||
|
<Lote Id="lote:{{ consulta.lote }}"> |
||||
|
<RPSConsulta> |
||||
|
<RPS Id="rps:{{ consulta.rps_id }}"> |
||||
|
<InscricaoMunicipalPrestador>{{ consulta.inscricao_municipal }}</InscricaoMunicipalPrestador> |
||||
|
<NumeroRPS>{{ consulta.rps_id }}</NumeroRPS> |
||||
|
<SeriePrestacao>{{ consulta.serie_prestacao }}</SeriePrestacao> |
||||
|
</RPS> |
||||
|
</RPSConsulta> |
||||
|
</Lote> |
||||
|
</ns1:ReqConsultaNFSeRPS> |
||||
@ -0,0 +1,55 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- edited with XMLSpy v2008 sp1 (http://www.altova.com) by Marcel (DSF) --> |
||||
|
<xs:schema xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" |
||||
|
schemaLocation="Tipos.xsd" /> |
||||
|
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" |
||||
|
schemaLocation="xmldsig-core-schema_v1.01.xsd" /> |
||||
|
<xs:element name="ReqConsultaNFSeRPS"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Schema utilizado para Consulta de NFSe.</xs:documentation> |
||||
|
<xs:documentation>Este Schema XML é utilizado pelos Prestadores de serviços consultarem NFSe emitidas por eles.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Cabeçalho do pedido.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCidade" type="tipos:tpCodCidade" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Codigo da Cidade.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o CPF/CNPJ do Remetente autorizado a transmitir a mensagem XML.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="transacao" type="xs:boolean" default="true" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe se as NF-e a serem consultadas farão parte de uma mesma transação. Informe sempre True.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" fixed="1" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe a Versão do Schema XML utilizado.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
<xs:element name="Lote" type="tipos:tpLoteConsultaNFSe" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Detalhe do pedido de consulta de NFSe. Cada detalhe deverá conter a Chave de uma NFSe e sua respectiva assinatura de consulta.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element ref="ds:Signature" minOccurs="0" maxOccurs="1" /> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,108 @@ |
|||||
|
<ns1:ReqEnvioLoteRPS xmlns:ns1="http://localhost:8080/WsNFe2/lote" |
||||
|
xmlns:tipos="http://localhost:8080/WsNFe2/tp" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xsi:schemaLocation="http://localhost:8080/WsNFe2/lote http://localhost:8080/WsNFe2/xsd/ReqEnvioLoteRPS.xsd"> |
||||
|
<Cabecalho> |
||||
|
<CodCidade>{{ nfse.cidade }}</CodCidade> |
||||
|
<CPFCNPJRemetente>{{ nfse.cpf_cnpj }}</CPFCNPJRemetente> |
||||
|
<RazaoSocialRemetente>{{ nfse.remetente }}</RazaoSocialRemetente> |
||||
|
<transacao>{{ nfse.transacao }}</transacao> |
||||
|
<dtInicio>{{ nfse.data_inicio|format_date }}</dtInicio> |
||||
|
<dtFim>{{ nfse.data_fim|format_date }}</dtFim> |
||||
|
<QtdRPS>{{ nfse.total_rps }}</QtdRPS> |
||||
|
<ValorTotalServicos>{{ nfse.total_servicos }}</ValorTotalServicos> |
||||
|
<ValorTotalDeducoes>{{ nfse.total_deducoes }}</ValorTotalDeducoes> |
||||
|
<Versao>1</Versao> |
||||
|
<MetodoEnvio>WS</MetodoEnvio> |
||||
|
</Cabecalho> |
||||
|
<Lote Id="{{ nfse.lote_id }}"> |
||||
|
{% for rps in nfse.lista_rps -%} |
||||
|
<RPS Id="{{ rps.numero }}"> |
||||
|
<Assinatura>{{ rps.assinatura }}</Assinatura> |
||||
|
<InscricaoMunicipalPrestador>{{ rps.prestador.inscricao_municipal }} |
||||
|
</InscricaoMunicipalPrestador> |
||||
|
<RazaoSocialPrestador>{{ rps.prestador.razao_social }}</RazaoSocialPrestador> |
||||
|
<TipoRPS>RPS</TipoRPS> |
||||
|
<SerieRPS>{{ rps.serie }}</SerieRPS> |
||||
|
<NumeroRPS>{{ rps.numero }}</NumeroRPS> |
||||
|
<DataEmissaoRPS>{{ rps.data_emissao|format_datetime }} |
||||
|
</DataEmissaoRPS> |
||||
|
<SituacaoRPS>{{ rps.situacao }}</SituacaoRPS> |
||||
|
<SerieRPSSubstituido></SerieRPSSubstituido> |
||||
|
<NumeroRPSSubstituido>0</NumeroRPSSubstituido> |
||||
|
<NumeroNFSeSubstituida>0</NumeroNFSeSubstituida> |
||||
|
<DataEmissaoNFSeSubstituida>1900-01-01</DataEmissaoNFSeSubstituida> |
||||
|
<SeriePrestacao>{{ rps.serie_prestacao }}</SeriePrestacao> |
||||
|
<InscricaoMunicipalTomador>{{ rps.tomador.inscricao_municipal }}</InscricaoMunicipalTomador> |
||||
|
<CPFCNPJTomador>{{ rps.tomador.cpf_cnpj }}</CPFCNPJTomador> |
||||
|
<RazaoSocialTomador>{{ rps.tomador.razao_social }} |
||||
|
</RazaoSocialTomador> |
||||
|
<TipoLogradouroTomador>{{ rps.tomador.tipo_logradouro }} |
||||
|
</TipoLogradouroTomador> |
||||
|
<LogradouroTomador>{{ rps.tomador.logradouro }}</LogradouroTomador> |
||||
|
<NumeroEnderecoTomador>{{ rps.tomador.numero }} |
||||
|
</NumeroEnderecoTomador> |
||||
|
<TipoBairroTomador>{{ rps.tomador.tipo_bairro }}</TipoBairroTomador> |
||||
|
<BairroTomador>{{ rps.tomador.bairro }}</BairroTomador> |
||||
|
<CidadeTomador>{{ rps.tomador.cidade }}</CidadeTomador> |
||||
|
<CidadeTomadorDescricao>{{ rps.tomador.cidade_descricao }} |
||||
|
</CidadeTomadorDescricao> |
||||
|
<CEPTomador>{{ rps.tomador.cep }}</CEPTomador> |
||||
|
<EmailTomador>{{ rps.tomador.email }}</EmailTomador> |
||||
|
<CodigoAtividade>{{ rps.codigo_atividade }}</CodigoAtividade> |
||||
|
<AliquotaAtividade>{{ rps.aliquota_atividade }}</AliquotaAtividade> |
||||
|
<TipoRecolhimento>{{ rps.tipo_recolhimento }}</TipoRecolhimento> |
||||
|
<MunicipioPrestacao>{{ rps.municipio_prestacao }} |
||||
|
</MunicipioPrestacao> |
||||
|
<MunicipioPrestacaoDescricao>{{ rps.municipio_descricao_prestacao }} |
||||
|
</MunicipioPrestacaoDescricao> |
||||
|
<Operacao>{{ rps.operacao }}</Operacao> |
||||
|
<Tributacao>{{ rps.tributacao }}</Tributacao> |
||||
|
<ValorPIS>{{ rps.valor_pis }}</ValorPIS> |
||||
|
<ValorCOFINS>{{ rps.valor_cofins }}</ValorCOFINS> |
||||
|
<ValorINSS>{{ rps.valor_inss }}</ValorINSS> |
||||
|
<ValorIR>{{ rps.valor_ir }}</ValorIR> |
||||
|
<ValorCSLL>{{ rps.valor_csll }}</ValorCSLL> |
||||
|
<AliquotaPIS>{{ rps.aliquota_pis }}</AliquotaPIS> |
||||
|
<AliquotaCOFINS>{{ rps.aliquota_cofins }}</AliquotaCOFINS> |
||||
|
<AliquotaINSS>{{ rps.aliquota_inss }}</AliquotaINSS> |
||||
|
<AliquotaIR>{{ rps.aliquota_ir }}</AliquotaIR> |
||||
|
<AliquotaCSLL>{{ rps.aliquota_csll }}</AliquotaCSLL> |
||||
|
<DescricaoRPS>{{ rps.descricao }}</DescricaoRPS> |
||||
|
<DDDPrestador>{{ rps.prestador.ddd }}</DDDPrestador> |
||||
|
<TelefonePrestador>{{ rps.prestador.telefone }}</TelefonePrestador> |
||||
|
<DDDTomador>{{ rps.tomador.ddd }}</DDDTomador> |
||||
|
<TelefoneTomador>{{ rps.tomador.telefone }}</TelefoneTomador> |
||||
|
<MotCancelamento>{{ rps.motivo_cancelamento }}</MotCancelamento> |
||||
|
{% if rps.deducoes|count > 0 %} |
||||
|
<Deducoes> |
||||
|
{% for deducao in rps.deducoes -%} |
||||
|
<Deducao> |
||||
|
<DeducaoPor>{{ deducao.por }}</DeducaoPor> |
||||
|
<TipoDeducao>{{ deducao.tipo }}</TipoDeducao> |
||||
|
<CPFCNPJReferencia>{{ deducao.cnpj_referencia }}</CPFCNPJReferencia> |
||||
|
<NumeroNFReferencia>{{ deducao.nf_referencia }}</NumeroNFReferencia> |
||||
|
<ValorTotalReferencia>{{ deducao.valor_referencia }}</ValorTotalReferencia> |
||||
|
<PercentualDeduzir>{{ deducao.percentual_deduzir }}</PercentualDeduzir> |
||||
|
<ValorDeduzir>{{ deducao.valor_deduzir }}</ValorDeduzir> |
||||
|
</Deducao> |
||||
|
{% endfor %} |
||||
|
</Deducoes> |
||||
|
{% endif %} |
||||
|
{% if rps.deducoes|count == 0 %} |
||||
|
<Deducoes /> |
||||
|
{% endif %} |
||||
|
<Itens> |
||||
|
{% for item in rps.itens -%} |
||||
|
<Item> |
||||
|
<DiscriminacaoServico>{{ item.descricao }}</DiscriminacaoServico> |
||||
|
<Quantidade>{{ item.quantidade }}</Quantidade> |
||||
|
<ValorUnitario>{{ item.valor_unitario }}</ValorUnitario> |
||||
|
<ValorTotal>{{ item.valor_total }}</ValorTotal> |
||||
|
<Tributavel>S</Tributavel> |
||||
|
</Item> |
||||
|
{% endfor %} |
||||
|
</Itens> |
||||
|
</RPS> |
||||
|
{% endfor %} |
||||
|
</Lote> |
||||
|
</ns1:ReqEnvioLoteRPS> |
||||
@ -0,0 +1,149 @@ |
|||||
|
<xs:schema xmlns:tipos="http://localhost:8080/WsNFe2/tp" |
||||
|
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" |
||||
|
xmlns:ns1="http://localhost:8080/WsNFe2/lote" targetNamespace="http://localhost:8080/WsNFe2/lote"> |
||||
|
<xs:import namespace="http://localhost:8080/WsNFe2/tp" |
||||
|
schemaLocation="Tipos.xsd" /> |
||||
|
<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" |
||||
|
schemaLocation="xmldsig-core-schema_v1.01.xsd" /> |
||||
|
<xs:element name="ReqEnvioLoteRPS"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Schema utilizado para envio de lote de RPS.</xs:documentation> |
||||
|
<xs:documentation>Este Schema XML é utilizado pelos prestadores |
||||
|
de serviços para substituição em lote de RPS por NFS-e. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="Cabecalho"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Cabeçalho do Lote.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
<xs:complexType> |
||||
|
<xs:sequence> |
||||
|
<xs:element name="CodCidade" type="tipos:tpCodCidade" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Codigo da Cidade no Padrão SIAFI. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="CPFCNPJRemetente" type="tipos:tpCPFCNPJ" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
CNPJ do contribuinte ou CPF do Responsável Legal autorizado a entregar o lote. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="RazaoSocialRemetente" type="tipos:tpRazaoSocial" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe o Nome do Contribuinte ou do Responsável Legal |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="transacao" type="xs:boolean" |
||||
|
default="true" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe se os RPS a serem |
||||
|
substituídos por |
||||
|
NF-e farão |
||||
|
parte de uma mesma transação. |
||||
|
True - Os RPS só serão |
||||
|
substituídos por NF-e se não |
||||
|
ocorrer nenhum evento de erro |
||||
|
durante o processamento de todo |
||||
|
o lote; False - Os RPS válidos |
||||
|
serão substituídos por NF-e, |
||||
|
mesmo que ocorram eventos de |
||||
|
erro durante processamento de |
||||
|
outros RPS deste lote. Por definição |
||||
|
estão sendo aceitos apenas lotes com RPS válidos, |
||||
|
o lote é |
||||
|
recusado caso haja algum RPS inválido. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="dtInicio" type="xs:date" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe a data de início do |
||||
|
período |
||||
|
transmitido |
||||
|
(AAAA-MM-DD). |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="dtFim" type="xs:date" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe a data final do período |
||||
|
transmitido |
||||
|
(AAAA-MM-DD). |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="QtdRPS" type="tipos:tpQtdRpsLote" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe o total de RPS contidos |
||||
|
na mensagem |
||||
|
XML. OBS: O xml não pode ultrapassar o tamanho maximo de 500kb. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="ValorTotalServicos" type="tipos:tpValor" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe o valor total dos |
||||
|
serviços prestados |
||||
|
dos RPS |
||||
|
contidos na mensagem XML. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="ValorTotalDeducoes" type="tipos:tpValor" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe o valor total das |
||||
|
deduções dos RPS |
||||
|
contidos na |
||||
|
mensagem XML. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="Versao" type="tipos:tpVersao" fixed="1" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation> |
||||
|
Informe a Versão do Schema XML |
||||
|
utilizado. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="MetodoEnvio" type="tipos:tpMetodoEnvio" |
||||
|
minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe o Método de Envio</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element name="VersaoComponente" type="tipos:tpVersaoComponente" |
||||
|
minOccurs="0" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Versão da DLL de envio de lote. Não é necessário informar esse campo caso não utilize a DLL. |
||||
|
</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
|
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
<xs:element name="Lote" type="tipos:tpLote" minOccurs="1" maxOccurs="1"> |
||||
|
<xs:annotation> |
||||
|
<xs:documentation>Informe os RPS a serem substituidos por |
||||
|
NF-e.</xs:documentation> |
||||
|
</xs:annotation> |
||||
|
</xs:element> |
||||
|
<xs:element ref="ds:Signature" minOccurs="0" maxOccurs="1" /> |
||||
|
</xs:sequence> |
||||
|
</xs:complexType> |
||||
|
</xs:element> |
||||
|
</xs:schema> |
||||
@ -0,0 +1,12 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" |
||||
|
xmlns:dsf="http://dsfnet.com.br"> |
||||
|
<soapenv:Body> |
||||
|
<dsf:enviar soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> |
||||
|
<mensagemXml xsi:type="xsd:string"><![CDATA[ |
||||
|
{% block content %}{% endblock %} |
||||
|
]]></mensagemXml> |
||||
|
</dsf:enviar> |
||||
|
</soapenv:Body> |
||||
|
</soapenv:Envelope> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue