166
166
SVC_AN = {
167
167
AMBIENTE_PRODUCAO : {
168
168
"servidor" : "www.svc.fazenda.gov.br" ,
169
+ WS_NFE_INUTILIZACAO : "NFeInutilizacao4/NFeInutilizacao4.asmx?wsdl" ,
169
170
WS_NFE_CONSULTA : "NFeConsultaProtocolo4/NFeConsultaProtocolo4.asmx?wsdl" , # noqa
170
171
WS_NFE_SITUACAO : "NFeStatusServico4/NFeStatusServico4.asmx?wsdl" ,
171
172
WS_NFE_RECEPCAO_EVENTO : "NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx?wsdl" , # noqa
172
173
WS_NFE_AUTORIZACAO : "NFeAutorizacao4/NFeAutorizacao4.asmx?wsdl" ,
173
174
WS_NFE_RET_AUTORIZACAO : "NFeRetAutorizacao4/NFeRetAutorizacao4.asmx?wsdl" , # noqa
174
175
},
175
176
AMBIENTE_HOMOLOGACAO : {
176
- "servidor" : "hom.svc.fazenda.gov.br" ,
177
+ "servidor" : "hom.sefazvirtual.fazenda.gov.br" ,
178
+ WS_NFE_INUTILIZACAO : "NFeInutilizacao4/NFeInutilizacao4.asmx?wsdl" ,
177
179
WS_NFE_CONSULTA : "NFeConsultaProtocolo4/NFeConsultaProtocolo4.asmx?wsdl" , # noqa
178
180
WS_NFE_SITUACAO : "NFeStatusServico4/NFeStatusServico4.asmx?wsdl" ,
179
181
WS_NFE_RECEPCAO_EVENTO : "NFeRecepcaoEvento4/NFeRecepcaoEvento4.asmx?wsdl" , # noqa
675
677
"AN" : AN ,
676
678
}
677
679
680
+ ESTADO_WS_CONTINGENCIA = {
681
+ "AC" : SVC_AN ,
682
+ "AL" : SVC_AN ,
683
+ "AM" : SVC_RS ,
684
+ "AP" : SVC_AN ,
685
+ "BA" : SVC_RS ,
686
+ "CE" : SVC_AN ,
687
+ "DF" : SVC_AN ,
688
+ "ES" : SVC_AN ,
689
+ "GO" : SVC_RS ,
690
+ "MA" : SVC_RS ,
691
+ "MG" : SVC_AN ,
692
+ "MS" : SVC_RS ,
693
+ "MT" : SVC_RS ,
694
+ "PA" : SVC_AN ,
695
+ "PB" : SVC_AN ,
696
+ "PE" : SVC_RS ,
697
+ "PI" : SVC_RS ,
698
+ "PR" : SVC_RS ,
699
+ "RJ" : SVC_AN ,
700
+ "RN" : SVC_AN ,
701
+ "RO" : SVC_AN ,
702
+ "RR" : SVC_AN ,
703
+ "RS" : SVC_AN ,
704
+ "SC" : SVC_AN ,
705
+ "SE" : SVC_AN ,
706
+ "SP" : SVC_AN ,
707
+ "TO" : SVC_AN ,
708
+ }
709
+
678
710
679
- def localizar_url (servico , estado , mod = "55" , ambiente = 2 ):
711
+ def localizar_url (servico , estado , mod = "55" , ambiente = 2 , contingencia = False ):
680
712
sigla = SIGLA_ESTADO [estado ]
681
- ws = ESTADO_WS [sigla ]
713
+
714
+ ws = ESTADO_WS_CONTINGENCIA [sigla ] if contingencia else ESTADO_WS [sigla ]
682
715
683
716
if servico in (WS_DFE_DISTRIBUICAO , WS_DOWNLOAD_NFE ):
684
717
ws = AN
@@ -734,12 +767,14 @@ def __init__(
734
767
ambiente = "2" ,
735
768
mod = "55" ,
736
769
envio_sincrono = False ,
770
+ contingencia = False ,
737
771
):
738
772
super ().__init__ (transmissao , envio_sincrono )
739
773
self .versao = str (versao )
740
774
self .ambiente = str (ambiente )
741
775
self .uf = int (uf )
742
776
self .mod = str (mod )
777
+ self .contingencia = contingencia
743
778
744
779
def _edoc_situacao_ja_enviado (self , proc_consulta ):
745
780
if proc_consulta .resposta .cStat in ("100" , "110" , "150" , "301" , "302" ):
@@ -760,7 +795,13 @@ def status_servico(self):
760
795
return self ._post (
761
796
raiz ,
762
797
# 'https://hom.sefazvirtual.fazenda.gov.br/NFeStatusServico4/NFeStatusServico4.asmx?wsdl',
763
- localizar_url (WS_NFE_SITUACAO , str (self .uf ), self .mod , int (self .ambiente )),
798
+ localizar_url (
799
+ WS_NFE_SITUACAO ,
800
+ str (self .uf ),
801
+ self .mod ,
802
+ int (self .ambiente ),
803
+ self .contingencia ,
804
+ ),
764
805
"nfeStatusServicoNF" ,
765
806
retConsStatServ ,
766
807
)
@@ -777,7 +818,13 @@ def consulta_documento(self, chave):
777
818
return self ._post (
778
819
raiz ,
779
820
# 'https://hom.sefazvirtual.fazenda.gov.br/NFeConsultaProtocolo4/NFeConsultaProtocolo4.asmx?wsdl',
780
- localizar_url (WS_NFE_CONSULTA , str (self .uf ), self .mod , int (self .ambiente )),
821
+ localizar_url (
822
+ WS_NFE_CONSULTA ,
823
+ str (self .uf ),
824
+ self .mod ,
825
+ int (self .ambiente ),
826
+ self .contingencia ,
827
+ ),
781
828
"nfeConsultaNF" ,
782
829
retConsSitNFe ,
783
830
)
@@ -806,7 +853,11 @@ def envia_documento(self, edoc):
806
853
xml_envio_etree ,
807
854
# 'https://hom.sefazvirtual.fazenda.gov.br/NFeAutorizacao4/NFeAutorizacao4.asmx?wsdl',
808
855
localizar_url (
809
- WS_NFE_AUTORIZACAO , str (self .uf ), self .mod , int (self .ambiente )
856
+ WS_NFE_AUTORIZACAO ,
857
+ str (self .uf ),
858
+ self .mod ,
859
+ int (self .ambiente ),
860
+ self .contingencia ,
810
861
),
811
862
"nfeAutorizacaoLote" ,
812
863
retEnviNFe ,
@@ -823,7 +874,11 @@ def envia_inutilizacao(self, evento):
823
874
return self ._post (
824
875
xml_envio_etree ,
825
876
localizar_url (
826
- WS_NFE_INUTILIZACAO , str (self .uf ), self .mod , int (self .ambiente )
877
+ WS_NFE_INUTILIZACAO ,
878
+ str (self .uf ),
879
+ self .mod ,
880
+ int (self .ambiente ),
881
+ self .contingencia ,
827
882
),
828
883
"nfeInutilizacaoNF" ,
829
884
retInutNFe ,
@@ -845,7 +900,11 @@ def consulta_recibo(self, numero=False, proc_envio=False):
845
900
return self ._post (
846
901
raiz ,
847
902
localizar_url (
848
- WS_NFE_RET_AUTORIZACAO , str (self .uf ), self .mod , int (self .ambiente )
903
+ WS_NFE_RET_AUTORIZACAO ,
904
+ str (self .uf ),
905
+ self .mod ,
906
+ int (self .ambiente ),
907
+ self .contingencia ,
849
908
),
850
909
# 'ws/nferetautorizacao4.asmx'
851
910
"nfeRetAutorizacaoLote" ,
@@ -872,7 +931,11 @@ def enviar_lote_evento(self, lista_eventos, numero_lote=False):
872
931
return self ._post (
873
932
xml_envio_etree ,
874
933
localizar_url (
875
- WS_NFE_RECEPCAO_EVENTO , str (self .uf ), self .mod , int (self .ambiente )
934
+ WS_NFE_RECEPCAO_EVENTO ,
935
+ str (self .uf ),
936
+ self .mod ,
937
+ int (self .ambiente ),
938
+ self .contingencia ,
876
939
),
877
940
"nfeRecepcaoEvento" ,
878
941
retEnvEvento ,
@@ -1024,7 +1087,11 @@ def consultar_distribuicao(
1024
1087
return self ._post (
1025
1088
raiz ,
1026
1089
localizar_url (
1027
- WS_DFE_DISTRIBUICAO , str (self .uf ), self .mod , int (self .ambiente )
1090
+ WS_DFE_DISTRIBUICAO ,
1091
+ str (self .uf ),
1092
+ self .mod ,
1093
+ int (self .ambiente ),
1094
+ self .contingencia ,
1028
1095
),
1029
1096
"nfeDistDFeInteresse" ,
1030
1097
retDistDFeInt ,
@@ -1091,7 +1158,13 @@ def consultar_cadastro(self, uf, cnpj=None, cpf=None, ie=None):
1091
1158
1092
1159
return self ._post (
1093
1160
raiz ,
1094
- localizar_url (WS_NFE_CADASTRO , str (self .uf ), self .mod , int (self .ambiente )),
1161
+ localizar_url (
1162
+ WS_NFE_CADASTRO ,
1163
+ str (self .uf ),
1164
+ self .mod ,
1165
+ int (self .ambiente ),
1166
+ self .contingencia ,
1167
+ ),
1095
1168
"consultaCadastro" ,
1096
1169
retConsCad ,
1097
1170
)
0 commit comments