Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] Mescla e-Social e EFD/Reinf desenvolvidos pela ABGF a pysped or… #71

Open
wants to merge 1 commit into
base: python3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pysped/efdreinf/leiaute/evtFechamento_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,8 @@ def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.evtFechaEvPer.xml = arquivo
self.Signature.xml = self._le_noh('//Reinf/evtFechaEvPer/sig:Signature')
return True

def gera_id_evento(self, data_hora):
def gera_id_evento(self, data_hora, sequencia=False):

#A identificação única do evento (Id) é composta por 36 caracteres, conforme o que segue: IDTNNNNNNNNNNNNNNAAAAMMDDHHMMSSQQQQQ
#ID - Texto Fixo "ID";
Expand All @@ -268,13 +267,16 @@ def gera_id_evento(self, data_hora):
#eventos na mesma data/hora, completando com zeros à esquerda.
#OBS.: No caso de pessoas jurídicas, o CNPJ informado deverá conter 8 ou 14 posições de
#acordo com o enquadramento do contribuinte para preenchimento do campo {ideEmpregador/nrInsc} do evento S-1000, completando-se com zeros à direita, se necessário.


if not sequencia:
sequencia=1

id_evento = 'ID'
id_evento += self.evtFechaEvPer.ideContri.tpInsc.valor
id_evento += str(self.evtFechaEvPer.ideContri.nrInsc.valor)[0:8] + '000000'
# id_evento += str(self.evtInfoContri.ideContri.nrInsc.valor).zfill(14)
id_evento += data_hora
id_evento += str(1).zfill(5)
id_evento += str(sequencia).zfill(5)

# Define o Id
#
Expand Down
10 changes: 6 additions & 4 deletions pysped/efdreinf/leiaute/evtInfoContribuinte_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,8 @@ def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.evtInfoContri.xml = arquivo
self.Signature.xml = self._le_noh('//Reinf/evtInfoContri/sig:Signature')
return True

def gera_id_evento(self, data_hora):
def gera_id_evento(self, data_hora, sequencia=False):

#A identificação única do evento (Id) é composta por 36 caracteres, conforme o que segue: IDTNNNNNNNNNNNNNNAAAAMMDDHHMMSSQQQQQ
#ID - Texto Fixo "ID";
Expand All @@ -369,13 +368,16 @@ def gera_id_evento(self, data_hora):
#eventos na mesma data/hora, completando com zeros à esquerda.
#OBS.: No caso de pessoas jurídicas, o CNPJ informado deverá conter 8 ou 14 posições de
#acordo com o enquadramento do contribuinte para preenchimento do campo {ideEmpregador/nrInsc} do evento S-1000, completando-se com zeros à direita, se necessário.


if not sequencia:
sequencia=1

id_evento = 'ID'
id_evento += self.evtInfoContri.ideContri.tpInsc.valor
id_evento += str(self.evtInfoContri.ideContri.nrInsc.valor)[0:8] + '000000'
# id_evento += str(self.evtInfoContri.ideContri.nrInsc.valor).zfill(14)
id_evento += data_hora
id_evento += str(1).zfill(5)
id_evento += str(sequencia).zfill(5)

# Define o Id
#
Expand Down
10 changes: 6 additions & 4 deletions pysped/efdreinf/leiaute/evtTomadorServicos_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,8 @@ def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.evtServTom.xml = arquivo
self.Signature.xml = self._le_noh('//Reinf/evtServTom/sig:Signature')
return True

def gera_id_evento(self, data_hora):
def gera_id_evento(self, data_hora, sequencia=False):

#A identificação única do evento (Id) é composta por 36 caracteres, conforme o que segue: IDTNNNNNNNNNNNNNNAAAAMMDDHHMMSSQQQQQ
#ID - Texto Fixo "ID";
Expand All @@ -463,13 +462,16 @@ def gera_id_evento(self, data_hora):
#eventos na mesma data/hora, completando com zeros à esquerda.
#OBS.: No caso de pessoas jurídicas, o CNPJ informado deverá conter 8 ou 14 posições de
#acordo com o enquadramento do contribuinte para preenchimento do campo {ideEmpregador/nrInsc} do evento S-1000, completando-se com zeros à direita, se necessário.


if not sequencia:
sequencia=1

id_evento = 'ID'
id_evento += self.evtServTom.ideContri.tpInsc.valor
id_evento += str(self.evtServTom.ideContri.nrInsc.valor)[0:8] + '000000'
# id_evento += str(self.evtInfoContri.ideContri.nrInsc.valor).zfill(14)
id_evento += data_hora
id_evento += str(1).zfill(5)
id_evento += str(sequencia).zfill(5)

