77from erpbrasil .edoc .nfse import NFSe , ServicoNFSe
88
99try :
10- from nfselib .paulistana .v02 import (
10+ from nfselib .paulistana .v03 import (
1111 PedidoCancelamentoNFe ,
1212 PedidoConsultaLote ,
1313 PedidoConsultaNFe ,
1717 )
1818
1919 from erpbrasil .assinatura .assinatura import Assinatura
20-
2120 paulistana = True
2221except ImportError :
2322 paulistana = False
2423
25- endpoint = "ws/ lotenfe.asmx?WSDL"
24+ endpoint = "lotenfe.asmx?WSDL"
2625
2726if paulistana :
2827 servicos_base = {
5150
5251
5352class Paulistana (NFSe ):
53+
5454 def __init__ (
5555 self , transmissao , ambiente , cidade_ibge , cnpj_prestador , im_prestador
5656 ):
57- self ._url = "https://nfe .prefeitura.sp.gov.br"
57+ self ._url = "https://nfews .prefeitura.sp.gov.br"
5858
5959 # Não tem URL de homologação mas tem métodos para testes
6060 # no mesmo webservice
@@ -71,10 +71,8 @@ def __init__(
7171 def _prepara_envia_documento (self , edoc ):
7272 assinador = Assinatura (self ._transmissao .certificado )
7373 for rps in edoc .RPS :
74- data = rps .Assinatura
75- data_bytes = data .encode ("ascii" )
76- assinatura = assinador .sign_pkcs1v15_sha1 (data_bytes )
77- rps .Assinatura = b64encode (assinatura ).decode ()
74+ assinatura_bytes = assinador .sign_pkcs1v15_sha1 (rps .Assinatura )
75+ rps .Assinatura = assinatura_bytes
7876 xml_assinado = self .assina_raiz (edoc , "" )
7977 return xml_assinado
8078
@@ -94,7 +92,7 @@ def _prepara_consulta_recibo(self, proc_envio):
9492
9593 edoc = PedidoConsultaLote .PedidoConsultaLote (
9694 Cabecalho = PedidoConsultaLote .CabecalhoType (
97- Versao = 1 ,
95+ Versao = 2 ,
9896 CPFCNPJRemetente = PedidoConsultaNFe .tpCPFCNPJ (CNPJ = cnpj ),
9997 NumeroLote = numero_lote ,
10098 )
@@ -112,8 +110,8 @@ def _prepara_consultar_nfse_rps(self, **kwargs):
112110
113111 raiz = PedidoConsultaNFe .PedidoConsultaNFe (
114112 Cabecalho = PedidoConsultaNFe .CabecalhoType (
115- Versao = 1 ,
116- CPFCNPJRemetente = PedidoConsultaNFe .tpCPFCNPJ (CNPJ = cnpj_prestador ),
113+ Versao = 2 ,
114+ CPFCNPJRemetente = PedidoConsultaNFe .tpCPFCNPJ (CNPJ = cnpj_prestador )
117115 ),
118116 Detalhe = [
119117 PedidoConsultaNFe .DetalheType (
@@ -147,12 +145,12 @@ def _prepara_cancelar_nfse_envio(self, doc_numero):
147145 numero_nfse = doc_numero .get ("numero_nfse" )
148146 codigo_verificacao = doc_numero .get ("codigo_verificacao" ) or ""
149147
150- assinatura = self .im_prestador .zfill (8 )
148+ assinatura = self .im_prestador .zfill (12 )
151149 assinatura += numero_nfse .zfill (12 )
152150
153151 raiz = PedidoCancelamentoNFe .PedidoCancelamentoNFe (
154152 Cabecalho = PedidoCancelamentoNFe .CabecalhoType (
155- Versao = 1 ,
153+ Versao = 2 ,
156154 CPFCNPJRemetente = PedidoConsultaNFe .tpCPFCNPJ (CNPJ = self .cnpj_prestador ),
157155 ),
158156 Detalhe = [
0 commit comments