# Define o Id
#
Expand Down
9 changes: 8 additions & 1 deletion pysped/efdreinf/leiaute/retornoLoteEventos_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,11 @@ def __init__(self):
self.Id = TagCaracter(nome='retornoLoteEventos', propriedade='id', raiz='//Reinf', namespace=NAMESPACE_LOTE_EFDREINF, namespace_obrigatorio=False)
self.ideTransmissor = IdeTransmissor()
self.retornoStatus = RetornoStatus()
# self.retornoEventos = RetornoEventos()
self.cdRetorno = ''
self.descRetorno = ''
self.ocorrencias = []
self.retornoEventos = []
self.eventos = []
# self.caminho_esquema = os.path.join(DIRNAME, 'schema/', ESQUEMA_ATUAL + '/')
# self.arquivo_esquema = 'RetornoLoteEventos.xsd'

Expand All @@ -243,6 +246,10 @@ def set_xml(self, arquivo):
self.ideTransmissor.xml = arquivo
self.retornoStatus.xml = arquivo
self.retornoEventos = self.le_grupo('//Reinf/retornoLoteEventos/retornoEventos/evento', RetornoTotalizadorEvento, namespace=NAMESPACE_LOTE_EFDREINF, sigla_ns='res')
self.eventos = self.retornoEventos
self.cdRetorno = self.retornoStatus.cdRetorno.valor
self.descRetorno = self.retornoStatus.descRetorno.valor
self.ocorrencias = self.retornoStatus.dadosRegistroOcorrenciaLote.ocorrencias
return True

xml = property(get_xml, set_xml)
33 changes: 19 additions & 14 deletions pysped/efdreinf/leiaute/retornoTotalizadorContribuinte_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class RCPRB(XMLNFe):
def __init__(self):
super(RCPRB, self).__init__()
self.CRCPRB = TagCaracter(nome='CRCPRB', tamanho=[1, 6], raiz='//Reinf/evtTotalContrib/infoTotal/RCPRB', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.vlrCRCPRB = TagDecimal(nome='vlrCRCPRB', raiz='//Reinf/evtTotal/infoTotalContrib/RCPRB', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.vlrCRCPRBSusp = TagDecimal(nome='vlrCRCPRBSusp', raiz='//Reinf/evtTotalContrib/infoTotal/RCPRB', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, obrigatorio=False)
self.vlrCRCPRB = TagDecimalVirgula(nome='vlrCRCPRB', raiz='//Reinf/evtTotal/infoTotalContrib/RCPRB', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.vlrCRCPRBSusp = TagDecimalVirgula(nome='vlrCRCPRBSusp', raiz='//Reinf/evtTotalContrib/infoTotal/RCPRB', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, obrigatorio=False)

def get_xml(self):
xml = XMLNFe.get_xml(self)
Expand Down Expand Up @@ -242,8 +242,8 @@ def set_xml(self, arquivo):
class InfoTotalContrib(XMLNFe):
def __init__(self):
super(InfoTotalContrib, self).__init__()
self.nrRecArqBase = TagCaracter(nome='nrRecArqBase', raiz='//Reinf/evtTotalContrib/infoTotalContrib', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, obrigatorio=False)
self.indExistInfo = TagCaracter(nome='indExistInfo', raiz='//Reinf/evtTotalContrib/infoTotalContrib', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.nrRecArqBase = TagCaracter(nome='nrRecArqBase', tamanho=[1, 52], raiz='//Reinf/evtTotalContrib/infoTotalContrib', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, obrigatorio=False)
self.indExistInfo = TagCaracter(nome='indExistInfo', tamanho=[1, 1], raiz='//Reinf/evtTotalContrib/infoTotalContrib', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.RTom = []
self.RPrest = []
self.RRecRepAD = []
Expand All @@ -267,7 +267,6 @@ def get_xml(self):
if len(self.RComl) >= 1:
for r in self.RComl:
xml += r.xml

if len(self.RCPRB) >= 1:
for r in self.RCPRB:
xml += r.xml
Expand All @@ -291,7 +290,7 @@ def set_xml(self, arquivo):
class InfoRecEv(XMLNFe):
def __init__(self):
super(InfoRecEv, self).__init__()
self.nrProtEntr = TagCaracter(nome='nrProtEntr', tamanho=[0, 49], raiz='//Reinf/evtTotalContrib/infoRecEv', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, obrigatorio=False)
self.nrProtEntr = TagCaracter(nome='nrProtEntr', tamanho=[1, 49], raiz='//Reinf/evtTotalContrib/infoRecEv', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.dhProcess = TagDataHora(nome='dhProcess', raiz='//Reinf/evtTotalContrib/infoRecEv', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.tpEv = TagCaracter(nome='tpEv', tamanho=[1, 6], raiz='//Reinf/evtTotalContrib/infoRecEv', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.idEv = TagCaracter(nome='idEv', tamanho=[1, 36], raiz='//Reinf/evtTotalContrib/infoRecEv', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
Expand Down Expand Up @@ -323,10 +322,10 @@ def set_xml(self, arquivo):
class Ocorrencias(XMLNFe):
def __init__(self):
super(Ocorrencias, self).__init__()
self.tpOcorr = TagCaracter(nome='tpOcorr' , raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.localErroAviso = TagCaracter(nome='localErroAviso', raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.codResp = TagCaracter(nome='codResp' , raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.dscResp = TagCaracter(nome='dscResp' , raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.tpOcorr = TagCaracter(nome='tpOcorr' , tamanho=[1, 1], raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.localErroAviso = TagCaracter(nome='localErroAviso', tamanho=[1, 100], raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.codResp = TagCaracter(nome='codResp' , tamanho=[1, 6], raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.dscResp = TagCaracter(nome='dscResp' , tamanho=[1, 999], raiz='//regOcorrs', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)

def get_xml(self):
xml = XMLNFe.get_xml(self)
Expand Down Expand Up @@ -362,10 +361,10 @@ def get_xml(self):
xml += self.cdRetorno.xml
xml += self.descRetorno.xml
if len(self.regOcorrs) >= 1:
xml += '<regOcorrs>'
# xml += '<regOcorrs>'
for o in self.regOcorrs:
xml += o.xml
xml += '</regOcorrs>'
# xml += '</regOcorrs>'

xml += '</ideStatus>'
return xml
Expand Down Expand Up @@ -403,7 +402,7 @@ def set_xml(self, arquivo):
class IdeContri(XMLNFe):
def __init__(self):
super(IdeContri, self).__init__()
self.tpInsc = TagCaracter(nome='tpInsc', valor='1', raiz='//Reinf/evtTotalContrib/ideContri', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.tpInsc = TagCaracter(nome='tpInsc', tamanho=[1, 1], raiz='//Reinf/evtTotalContrib/ideContri', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False, valor='1')
self.nrInsc = TagCaracter(nome='nrInsc', tamanho=[8, 14], raiz='//Reinf/evtTotalContrib/ideContri', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)

def get_xml(self):
Expand All @@ -426,7 +425,7 @@ def set_xml(self, arquivo):
class IdeEvento(XMLNFe):
def __init__(self):
super(IdeEvento, self).__init__()
self.perApur = TagCaracter(nome='perApur', tamanho=[1, 7], raiz='//Reinf/evtTotalContrib/ideEvento', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)
self.perApur = TagCaracter(nome='perApur', tamanho=[1, 10], raiz='//Reinf/evtTotalContrib/ideEvento', namespace=NAMESPACE_EFDREINF, namespace_obrigatorio=False)

def get_xml(self):
xml = XMLNFe.get_xml(self)
Expand Down Expand Up @@ -483,6 +482,9 @@ def __init__(self):
self.evtTotalContrib = EvtTotalContrib()
self.caminho_esquema = os.path.join(DIRNAME, 'schema/', ESQUEMA_ATUAL + '/')
self.arquivo_esquema = 'retornoTotalizadorContribuinte.xsd'
self.cdResposta = ''
self.descResposta = ''
self.ocorrencias = []
self.id_evento = ''
self.Signature = Signature()
self.evento = self.evtTotalContrib
Expand All @@ -508,6 +510,9 @@ def set_xml(self, arquivo):
if self._le_xml(arquivo):
self.evtTotalContrib.xml = arquivo
self.Signature.xml = self._le_noh('//Reinf/evtTotalContrib/sig:Signature')
self.cdResposta = self.evtTotalContrib.ideRecRetorno.ideStatus.cdRetorno.valor
self.descResposta = self.evtTotalContrib.ideRecRetorno.ideStatus.descRetorno.valor
self.ocorrencias = self.evtTotalContrib.ideRecRetorno.ideStatus.regOcorrs
return True

# def gera_id_evento(self, data_hora):
Expand Down
6 changes: 2 additions & 4 deletions pysped/efdreinf/leiaute/retornoTotalizadorEvento_10302.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,14 @@ def __init__(self):

def get_xml(self):
xml = XMLNFe.get_xml(self)
xml += '<ideRecRetorno>'
xml += '<ideStatus>'
xml += self.cdRetorno.xml
xml += self.descRetorno.xml
if len(self.regOcorrs) >= 1:
xml += '<regOcorrs>'
for o in self.regOcorrs:
xml += o.xml
xml += '</regOcorrs>'

xml += '</ideRecRetorno>'
xml += '</ideStatus>'
return xml

def set_xml(self, arquivo):
Expand Down
1 change: 1 addition & 0 deletions pysped/efdreinf/leiaute/soap_10100.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def get_xml(self):
xml += '<sped:ConsultaInformacoesConsolidadas>'
xml += '<sped:tipoInscricaoContribuinte>%s</sped:tipoInscricaoContribuinte>' % self.tipoInscricaoContribuinte
xml += '<sped:numeroInscricaoContribuinte>%s</sped:numeroInscricaoContribuinte>' % self.numeroInscricaoContribuinte
# xml += '<sped:numeroProtocoloFechamento>%s</sped:numeroProtocoloFechamento>' % self.numeroProtocoloFechamento
xml += '<sped:numeroReciboFechamento>%s</sped:numeroReciboFechamento>' % self.numeroProtocoloFechamento
xml += '</sped:ConsultaInformacoesConsolidadas>'
xml += '</soapenv:Body>'
Expand Down
Loading