예제 #1
0
def read_s1298_evtreabreevper_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1298_evtreabreevper_dados = {}
    s1298_evtreabreevper_dados['status'] = status
    s1298_evtreabreevper_dados['arquivo_original'] = 1
    if arquivo:
        s1298_evtreabreevper_dados['arquivo'] = arquivo.arquivo
    s1298_evtreabreevper_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    s1298_evtreabreevper_dados['identidade'] = doc.eSocial.evtReabreEvPer['Id']
    evtReabreEvPer = doc.eSocial.evtReabreEvPer

    try:
        s1298_evtreabreevper_dados['indapuracao'] = read_from_xml(evtReabreEvPer.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['perapur'] = read_from_xml(evtReabreEvPer.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['tpamb'] = read_from_xml(evtReabreEvPer.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['procemi'] = read_from_xml(evtReabreEvPer.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['verproc'] = read_from_xml(evtReabreEvPer.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['tpinsc'] = read_from_xml(evtReabreEvPer.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1298_evtreabreevper_dados['nrinsc'] = read_from_xml(evtReabreEvPer.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1298_evtreabreevper = s1298evtReabreEvPer.objects.create(**s1298_evtreabreevper_dados)
    s1298_evtreabreevper_dados['evento'] = 's1298'
    s1298_evtreabreevper_dados['id'] = s1298_evtreabreevper.id
    s1298_evtreabreevper_dados['identidade_evento'] = doc.eSocial.evtReabreEvPer['Id']

    from emensageriapro.esocial.views.s1298_evtreabreevper_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1298_evtreabreevper.id)

    return s1298_evtreabreevper_dados
예제 #2
0
def read_r4098_evtreab_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r4098_evtreab_dados = {}
    r4098_evtreab_dados['status'] = status
    r4098_evtreab_dados['arquivo_original'] = 1
    if arquivo:
        r4098_evtreab_dados['arquivo'] = arquivo.arquivo
    r4098_evtreab_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    r4098_evtreab_dados['identidade'] = doc.Reinf.evtReab['id']
    evtReab = doc.Reinf.evtReab

    try:
        r4098_evtreab_dados['perapur'] = read_from_xml(evtReab.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4098_evtreab_dados['tpamb'] = read_from_xml(evtReab.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4098_evtreab_dados['procemi'] = read_from_xml(evtReab.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4098_evtreab_dados['verproc'] = read_from_xml(evtReab.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4098_evtreab_dados['tpinsc'] = read_from_xml(evtReab.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4098_evtreab_dados['nrinsc'] = read_from_xml(evtReab.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    r4098_evtreab = r4098evtReab.objects.create(**r4098_evtreab_dados)
    r4098_evtreab_dados['evento'] = 'r4098'
    r4098_evtreab_dados['id'] = r4098_evtreab.id
    r4098_evtreab_dados['identidade_evento'] = doc.Reinf.evtReab['id']

    from emensageriapro.efdreinf.views.r4098_evtreab_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r4098_evtreab.id)

    return r4098_evtreab_dados
예제 #3
0
def read_s2250_evtavprevio_obj(request,
                               doc,
                               status,
                               validar=False,
                               arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2250_evtavprevio_dados = {}
    s2250_evtavprevio_dados['status'] = status
    s2250_evtavprevio_dados['arquivo_original'] = 1
    if arquivo:
        s2250_evtavprevio_dados['arquivo'] = arquivo.arquivo
    s2250_evtavprevio_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2250_evtavprevio_dados['identidade'] = doc.eSocial.evtAvPrevio['Id']
    evtAvPrevio = doc.eSocial.evtAvPrevio

    try:
        s2250_evtavprevio_dados['indretif'] = read_from_xml(
            evtAvPrevio.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['nrrecibo'] = read_from_xml(
            evtAvPrevio.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['tpamb'] = read_from_xml(
            evtAvPrevio.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['procemi'] = read_from_xml(
            evtAvPrevio.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['verproc'] = read_from_xml(
            evtAvPrevio.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['tpinsc'] = read_from_xml(
            evtAvPrevio.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['nrinsc'] = read_from_xml(
            evtAvPrevio.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['cpftrab'] = read_from_xml(
            evtAvPrevio.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['nistrab'] = read_from_xml(
            evtAvPrevio.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2250_evtavprevio_dados['matricula'] = read_from_xml(
            evtAvPrevio.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s2250_evtavprevio = s2250evtAvPrevio.objects.create(
        **s2250_evtavprevio_dados)

    if 'infoAvPrevio' in dir(evtAvPrevio) and 'detAvPrevio' in dir(
            evtAvPrevio.infoAvPrevio):

        for detAvPrevio in evtAvPrevio.infoAvPrevio.detAvPrevio:

            s2250_detavprevio_dados = {}
            s2250_detavprevio_dados[
                's2250_evtavprevio_id'] = s2250_evtavprevio.id

            try:
                s2250_detavprevio_dados['dtavprv'] = read_from_xml(
                    detAvPrevio.dtAvPrv.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2250_detavprevio_dados['dtprevdeslig'] = read_from_xml(
                    detAvPrevio.dtPrevDeslig.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2250_detavprevio_dados['tpavprevio'] = read_from_xml(
                    detAvPrevio.tpAvPrevio.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2250_detavprevio_dados['observacao'] = read_from_xml(
                    detAvPrevio.observacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2250_detavprevio = s2250detAvPrevio.objects.create(
                **s2250_detavprevio_dados)

    if 'infoAvPrevio' in dir(evtAvPrevio) and 'cancAvPrevio' in dir(
            evtAvPrevio.infoAvPrevio):

        for cancAvPrevio in evtAvPrevio.infoAvPrevio.cancAvPrevio:

            s2250_cancavprevio_dados = {}
            s2250_cancavprevio_dados[
                's2250_evtavprevio_id'] = s2250_evtavprevio.id

            try:
                s2250_cancavprevio_dados['dtcancavprv'] = read_from_xml(
                    cancAvPrevio.dtCancAvPrv.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2250_cancavprevio_dados['observacao'] = read_from_xml(
                    cancAvPrevio.observacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2250_cancavprevio_dados['mtvcancavprevio'] = read_from_xml(
                    cancAvPrevio.mtvCancAvPrevio.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s2250_cancavprevio = s2250cancAvPrevio.objects.create(
                **s2250_cancavprevio_dados)
    s2250_evtavprevio_dados['evento'] = 's2250'
    s2250_evtavprevio_dados['id'] = s2250_evtavprevio.id
    s2250_evtavprevio_dados['identidade_evento'] = doc.eSocial.evtAvPrevio[
        'Id']

    from emensageriapro.esocial.views.s2250_evtavprevio_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2250_evtavprevio.id)

    return s2250_evtavprevio_dados
예제 #4
0
def read_r2020_evtservprest_obj(request,
                                doc,
                                status,
                                validar=False,
                                arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r2020_evtservprest_dados = {}
    r2020_evtservprest_dados['status'] = status
    r2020_evtservprest_dados['arquivo_original'] = 1
    if arquivo:
        r2020_evtservprest_dados['arquivo'] = arquivo.arquivo
    r2020_evtservprest_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r2020_evtservprest_dados['identidade'] = doc.Reinf.evtServPrest['id']
    evtServPrest = doc.Reinf.evtServPrest

    try:
        r2020_evtservprest_dados['indretif'] = read_from_xml(
            evtServPrest.ideEvento.indRetif.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['nrrecibo'] = read_from_xml(
            evtServPrest.ideEvento.nrRecibo.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['perapur'] = read_from_xml(
            evtServPrest.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['tpamb'] = read_from_xml(
            evtServPrest.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['procemi'] = read_from_xml(
            evtServPrest.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['verproc'] = read_from_xml(
            evtServPrest.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['tpinsc'] = read_from_xml(
            evtServPrest.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['nrinsc'] = read_from_xml(
            evtServPrest.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['tpinscestabprest'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.tpInscEstabPrest.cdata,
            'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['nrinscestabprest'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.nrInscEstabPrest.cdata,
            'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['tpinsctomador'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.tpInscTomador.
            cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['nrinsctomador'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.nrInscTomador.
            cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['indobra'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.indObra.cdata,
            'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalbruto'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.vlrTotalBruto.
            cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalbaseret'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.
            vlrTotalBaseRet.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalretprinc'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.
            vlrTotalRetPrinc.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalretadic'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.
            vlrTotalRetAdic.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalnretprinc'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.
            vlrTotalNRetPrinc.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r2020_evtservprest_dados['vlrtotalnretadic'] = read_from_xml(
            evtServPrest.infoServPrest.ideEstabPrest.ideTomador.
            vlrTotalNRetAdic.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    r2020_evtservprest = r2020evtServPrest.objects.create(
        **r2020_evtservprest_dados)

    if 'infoServPrest' in dir(evtServPrest) and 'ideEstabPrest' in dir(
            evtServPrest.infoServPrest) and 'ideTomador' in dir(
                evtServPrest.infoServPrest.ideEstabPrest) and 'nfs' in dir(
                    evtServPrest.infoServPrest.ideEstabPrest.ideTomador):

        for nfs in evtServPrest.infoServPrest.ideEstabPrest.ideTomador.nfs:

            r2020_nfs_dados = {}
            r2020_nfs_dados['r2020_evtservprest_id'] = r2020_evtservprest.id

            try:
                r2020_nfs_dados['serie'] = read_from_xml(
                    nfs.serie.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r2020_nfs_dados['numdocto'] = read_from_xml(
                    nfs.numDocto.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r2020_nfs_dados['dtemissaonf'] = read_from_xml(
                    nfs.dtEmissaoNF.cdata, 'efdreinf', 'D', None)
            except AttributeError:
                pass

            try:
                r2020_nfs_dados['vlrbruto'] = read_from_xml(
                    nfs.vlrBruto.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            try:
                r2020_nfs_dados['obs'] = read_from_xml(nfs.obs.cdata,
                                                       'efdreinf', 'C', None)
            except AttributeError:
                pass

            r2020_nfs = r2020nfs.objects.create(**r2020_nfs_dados)

            if 'infoTpServ' in dir(nfs):

                for infoTpServ in nfs.infoTpServ:

                    r2020_infotpserv_dados = {}
                    r2020_infotpserv_dados['r2020_nfs_id'] = r2020_nfs.id

                    try:
                        r2020_infotpserv_dados['tpservico'] = read_from_xml(
                            infoTpServ.tpServico.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlrbaseret'] = read_from_xml(
                            infoTpServ.vlrBaseRet.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlrretencao'] = read_from_xml(
                            infoTpServ.vlrRetencao.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlrretsub'] = read_from_xml(
                            infoTpServ.vlrRetSub.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlrnretprinc'] = read_from_xml(
                            infoTpServ.vlrNRetPrinc.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados[
                            'vlrservicos15'] = read_from_xml(
                                infoTpServ.vlrServicos15.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados[
                            'vlrservicos20'] = read_from_xml(
                                infoTpServ.vlrServicos20.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados[
                            'vlrservicos25'] = read_from_xml(
                                infoTpServ.vlrServicos25.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlradicional'] = read_from_xml(
                            infoTpServ.vlrAdicional.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2020_infotpserv_dados['vlrnretadic'] = read_from_xml(
                            infoTpServ.vlrNRetAdic.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r2020_infotpserv = r2020infoTpServ.objects.create(
                        **r2020_infotpserv_dados)

    if 'infoServPrest' in dir(evtServPrest) and 'ideEstabPrest' in dir(
            evtServPrest.infoServPrest) and 'ideTomador' in dir(
                evtServPrest.infoServPrest.ideEstabPrest
            ) and 'infoProcRetPr' in dir(
                evtServPrest.infoServPrest.ideEstabPrest.ideTomador):

        for infoProcRetPr in evtServPrest.infoServPrest.ideEstabPrest.ideTomador.infoProcRetPr:

            r2020_infoprocretpr_dados = {}
            r2020_infoprocretpr_dados[
                'r2020_evtservprest_id'] = r2020_evtservprest.id

            try:
                r2020_infoprocretpr_dados['tpprocretprinc'] = read_from_xml(
                    infoProcRetPr.tpProcRetPrinc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretpr_dados['nrprocretprinc'] = read_from_xml(
                    infoProcRetPr.nrProcRetPrinc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretpr_dados['codsuspprinc'] = read_from_xml(
                    infoProcRetPr.codSuspPrinc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretpr_dados['valorprinc'] = read_from_xml(
                    infoProcRetPr.valorPrinc.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r2020_infoprocretpr = r2020infoProcRetPr.objects.create(
                **r2020_infoprocretpr_dados)

    if 'infoServPrest' in dir(evtServPrest) and 'ideEstabPrest' in dir(
            evtServPrest.infoServPrest) and 'ideTomador' in dir(
                evtServPrest.infoServPrest.ideEstabPrest
            ) and 'infoProcRetAd' in dir(
                evtServPrest.infoServPrest.ideEstabPrest.ideTomador):

        for infoProcRetAd in evtServPrest.infoServPrest.ideEstabPrest.ideTomador.infoProcRetAd:

            r2020_infoprocretad_dados = {}
            r2020_infoprocretad_dados[
                'r2020_evtservprest_id'] = r2020_evtservprest.id

            try:
                r2020_infoprocretad_dados['tpprocretadic'] = read_from_xml(
                    infoProcRetAd.tpProcRetAdic.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretad_dados['nrprocretadic'] = read_from_xml(
                    infoProcRetAd.nrProcRetAdic.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretad_dados['codsuspadic'] = read_from_xml(
                    infoProcRetAd.codSuspAdic.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r2020_infoprocretad_dados['valoradic'] = read_from_xml(
                    infoProcRetAd.valorAdic.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r2020_infoprocretad = r2020infoProcRetAd.objects.create(
                **r2020_infoprocretad_dados)
    r2020_evtservprest_dados['evento'] = 'r2020'
    r2020_evtservprest_dados['id'] = r2020_evtservprest.id
    r2020_evtservprest_dados['identidade_evento'] = doc.Reinf.evtServPrest[
        'id']

    from emensageriapro.efdreinf.views.r2020_evtservprest_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r2020_evtservprest.id)

    return r2020_evtservprest_dados
예제 #5
0
def read_s1202_evtrmnrpps_obj(request,
                              doc,
                              status,
                              validar=False,
                              arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1202_evtrmnrpps_dados = {}
    s1202_evtrmnrpps_dados['status'] = status
    s1202_evtrmnrpps_dados['arquivo_original'] = 1
    if arquivo:
        s1202_evtrmnrpps_dados['arquivo'] = arquivo.arquivo
    s1202_evtrmnrpps_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1202_evtrmnrpps_dados['identidade'] = doc.eSocial.evtRmnRPPS['Id']
    evtRmnRPPS = doc.eSocial.evtRmnRPPS

    try:
        s1202_evtrmnrpps_dados['indretif'] = read_from_xml(
            evtRmnRPPS.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['nrrecibo'] = read_from_xml(
            evtRmnRPPS.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['indapuracao'] = read_from_xml(
            evtRmnRPPS.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['perapur'] = read_from_xml(
            evtRmnRPPS.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['tpamb'] = read_from_xml(
            evtRmnRPPS.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['procemi'] = read_from_xml(
            evtRmnRPPS.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['verproc'] = read_from_xml(
            evtRmnRPPS.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['tpinsc'] = read_from_xml(
            evtRmnRPPS.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['nrinsc'] = read_from_xml(
            evtRmnRPPS.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['cpftrab'] = read_from_xml(
            evtRmnRPPS.ideTrabalhador.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['nistrab'] = read_from_xml(
            evtRmnRPPS.ideTrabalhador.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1202_evtrmnrpps_dados['qtddepfp'] = read_from_xml(
            evtRmnRPPS.ideTrabalhador.qtdDepFP.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    s1202_evtrmnrpps = s1202evtRmnRPPS.objects.create(**s1202_evtrmnrpps_dados)

    if 'ideTrabalhador' in dir(evtRmnRPPS) and 'procJudTrab' in dir(
            evtRmnRPPS.ideTrabalhador):

        for procJudTrab in evtRmnRPPS.ideTrabalhador.procJudTrab:

            s1202_procjudtrab_dados = {}
            s1202_procjudtrab_dados[
                's1202_evtrmnrpps_id'] = s1202_evtrmnrpps.id

            try:
                s1202_procjudtrab_dados['tptrib'] = read_from_xml(
                    procJudTrab.tpTrib.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1202_procjudtrab_dados['nrprocjud'] = read_from_xml(
                    procJudTrab.nrProcJud.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1202_procjudtrab_dados['codsusp'] = read_from_xml(
                    procJudTrab.codSusp.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s1202_procjudtrab = s1202procJudTrab.objects.create(
                **s1202_procjudtrab_dados)

    if 'dmDev' in dir(evtRmnRPPS):

        for dmDev in evtRmnRPPS.dmDev:

            s1202_dmdev_dados = {}
            s1202_dmdev_dados['s1202_evtrmnrpps_id'] = s1202_evtrmnrpps.id

            try:
                s1202_dmdev_dados['idedmdev'] = read_from_xml(
                    dmDev.ideDmDev.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1202_dmdev_dados['codcateg'] = read_from_xml(
                    dmDev.codCateg.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s1202_dmdev = s1202dmDev.objects.create(**s1202_dmdev_dados)

            if 'infoPerApur' in dir(dmDev):

                for infoPerApur in dmDev.infoPerApur:

                    s1202_infoperapur_dados = {}
                    s1202_infoperapur_dados['s1202_dmdev_id'] = s1202_dmdev.id

                    s1202_infoperapur = s1202infoPerApur.objects.create(
                        **s1202_infoperapur_dados)

                    if 'ideEstab' in dir(infoPerApur):

                        for ideEstab in infoPerApur.ideEstab:

                            s1202_infoperapur_ideestab_dados = {}
                            s1202_infoperapur_ideestab_dados[
                                's1202_infoperapur_id'] = s1202_infoperapur.id

                            try:
                                s1202_infoperapur_ideestab_dados[
                                    'tpinsc'] = read_from_xml(
                                        ideEstab.tpInsc.cdata, 'esocial', 'N',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperapur_ideestab_dados[
                                    'nrinsc'] = read_from_xml(
                                        ideEstab.nrInsc.cdata, 'esocial', 'C',
                                        None)
                            except AttributeError:
                                pass

                            s1202_infoperapur_ideestab = s1202infoPerApurideEstab.objects.create(
                                **s1202_infoperapur_ideestab_dados)

                            if 'remunPerApur' in dir(ideEstab):

                                for remunPerApur in ideEstab.remunPerApur:

                                    s1202_infoperapur_remunperapur_dados = {}
                                    s1202_infoperapur_remunperapur_dados[
                                        's1202_infoperapur_ideestab_id'] = s1202_infoperapur_ideestab.id

                                    try:
                                        s1202_infoperapur_remunperapur_dados[
                                            'matricula'] = read_from_xml(
                                                remunPerApur.matricula.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s1202_infoperapur_remunperapur_dados[
                                            'codcateg'] = read_from_xml(
                                                remunPerApur.codCateg.cdata,
                                                'esocial', 'N', None)
                                    except AttributeError:
                                        pass

                                    s1202_infoperapur_remunperapur = s1202infoPerApurremunPerApur.objects.create(
                                        **s1202_infoperapur_remunperapur_dados)

                                    if 'itensRemun' in dir(remunPerApur):

                                        for itensRemun in remunPerApur.itensRemun:

                                            s1202_infoperapur_itensremun_dados = {}
                                            s1202_infoperapur_itensremun_dados[
                                                's1202_infoperapur_remunperapur_id'] = s1202_infoperapur_remunperapur.id

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'codrubr'] = read_from_xml(
                                                        itensRemun.codRubr.
                                                        cdata, 'esocial', 'C',
                                                        None)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'idetabrubr'] = read_from_xml(
                                                        itensRemun.ideTabRubr.
                                                        cdata, 'esocial', 'C',
                                                        None)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'qtdrubr'] = read_from_xml(
                                                        itensRemun.qtdRubr.
                                                        cdata, 'esocial', 'N',
                                                        2)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'fatorrubr'] = read_from_xml(
                                                        itensRemun.fatorRubr.
                                                        cdata, 'esocial', 'N',
                                                        2)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'vrunit'] = read_from_xml(
                                                        itensRemun.vrUnit.
                                                        cdata, 'esocial', 'N',
                                                        2)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperapur_itensremun_dados[
                                                    'vrrubr'] = read_from_xml(
                                                        itensRemun.vrRubr.
                                                        cdata, 'esocial', 'N',
                                                        2)
                                            except AttributeError:
                                                pass

                                            s1202_infoperapur_itensremun = s1202infoPerApuritensRemun.objects.create(
                                                **
                                                s1202_infoperapur_itensremun_dados
                                            )

                                    if 'infoSaudeColet' in dir(remunPerApur):

                                        for infoSaudeColet in remunPerApur.infoSaudeColet:

                                            s1202_infoperapur_infosaudecolet_dados = {}
                                            s1202_infoperapur_infosaudecolet_dados[
                                                's1202_infoperapur_remunperapur_id'] = s1202_infoperapur_remunperapur.id

                                            s1202_infoperapur_infosaudecolet = s1202infoPerApurinfoSaudeColet.objects.create(
                                                **
                                                s1202_infoperapur_infosaudecolet_dados
                                            )

                                            if 'detOper' in dir(
                                                    infoSaudeColet):

                                                for detOper in infoSaudeColet.detOper:

                                                    s1202_infoperapur_detoper_dados = {}
                                                    s1202_infoperapur_detoper_dados[
                                                        's1202_infoperapur_infosaudecolet_id'] = s1202_infoperapur_infosaudecolet.id

                                                    try:
                                                        s1202_infoperapur_detoper_dados[
                                                            'cnpjoper'] = read_from_xml(
                                                                detOper.
                                                                cnpjOper.cdata,
                                                                'esocial', 'C',
                                                                None)
                                                    except AttributeError:
                                                        pass

                                                    try:
                                                        s1202_infoperapur_detoper_dados[
                                                            'regans'] = read_from_xml(
                                                                detOper.regANS.
                                                                cdata,
                                                                'esocial', 'C',
                                                                None)
                                                    except AttributeError:
                                                        pass

                                                    try:
                                                        s1202_infoperapur_detoper_dados[
                                                            'vrpgtit'] = read_from_xml(
                                                                detOper.
                                                                vrPgTit.cdata,
                                                                'esocial', 'N',
                                                                2)
                                                    except AttributeError:
                                                        pass

                                                    s1202_infoperapur_detoper = s1202infoPerApurdetOper.objects.create(
                                                        **
                                                        s1202_infoperapur_detoper_dados
                                                    )

                                                    if 'detPlano' in dir(
                                                            detOper):

                                                        for detPlano in detOper.detPlano:

                                                            s1202_infoperapur_detplano_dados = {}
                                                            s1202_infoperapur_detplano_dados[
                                                                's1202_infoperapur_detoper_id'] = s1202_infoperapur_detoper.id

                                                            try:
                                                                s1202_infoperapur_detplano_dados[
                                                                    'tpdep'] = read_from_xml(
                                                                        detPlano
                                                                        .tpDep.
                                                                        cdata,
                                                                        'esocial',
                                                                        'C',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperapur_detplano_dados[
                                                                    'cpfdep'] = read_from_xml(
                                                                        detPlano
                                                                        .cpfDep
                                                                        .cdata,
                                                                        'esocial',
                                                                        'C',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperapur_detplano_dados[
                                                                    'nmdep'] = read_from_xml(
                                                                        detPlano
                                                                        .nmDep.
                                                                        cdata,
                                                                        'esocial',
                                                                        'C',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperapur_detplano_dados[
                                                                    'dtnascto'] = read_from_xml(
                                                                        detPlano
                                                                        .
                                                                        dtNascto
                                                                        .cdata,
                                                                        'esocial',
                                                                        'D',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperapur_detplano_dados[
                                                                    'vlrpgdep'] = read_from_xml(
                                                                        detPlano
                                                                        .
                                                                        vlrPgDep
                                                                        .cdata,
                                                                        'esocial',
                                                                        'N', 2)
                                                            except AttributeError:
                                                                pass

                                                            s1202_infoperapur_detplano = s1202infoPerApurdetPlano.objects.create(
                                                                **
                                                                s1202_infoperapur_detplano_dados
                                                            )

            if 'infoPerAnt' in dir(dmDev):

                for infoPerAnt in dmDev.infoPerAnt:

                    s1202_infoperant_dados = {}
                    s1202_infoperant_dados['s1202_dmdev_id'] = s1202_dmdev.id

                    s1202_infoperant = s1202infoPerAnt.objects.create(
                        **s1202_infoperant_dados)

                    if 'ideADC' in dir(infoPerAnt):

                        for ideADC in infoPerAnt.ideADC:

                            s1202_infoperant_ideadc_dados = {}
                            s1202_infoperant_ideadc_dados[
                                's1202_infoperant_id'] = s1202_infoperant.id

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'dtlei'] = read_from_xml(
                                        ideADC.dtLei.cdata, 'esocial', 'D',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'nrlei'] = read_from_xml(
                                        ideADC.nrLei.cdata, 'esocial', 'C',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'dtef'] = read_from_xml(
                                        ideADC.dtEf.cdata, 'esocial', 'D',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'dtacconv'] = read_from_xml(
                                        ideADC.dtAcConv.cdata, 'esocial', 'D',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'tpacconv'] = read_from_xml(
                                        ideADC.tpAcConv.cdata, 'esocial', 'C',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'compacconv'] = read_from_xml(
                                        ideADC.compAcConv.cdata, 'esocial',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'dtefacconv'] = read_from_xml(
                                        ideADC.dtEfAcConv.cdata, 'esocial',
                                        'D', None)
                            except AttributeError:
                                pass

                            try:
                                s1202_infoperant_ideadc_dados[
                                    'dsc'] = read_from_xml(
                                        ideADC.dsc.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s1202_infoperant_ideadc = s1202infoPerAntideADC.objects.create(
                                **s1202_infoperant_ideadc_dados)

                            if 'idePeriodo' in dir(ideADC):

                                for idePeriodo in ideADC.idePeriodo:

                                    s1202_infoperant_ideperiodo_dados = {}
                                    s1202_infoperant_ideperiodo_dados[
                                        's1202_infoperant_ideadc_id'] = s1202_infoperant_ideadc.id

                                    try:
                                        s1202_infoperant_ideperiodo_dados[
                                            'perref'] = read_from_xml(
                                                idePeriodo.perRef.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    s1202_infoperant_ideperiodo = s1202infoPerAntidePeriodo.objects.create(
                                        **s1202_infoperant_ideperiodo_dados)

                                    if 'ideEstab' in dir(idePeriodo):

                                        for ideEstab in idePeriodo.ideEstab:

                                            s1202_infoperant_ideestab_dados = {}
                                            s1202_infoperant_ideestab_dados[
                                                's1202_infoperant_ideperiodo_id'] = s1202_infoperant_ideperiodo.id

                                            try:
                                                s1202_infoperant_ideestab_dados[
                                                    'tpinsc'] = read_from_xml(
                                                        ideEstab.tpInsc.cdata,
                                                        'esocial', 'N', None)
                                            except AttributeError:
                                                pass

                                            try:
                                                s1202_infoperant_ideestab_dados[
                                                    'nrinsc'] = read_from_xml(
                                                        ideEstab.nrInsc.cdata,
                                                        'esocial', 'C', None)
                                            except AttributeError:
                                                pass

                                            s1202_infoperant_ideestab = s1202infoPerAntideEstab.objects.create(
                                                **
                                                s1202_infoperant_ideestab_dados
                                            )

                                            if 'remunPerAnt' in dir(ideEstab):

                                                for remunPerAnt in ideEstab.remunPerAnt:

                                                    s1202_infoperant_remunperant_dados = {}
                                                    s1202_infoperant_remunperant_dados[
                                                        's1202_infoperant_ideestab_id'] = s1202_infoperant_ideestab.id

                                                    try:
                                                        s1202_infoperant_remunperant_dados[
                                                            'matricula'] = read_from_xml(
                                                                remunPerAnt.
                                                                matricula.
                                                                cdata,
                                                                'esocial', 'C',
                                                                None)
                                                    except AttributeError:
                                                        pass

                                                    try:
                                                        s1202_infoperant_remunperant_dados[
                                                            'codcateg'] = read_from_xml(
                                                                remunPerAnt.
                                                                codCateg.cdata,
                                                                'esocial', 'N',
                                                                None)
                                                    except AttributeError:
                                                        pass

                                                    s1202_infoperant_remunperant = s1202infoPerAntremunPerAnt.objects.create(
                                                        **
                                                        s1202_infoperant_remunperant_dados
                                                    )

                                                    if 'itensRemun' in dir(
                                                            remunPerAnt):

                                                        for itensRemun in remunPerAnt.itensRemun:

                                                            s1202_infoperant_itensremun_dados = {}
                                                            s1202_infoperant_itensremun_dados[
                                                                's1202_infoperant_remunperant_id'] = s1202_infoperant_remunperant.id

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'codrubr'] = read_from_xml(
                                                                        itensRemun
                                                                        .
                                                                        codRubr
                                                                        .cdata,
                                                                        'esocial',
                                                                        'C',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'idetabrubr'] = read_from_xml(
                                                                        itensRemun
                                                                        .
                                                                        ideTabRubr
                                                                        .cdata,
                                                                        'esocial',
                                                                        'C',
                                                                        None)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'qtdrubr'] = read_from_xml(
                                                                        itensRemun
                                                                        .
                                                                        qtdRubr
                                                                        .cdata,
                                                                        'esocial',
                                                                        'N', 2)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'fatorrubr'] = read_from_xml(
                                                                        itensRemun
                                                                        .
                                                                        fatorRubr
                                                                        .cdata,
                                                                        'esocial',
                                                                        'N', 2)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'vrunit'] = read_from_xml(
                                                                        itensRemun
                                                                        .vrUnit
                                                                        .cdata,
                                                                        'esocial',
                                                                        'N', 2)
                                                            except AttributeError:
                                                                pass

                                                            try:
                                                                s1202_infoperant_itensremun_dados[
                                                                    'vrrubr'] = read_from_xml(
                                                                        itensRemun
                                                                        .vrRubr
                                                                        .cdata,
                                                                        'esocial',
                                                                        'N', 2)
                                                            except AttributeError:
                                                                pass

                                                            s1202_infoperant_itensremun = s1202infoPerAntitensRemun.objects.create(
                                                                **
                                                                s1202_infoperant_itensremun_dados
                                                            )
    s1202_evtrmnrpps_dados['evento'] = 's1202'
    s1202_evtrmnrpps_dados['id'] = s1202_evtrmnrpps.id
    s1202_evtrmnrpps_dados['identidade_evento'] = doc.eSocial.evtRmnRPPS['Id']

    from emensageriapro.esocial.views.s1202_evtrmnrpps_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1202_evtrmnrpps.id)

    return s1202_evtrmnrpps_dados
예제 #6
0
def read_s1040_evttabfuncao_obj(request,
                                doc,
                                status,
                                validar=False,
                                arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1040_evttabfuncao_dados = {}
    s1040_evttabfuncao_dados['status'] = status
    s1040_evttabfuncao_dados['arquivo_original'] = 1
    if arquivo:
        s1040_evttabfuncao_dados['arquivo'] = arquivo.arquivo
    s1040_evttabfuncao_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1040_evttabfuncao_dados['identidade'] = doc.eSocial.evtTabFuncao['Id']
    evtTabFuncao = doc.eSocial.evtTabFuncao

    if 'inclusao' in dir(evtTabFuncao.infoFuncao):
        s1040_evttabfuncao_dados['operacao'] = 1
    elif 'alteracao' in dir(evtTabFuncao.infoFuncao):
        s1040_evttabfuncao_dados['operacao'] = 2
    elif 'exclusao' in dir(evtTabFuncao.infoFuncao):
        s1040_evttabfuncao_dados['operacao'] = 3

    try:
        s1040_evttabfuncao_dados['tpamb'] = read_from_xml(
            evtTabFuncao.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1040_evttabfuncao_dados['procemi'] = read_from_xml(
            evtTabFuncao.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1040_evttabfuncao_dados['verproc'] = read_from_xml(
            evtTabFuncao.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1040_evttabfuncao_dados['tpinsc'] = read_from_xml(
            evtTabFuncao.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1040_evttabfuncao_dados['nrinsc'] = read_from_xml(
            evtTabFuncao.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1040_evttabfuncao = s1040evtTabFuncao.objects.create(
        **s1040_evttabfuncao_dados)

    if 'infoFuncao' in dir(evtTabFuncao) and 'inclusao' in dir(
            evtTabFuncao.infoFuncao):

        for inclusao in evtTabFuncao.infoFuncao.inclusao:

            s1040_inclusao_dados = {}
            s1040_inclusao_dados[
                's1040_evttabfuncao_id'] = s1040_evttabfuncao.id

            try:
                s1040_inclusao_dados['codfuncao'] = read_from_xml(
                    inclusao.ideFuncao.codFuncao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_inclusao_dados['inivalid'] = read_from_xml(
                    inclusao.ideFuncao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_inclusao_dados['fimvalid'] = read_from_xml(
                    inclusao.ideFuncao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_inclusao_dados['dscfuncao'] = read_from_xml(
                    inclusao.dadosFuncao.dscFuncao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_inclusao_dados['codcbo'] = read_from_xml(
                    inclusao.dadosFuncao.codCBO.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1040_inclusao = s1040inclusao.objects.create(
                **s1040_inclusao_dados)

    if 'infoFuncao' in dir(evtTabFuncao) and 'alteracao' in dir(
            evtTabFuncao.infoFuncao):

        for alteracao in evtTabFuncao.infoFuncao.alteracao:

            s1040_alteracao_dados = {}
            s1040_alteracao_dados[
                's1040_evttabfuncao_id'] = s1040_evttabfuncao.id

            try:
                s1040_alteracao_dados['codfuncao'] = read_from_xml(
                    alteracao.ideFuncao.codFuncao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_alteracao_dados['inivalid'] = read_from_xml(
                    alteracao.ideFuncao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_alteracao_dados['fimvalid'] = read_from_xml(
                    alteracao.ideFuncao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_alteracao_dados['dscfuncao'] = read_from_xml(
                    alteracao.dadosFuncao.dscFuncao.cdata, 'esocial', 'C',
                    None)
            except AttributeError:
                pass

            try:
                s1040_alteracao_dados['codcbo'] = read_from_xml(
                    alteracao.dadosFuncao.codCBO.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1040_alteracao = s1040alteracao.objects.create(
                **s1040_alteracao_dados)

            if 'novaValidade' in dir(alteracao):

                for novaValidade in alteracao.novaValidade:

                    s1040_alteracao_novavalidade_dados = {}
                    s1040_alteracao_novavalidade_dados[
                        's1040_alteracao_id'] = s1040_alteracao.id

                    try:
                        s1040_alteracao_novavalidade_dados[
                            'inivalid'] = read_from_xml(
                                novaValidade.iniValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1040_alteracao_novavalidade_dados[
                            'fimvalid'] = read_from_xml(
                                novaValidade.fimValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    s1040_alteracao_novavalidade = s1040alteracaonovaValidade.objects.create(
                        **s1040_alteracao_novavalidade_dados)

    if 'infoFuncao' in dir(evtTabFuncao) and 'exclusao' in dir(
            evtTabFuncao.infoFuncao):

        for exclusao in evtTabFuncao.infoFuncao.exclusao:

            s1040_exclusao_dados = {}
            s1040_exclusao_dados[
                's1040_evttabfuncao_id'] = s1040_evttabfuncao.id

            try:
                s1040_exclusao_dados['codfuncao'] = read_from_xml(
                    exclusao.ideFuncao.codFuncao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_exclusao_dados['inivalid'] = read_from_xml(
                    exclusao.ideFuncao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1040_exclusao_dados['fimvalid'] = read_from_xml(
                    exclusao.ideFuncao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1040_exclusao = s1040exclusao.objects.create(
                **s1040_exclusao_dados)
    s1040_evttabfuncao_dados['evento'] = 's1040'
    s1040_evttabfuncao_dados['id'] = s1040_evttabfuncao.id
    s1040_evttabfuncao_dados['identidade_evento'] = doc.eSocial.evtTabFuncao[
        'Id']

    from emensageriapro.esocial.views.s1040_evttabfuncao_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1040_evttabfuncao.id)

    return s1040_evttabfuncao_dados
예제 #7
0
def read_s5002_evtirrfbenef_obj(request,
                                doc,
                                status,
                                validar=False,
                                arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s5002_evtirrfbenef_dados = {}
    s5002_evtirrfbenef_dados['status'] = status
    s5002_evtirrfbenef_dados['arquivo_original'] = 1
    if arquivo:
        s5002_evtirrfbenef_dados['arquivo'] = arquivo.arquivo
    s5002_evtirrfbenef_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s5002_evtirrfbenef_dados['identidade'] = doc.eSocial.evtIrrfBenef['Id']
    evtIrrfBenef = doc.eSocial.evtIrrfBenef

    try:
        s5002_evtirrfbenef_dados['nrrecarqbase'] = read_from_xml(
            evtIrrfBenef.ideEvento.nrRecArqBase.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5002_evtirrfbenef_dados['perapur'] = read_from_xml(
            evtIrrfBenef.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5002_evtirrfbenef_dados['tpinsc'] = read_from_xml(
            evtIrrfBenef.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5002_evtirrfbenef_dados['nrinsc'] = read_from_xml(
            evtIrrfBenef.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5002_evtirrfbenef_dados['cpftrab'] = read_from_xml(
            evtIrrfBenef.ideTrabalhador.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s5002_evtirrfbenef = s5002evtIrrfBenef.objects.create(
        **s5002_evtirrfbenef_dados)

    if 'infoDep' in dir(evtIrrfBenef):

        for infoDep in evtIrrfBenef.infoDep:

            s5002_infodep_dados = {}
            s5002_infodep_dados[
                's5002_evtirrfbenef_id'] = s5002_evtirrfbenef.id

            try:
                s5002_infodep_dados['vrdeddep'] = read_from_xml(
                    infoDep.vrDedDep.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s5002_infodep = s5002infoDep.objects.create(**s5002_infodep_dados)

    if 'infoIrrf' in dir(evtIrrfBenef):

        for infoIrrf in evtIrrfBenef.infoIrrf:

            s5002_infoirrf_dados = {}
            s5002_infoirrf_dados[
                's5002_evtirrfbenef_id'] = s5002_evtirrfbenef.id

            try:
                s5002_infoirrf_dados['codcateg'] = read_from_xml(
                    infoIrrf.codCateg.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s5002_infoirrf_dados['indresbr'] = read_from_xml(
                    infoIrrf.indResBr.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s5002_infoirrf = s5002infoIrrf.objects.create(
                **s5002_infoirrf_dados)

            if 'basesIrrf' in dir(infoIrrf):

                for basesIrrf in infoIrrf.basesIrrf:

                    s5002_basesirrf_dados = {}
                    s5002_basesirrf_dados[
                        's5002_infoirrf_id'] = s5002_infoirrf.id

                    try:
                        s5002_basesirrf_dados['tpvalor'] = read_from_xml(
                            basesIrrf.tpValor.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5002_basesirrf_dados['valor'] = read_from_xml(
                            basesIrrf.valor.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5002_basesirrf = s5002basesIrrf.objects.create(
                        **s5002_basesirrf_dados)

            if 'irrf' in dir(infoIrrf):

                for irrf in infoIrrf.irrf:

                    s5002_irrf_dados = {}
                    s5002_irrf_dados['s5002_infoirrf_id'] = s5002_infoirrf.id

                    try:
                        s5002_irrf_dados['tpcr'] = read_from_xml(
                            irrf.tpCR.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s5002_irrf_dados['vrirrfdesc'] = read_from_xml(
                            irrf.vrIrrfDesc.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5002_irrf = s5002irrf.objects.create(**s5002_irrf_dados)

            if 'idePgtoExt' in dir(infoIrrf):

                for idePgtoExt in infoIrrf.idePgtoExt:

                    s5002_idepgtoext_dados = {}
                    s5002_idepgtoext_dados[
                        's5002_infoirrf_id'] = s5002_infoirrf.id

                    try:
                        s5002_idepgtoext_dados['codpais'] = read_from_xml(
                            idePgtoExt.idePais.codPais.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['indnif'] = read_from_xml(
                            idePgtoExt.idePais.indNIF.cdata, 'esocial', 'N',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['nifbenef'] = read_from_xml(
                            idePgtoExt.idePais.nifBenef.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['dsclograd'] = read_from_xml(
                            idePgtoExt.endExt.dscLograd.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['nrlograd'] = read_from_xml(
                            idePgtoExt.endExt.nrLograd.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['complem'] = read_from_xml(
                            idePgtoExt.endExt.complem.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['bairro'] = read_from_xml(
                            idePgtoExt.endExt.bairro.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['nmcid'] = read_from_xml(
                            idePgtoExt.endExt.nmCid.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        s5002_idepgtoext_dados['codpostal'] = read_from_xml(
                            idePgtoExt.endExt.codPostal.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    s5002_idepgtoext = s5002idePgtoExt.objects.create(
                        **s5002_idepgtoext_dados)
    s5002_evtirrfbenef_dados['evento'] = 's5002'
    s5002_evtirrfbenef_dados['id'] = s5002_evtirrfbenef.id
    s5002_evtirrfbenef_dados['identidade_evento'] = doc.eSocial.evtIrrfBenef[
        'Id']

    from emensageriapro.esocial.views.s5002_evtirrfbenef_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s5002_evtirrfbenef.id)

    return s5002_evtirrfbenef_dados
예제 #8
0
def read_r3010_evtespdesportivo_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r3010_evtespdesportivo_dados = {}
    r3010_evtespdesportivo_dados['status'] = status
    r3010_evtespdesportivo_dados['arquivo_original'] = 1
    if arquivo:
        r3010_evtespdesportivo_dados['arquivo'] = arquivo.arquivo
    r3010_evtespdesportivo_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    r3010_evtespdesportivo_dados['identidade'] = doc.Reinf.evtEspDesportivo['id']
    evtEspDesportivo = doc.Reinf.evtEspDesportivo

    try:
        r3010_evtespdesportivo_dados['indretif'] = read_from_xml(evtEspDesportivo.ideEvento.indRetif.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['nrrecibo'] = read_from_xml(evtEspDesportivo.ideEvento.nrRecibo.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['dtapuracao'] = read_from_xml(evtEspDesportivo.ideEvento.dtApuracao.cdata, 'efdreinf', 'D', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['tpamb'] = read_from_xml(evtEspDesportivo.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['procemi'] = read_from_xml(evtEspDesportivo.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['verproc'] = read_from_xml(evtEspDesportivo.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['tpinsc'] = read_from_xml(evtEspDesportivo.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['nrinsc'] = read_from_xml(evtEspDesportivo.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['tpinscestab'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.tpInscEstab.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['nrinscestab'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.nrInscEstab.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['vlrreceitatotal'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.receitaTotal.vlrReceitaTotal.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['vlrcp'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.receitaTotal.vlrCP.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['vlrcpsusptotal'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.receitaTotal.vlrCPSuspTotal.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['vlrreceitaclubes'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.receitaTotal.vlrReceitaClubes.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    try:
        r3010_evtespdesportivo_dados['vlrretparc'] = read_from_xml(evtEspDesportivo.ideContri.ideEstab.receitaTotal.vlrRetParc.cdata, 'efdreinf', 'N', 2)
    except AttributeError:
        pass

    r3010_evtespdesportivo = r3010evtEspDesportivo.objects.create(**r3010_evtespdesportivo_dados)

    if 'ideContri' in dir(evtEspDesportivo) and 'ideEstab' in dir(evtEspDesportivo.ideContri) and 'boletim' in dir(evtEspDesportivo.ideContri.ideEstab):

        for boletim in evtEspDesportivo.ideContri.ideEstab.boletim:

            r3010_boletim_dados = {}
            r3010_boletim_dados['r3010_evtespdesportivo_id'] = r3010_evtespdesportivo.id

            try:
                r3010_boletim_dados['nrboletim'] = read_from_xml(boletim.nrBoletim.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['tpcompeticao'] = read_from_xml(boletim.tpCompeticao.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['categevento'] = read_from_xml(boletim.categEvento.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['moddesportiva'] = read_from_xml(boletim.modDesportiva.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['nomecompeticao'] = read_from_xml(boletim.nomeCompeticao.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['cnpjmandante'] = read_from_xml(boletim.cnpjMandante.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['cnpjvisitante'] = read_from_xml(boletim.cnpjVisitante.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['nomevisitante'] = read_from_xml(boletim.nomeVisitante.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['pracadesportiva'] = read_from_xml(boletim.pracaDesportiva.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['codmunic'] = read_from_xml(boletim.codMunic.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['uf'] = read_from_xml(boletim.uf.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['qtdepagantes'] = read_from_xml(boletim.qtdePagantes.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_boletim_dados['qtdenaopagantes'] = read_from_xml(boletim.qtdeNaoPagantes.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            r3010_boletim = r3010boletim.objects.create(**r3010_boletim_dados)

            if 'receitaIngressos' in dir(boletim):

                for receitaIngressos in boletim.receitaIngressos:

                    r3010_receitaingressos_dados = {}
                    r3010_receitaingressos_dados['r3010_boletim_id'] = r3010_boletim.id

                    try:
                        r3010_receitaingressos_dados['tpingresso'] = read_from_xml(receitaIngressos.tpIngresso.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['descingr'] = read_from_xml(receitaIngressos.descIngr.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['qtdeingrvenda'] = read_from_xml(receitaIngressos.qtdeIngrVenda.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['qtdeingrvendidos'] = read_from_xml(receitaIngressos.qtdeIngrVendidos.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['qtdeingrdev'] = read_from_xml(receitaIngressos.qtdeIngrDev.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['precoindiv'] = read_from_xml(receitaIngressos.precoIndiv.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r3010_receitaingressos_dados['vlrtotal'] = read_from_xml(receitaIngressos.vlrTotal.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r3010_receitaingressos = r3010receitaIngressos.objects.create(**r3010_receitaingressos_dados)

            if 'outrasReceitas' in dir(boletim):

                for outrasReceitas in boletim.outrasReceitas:

                    r3010_outrasreceitas_dados = {}
                    r3010_outrasreceitas_dados['r3010_boletim_id'] = r3010_boletim.id

                    try:
                        r3010_outrasreceitas_dados['tpreceita'] = read_from_xml(outrasReceitas.tpReceita.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r3010_outrasreceitas_dados['vlrreceita'] = read_from_xml(outrasReceitas.vlrReceita.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r3010_outrasreceitas_dados['descreceita'] = read_from_xml(outrasReceitas.descReceita.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    r3010_outrasreceitas = r3010outrasReceitas.objects.create(**r3010_outrasreceitas_dados)

    if 'ideContri' in dir(evtEspDesportivo) and 'ideEstab' in dir(evtEspDesportivo.ideContri) and 'receitaTotal' in dir(evtEspDesportivo.ideContri.ideEstab) and 'infoProc' in dir(evtEspDesportivo.ideContri.ideEstab.receitaTotal):

        for infoProc in evtEspDesportivo.ideContri.ideEstab.receitaTotal.infoProc:

            r3010_infoproc_dados = {}
            r3010_infoproc_dados['r3010_evtespdesportivo_id'] = r3010_evtespdesportivo.id

            try:
                r3010_infoproc_dados['tpproc'] = read_from_xml(infoProc.tpProc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_infoproc_dados['nrproc'] = read_from_xml(infoProc.nrProc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r3010_infoproc_dados['codsusp'] = read_from_xml(infoProc.codSusp.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r3010_infoproc_dados['vlrcpsusp'] = read_from_xml(infoProc.vlrCPSusp.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r3010_infoproc = r3010infoProc.objects.create(**r3010_infoproc_dados)
    r3010_evtespdesportivo_dados['evento'] = 'r3010'
    r3010_evtespdesportivo_dados['id'] = r3010_evtespdesportivo.id
    r3010_evtespdesportivo_dados['identidade_evento'] = doc.Reinf.evtEspDesportivo['id']

    from emensageriapro.efdreinf.views.r3010_evtespdesportivo_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r3010_evtespdesportivo.id)

    return r3010_evtespdesportivo_dados
예제 #9
0
def read_s5011_evtcs_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s5011_evtcs_dados = {}
    s5011_evtcs_dados['status'] = status
    s5011_evtcs_dados['arquivo_original'] = 1
    if arquivo:
        s5011_evtcs_dados['arquivo'] = arquivo.arquivo
    s5011_evtcs_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s5011_evtcs_dados['identidade'] = doc.eSocial.evtCS['Id']
    evtCS = doc.eSocial.evtCS

    try:
        s5011_evtcs_dados['indapuracao'] = read_from_xml(
            evtCS.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['perapur'] = read_from_xml(
            evtCS.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['tpinsc'] = read_from_xml(
            evtCS.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['nrinsc'] = read_from_xml(
            evtCS.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['nrrecarqbase'] = read_from_xml(
            evtCS.infoCS.nrRecArqBase.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['indexistinfo'] = read_from_xml(
            evtCS.infoCS.indExistInfo.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5011_evtcs_dados['classtrib'] = read_from_xml(
            evtCS.infoCS.infoContrib.classTrib.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s5011_evtcs = s5011evtCS.objects.create(**s5011_evtcs_dados)

    if 'infoCS' in dir(evtCS) and 'infoCPSeg' in dir(evtCS.infoCS):

        for infoCPSeg in evtCS.infoCS.infoCPSeg:

            s5011_infocpseg_dados = {}
            s5011_infocpseg_dados['s5011_evtcs_id'] = s5011_evtcs.id

            try:
                s5011_infocpseg_dados['vrdesccp'] = read_from_xml(
                    infoCPSeg.vrDescCP.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            try:
                s5011_infocpseg_dados['vrcpseg'] = read_from_xml(
                    infoCPSeg.vrCpSeg.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s5011_infocpseg = s5011infoCPSeg.objects.create(
                **s5011_infocpseg_dados)

    if 'infoCS' in dir(evtCS) and 'infoContrib' in dir(
            evtCS.infoCS) and 'infoPJ' in dir(evtCS.infoCS.infoContrib):

        for infoPJ in evtCS.infoCS.infoContrib.infoPJ:

            s5011_infopj_dados = {}
            s5011_infopj_dados['s5011_evtcs_id'] = s5011_evtcs.id

            try:
                s5011_infopj_dados['indcoop'] = read_from_xml(
                    infoPJ.indCoop.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s5011_infopj_dados['indconstr'] = read_from_xml(
                    infoPJ.indConstr.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s5011_infopj_dados['indsubstpatr'] = read_from_xml(
                    infoPJ.indSubstPatr.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s5011_infopj_dados['percredcontrib'] = read_from_xml(
                    infoPJ.percRedContrib.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s5011_infopj = s5011infoPJ.objects.create(**s5011_infopj_dados)

            if 'infoAtConc' in dir(infoPJ):

                for infoAtConc in infoPJ.infoAtConc:

                    s5011_infoatconc_dados = {}
                    s5011_infoatconc_dados['s5011_infopj_id'] = s5011_infopj.id

                    try:
                        s5011_infoatconc_dados['fatormes'] = read_from_xml(
                            infoAtConc.fatorMes.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_infoatconc_dados['fator13'] = read_from_xml(
                            infoAtConc.fator13.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5011_infoatconc = s5011infoAtConc.objects.create(
                        **s5011_infoatconc_dados)

    if 'infoCS' in dir(evtCS) and 'ideEstab' in dir(evtCS.infoCS):

        for ideEstab in evtCS.infoCS.ideEstab:

            s5011_ideestab_dados = {}
            s5011_ideestab_dados['s5011_evtcs_id'] = s5011_evtcs.id

            try:
                s5011_ideestab_dados['tpinsc'] = read_from_xml(
                    ideEstab.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s5011_ideestab_dados['nrinsc'] = read_from_xml(
                    ideEstab.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s5011_ideestab = s5011ideEstab.objects.create(
                **s5011_ideestab_dados)

            if 'infoEstab' in dir(ideEstab):

                for infoEstab in ideEstab.infoEstab:

                    s5011_infoestab_dados = {}
                    s5011_infoestab_dados[
                        's5011_ideestab_id'] = s5011_ideestab.id

                    try:
                        s5011_infoestab_dados['cnaeprep'] = read_from_xml(
                            infoEstab.cnaePrep.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_infoestab_dados['aliqrat'] = read_from_xml(
                            infoEstab.aliqRat.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_infoestab_dados['fap'] = read_from_xml(
                            infoEstab.fap.cdata, 'esocial', 'N', 4)
                    except AttributeError:
                        pass

                    try:
                        s5011_infoestab_dados['aliqratajust'] = read_from_xml(
                            infoEstab.aliqRatAjust.cdata, 'esocial', 'N', 4)
                    except AttributeError:
                        pass

                    s5011_infoestab = s5011infoEstab.objects.create(
                        **s5011_infoestab_dados)

                    if 'infoComplObra' in dir(infoEstab):

                        for infoComplObra in infoEstab.infoComplObra:

                            s5011_infocomplobra_dados = {}
                            s5011_infocomplobra_dados[
                                's5011_infoestab_id'] = s5011_infoestab.id

                            try:
                                s5011_infocomplobra_dados[
                                    'indsubstpatrobra'] = read_from_xml(
                                        infoComplObra.indSubstPatrObra.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            s5011_infocomplobra = s5011infoComplObra.objects.create(
                                **s5011_infocomplobra_dados)

            if 'ideLotacao' in dir(ideEstab):

                for ideLotacao in ideEstab.ideLotacao:

                    s5011_idelotacao_dados = {}
                    s5011_idelotacao_dados[
                        's5011_ideestab_id'] = s5011_ideestab.id

                    try:
                        s5011_idelotacao_dados['codlotacao'] = read_from_xml(
                            ideLotacao.codLotacao.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_idelotacao_dados['fpas'] = read_from_xml(
                            ideLotacao.fpas.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_idelotacao_dados['codtercs'] = read_from_xml(
                            ideLotacao.codTercs.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_idelotacao_dados['codtercssusp'] = read_from_xml(
                            ideLotacao.codTercsSusp.cdata, 'esocial', 'C',
                            None)
                    except AttributeError:
                        pass

                    s5011_idelotacao = s5011ideLotacao.objects.create(
                        **s5011_idelotacao_dados)

                    if 'infoTercSusp' in dir(ideLotacao):

                        for infoTercSusp in ideLotacao.infoTercSusp:

                            s5011_infotercsusp_dados = {}
                            s5011_infotercsusp_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_infotercsusp_dados[
                                    'codterc'] = read_from_xml(
                                        infoTercSusp.codTerc.cdata, 'esocial',
                                        'C', None)
                            except AttributeError:
                                pass

                            s5011_infotercsusp = s5011infoTercSusp.objects.create(
                                **s5011_infotercsusp_dados)

                    if 'infoEmprParcial' in dir(ideLotacao):

                        for infoEmprParcial in ideLotacao.infoEmprParcial:

                            s5011_infoemprparcial_dados = {}
                            s5011_infoemprparcial_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_infoemprparcial_dados[
                                    'tpinsccontrat'] = read_from_xml(
                                        infoEmprParcial.tpInscContrat.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_infoemprparcial_dados[
                                    'nrinsccontrat'] = read_from_xml(
                                        infoEmprParcial.nrInscContrat.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_infoemprparcial_dados[
                                    'tpinscprop'] = read_from_xml(
                                        infoEmprParcial.tpInscProp.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_infoemprparcial_dados[
                                    'nrinscprop'] = read_from_xml(
                                        infoEmprParcial.nrInscProp.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_infoemprparcial_dados[
                                    'cnoobra'] = read_from_xml(
                                        infoEmprParcial.cnoObra.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s5011_infoemprparcial = s5011infoEmprParcial.objects.create(
                                **s5011_infoemprparcial_dados)

                    if 'dadosOpPort' in dir(ideLotacao):

                        for dadosOpPort in ideLotacao.dadosOpPort:

                            s5011_dadosopport_dados = {}
                            s5011_dadosopport_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_dadosopport_dados[
                                    'cnpjopportuario'] = read_from_xml(
                                        dadosOpPort.cnpjOpPortuario.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_dadosopport_dados[
                                    'aliqrat'] = read_from_xml(
                                        dadosOpPort.aliqRat.cdata, 'esocial',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_dadosopport_dados['fap'] = read_from_xml(
                                    dadosOpPort.fap.cdata, 'esocial', 'N', 4)
                            except AttributeError:
                                pass

                            try:
                                s5011_dadosopport_dados[
                                    'aliqratajust'] = read_from_xml(
                                        dadosOpPort.aliqRatAjust.cdata,
                                        'esocial', 'N', 4)
                            except AttributeError:
                                pass

                            s5011_dadosopport = s5011dadosOpPort.objects.create(
                                **s5011_dadosopport_dados)

                    if 'basesRemun' in dir(ideLotacao):

                        for basesRemun in ideLotacao.basesRemun:

                            s5011_basesremun_dados = {}
                            s5011_basesremun_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_basesremun_dados[
                                    'indincid'] = read_from_xml(
                                        basesRemun.indIncid.cdata, 'esocial',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'codcateg'] = read_from_xml(
                                        basesRemun.codCateg.cdata, 'esocial',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp00'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp00.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp15'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp15.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp20'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp20.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp25'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp25.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp00'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp00.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp15'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp15.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp20'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp20.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp25'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp25.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp00va'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp00VA.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp15va'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp15VA.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp20va'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp20VA.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrbccp25va'] = read_from_xml(
                                        basesRemun.basesCp.vrBcCp25VA.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp00va'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp00VA.
                                        cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp15va'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp15VA.
                                        cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp20va'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp20VA.
                                        cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsuspbccp25va'] = read_from_xml(
                                        basesRemun.basesCp.vrSuspBcCp25VA.
                                        cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrdescsest'] = read_from_xml(
                                        basesRemun.basesCp.vrDescSest.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrcalcsest'] = read_from_xml(
                                        basesRemun.basesCp.vrCalcSest.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrdescsenat'] = read_from_xml(
                                        basesRemun.basesCp.vrDescSenat.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrcalcsenat'] = read_from_xml(
                                        basesRemun.basesCp.vrCalcSenat.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsalfam'] = read_from_xml(
                                        basesRemun.basesCp.vrSalFam.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesremun_dados[
                                    'vrsalmat'] = read_from_xml(
                                        basesRemun.basesCp.vrSalMat.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s5011_basesremun = s5011basesRemun.objects.create(
                                **s5011_basesremun_dados)

                    if 'basesAvNPort' in dir(ideLotacao):

                        for basesAvNPort in ideLotacao.basesAvNPort:

                            s5011_basesavnport_dados = {}
                            s5011_basesavnport_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_basesavnport_dados[
                                    'vrbccp00'] = read_from_xml(
                                        basesAvNPort.vrBcCp00.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrbccp15'] = read_from_xml(
                                        basesAvNPort.vrBcCp15.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrbccp20'] = read_from_xml(
                                        basesAvNPort.vrBcCp20.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrbccp25'] = read_from_xml(
                                        basesAvNPort.vrBcCp25.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrbccp13'] = read_from_xml(
                                        basesAvNPort.vrBcCp13.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrbcfgts'] = read_from_xml(
                                        basesAvNPort.vrBcFgts.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s5011_basesavnport_dados[
                                    'vrdesccp'] = read_from_xml(
                                        basesAvNPort.vrDescCP.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            s5011_basesavnport = s5011basesAvNPort.objects.create(
                                **s5011_basesavnport_dados)

                    if 'infoSubstPatrOpPort' in dir(ideLotacao):

                        for infoSubstPatrOpPort in ideLotacao.infoSubstPatrOpPort:

                            s5011_infosubstpatropport_dados = {}
                            s5011_infosubstpatropport_dados[
                                's5011_idelotacao_id'] = s5011_idelotacao.id

                            try:
                                s5011_infosubstpatropport_dados[
                                    'cnpjopportuario'] = read_from_xml(
                                        infoSubstPatrOpPort.cnpjOpPortuario.
                                        cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s5011_infosubstpatropport = s5011infoSubstPatrOpPort.objects.create(
                                **s5011_infosubstpatropport_dados)

            if 'basesAquis' in dir(ideEstab):

                for basesAquis in ideEstab.basesAquis:

                    s5011_basesaquis_dados = {}
                    s5011_basesaquis_dados[
                        's5011_ideestab_id'] = s5011_ideestab.id

                    try:
                        s5011_basesaquis_dados['indaquis'] = read_from_xml(
                            basesAquis.indAquis.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vlraquis'] = read_from_xml(
                            basesAquis.vlrAquis.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrcpdescpr'] = read_from_xml(
                            basesAquis.vrCPDescPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrcpnret'] = read_from_xml(
                            basesAquis.vrCPNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrratnret'] = read_from_xml(
                            basesAquis.vrRatNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrsenarnret'] = read_from_xml(
                            basesAquis.vrSenarNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrcpcalcpr'] = read_from_xml(
                            basesAquis.vrCPCalcPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrratdescpr'] = read_from_xml(
                            basesAquis.vrRatDescPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrratcalcpr'] = read_from_xml(
                            basesAquis.vrRatCalcPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrsenardesc'] = read_from_xml(
                            basesAquis.vrSenarDesc.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basesaquis_dados['vrsenarcalc'] = read_from_xml(
                            basesAquis.vrSenarCalc.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5011_basesaquis = s5011basesAquis.objects.create(
                        **s5011_basesaquis_dados)

            if 'basesComerc' in dir(ideEstab):

                for basesComerc in ideEstab.basesComerc:

                    s5011_basescomerc_dados = {}
                    s5011_basescomerc_dados[
                        's5011_ideestab_id'] = s5011_ideestab.id

                    try:
                        s5011_basescomerc_dados['indcomerc'] = read_from_xml(
                            basesComerc.indComerc.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_basescomerc_dados['vrbccompr'] = read_from_xml(
                            basesComerc.vrBcComPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basescomerc_dados['vrcpsusp'] = read_from_xml(
                            basesComerc.vrCPSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basescomerc_dados['vrratsusp'] = read_from_xml(
                            basesComerc.vrRatSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_basescomerc_dados['vrsenarsusp'] = read_from_xml(
                            basesComerc.vrSenarSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5011_basescomerc = s5011basesComerc.objects.create(
                        **s5011_basescomerc_dados)

            if 'infoCREstab' in dir(ideEstab):

                for infoCREstab in ideEstab.infoCREstab:

                    s5011_infocrestab_dados = {}
                    s5011_infocrestab_dados[
                        's5011_ideestab_id'] = s5011_ideestab.id

                    try:
                        s5011_infocrestab_dados['tpcr'] = read_from_xml(
                            infoCREstab.tpCR.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s5011_infocrestab_dados['vrcr'] = read_from_xml(
                            infoCREstab.vrCR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s5011_infocrestab_dados['vrsuspcr'] = read_from_xml(
                            infoCREstab.vrSuspCR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s5011_infocrestab = s5011infoCREstab.objects.create(
                        **s5011_infocrestab_dados)

    if 'infoCS' in dir(evtCS) and 'infoCRContrib' in dir(evtCS.infoCS):

        for infoCRContrib in evtCS.infoCS.infoCRContrib:

            s5011_infocrcontrib_dados = {}
            s5011_infocrcontrib_dados['s5011_evtcs_id'] = s5011_evtcs.id

            try:
                s5011_infocrcontrib_dados['tpcr'] = read_from_xml(
                    infoCRContrib.tpCR.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s5011_infocrcontrib_dados['vrcr'] = read_from_xml(
                    infoCRContrib.vrCR.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            try:
                s5011_infocrcontrib_dados['vrcrsusp'] = read_from_xml(
                    infoCRContrib.vrCRSusp.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s5011_infocrcontrib = s5011infoCRContrib.objects.create(
                **s5011_infocrcontrib_dados)
    s5011_evtcs_dados['evento'] = 's5011'
    s5011_evtcs_dados['id'] = s5011_evtcs.id
    s5011_evtcs_dados['identidade_evento'] = doc.eSocial.evtCS['Id']

    from emensageriapro.esocial.views.s5011_evtcs_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s5011_evtcs.id)

    return s5011_evtcs_dados
예제 #10
0
def read_s2241_evtinsapo_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2241_evtinsapo_dados = {}
    s2241_evtinsapo_dados['status'] = status
    s2241_evtinsapo_dados['arquivo_original'] = 1
    if arquivo:
        s2241_evtinsapo_dados['arquivo'] = arquivo.arquivo
    s2241_evtinsapo_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    s2241_evtinsapo_dados['identidade'] = doc.eSocial.evtInsApo['Id']
    evtInsApo = doc.eSocial.evtInsApo

    try:
        s2241_evtinsapo_dados['indretif'] = read_from_xml(evtInsApo.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['nrrecibo'] = read_from_xml(evtInsApo.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['tpamb'] = read_from_xml(evtInsApo.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['procemi'] = read_from_xml(evtInsApo.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['verproc'] = read_from_xml(evtInsApo.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['tpinsc'] = read_from_xml(evtInsApo.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['nrinsc'] = read_from_xml(evtInsApo.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['cpftrab'] = read_from_xml(evtInsApo.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['nistrab'] = read_from_xml(evtInsApo.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2241_evtinsapo_dados['matricula'] = read_from_xml(evtInsApo.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s2241_evtinsapo = s2241evtInsApo.objects.create(**s2241_evtinsapo_dados)

    if 'insalPeric' in dir(evtInsApo):

        for insalPeric in evtInsApo.insalPeric:

            s2241_insalperic_dados = {}
            s2241_insalperic_dados['s2241_evtinsapo_id'] = s2241_evtinsapo.id

            s2241_insalperic = s2241insalPeric.objects.create(**s2241_insalperic_dados)

            if 'iniInsalPeric' in dir(insalPeric):

                for iniInsalPeric in insalPeric.iniInsalPeric:

                    s2241_iniinsalperic_dados = {}
                    s2241_iniinsalperic_dados['s2241_insalperic_id'] = s2241_insalperic.id

                    try:
                        s2241_iniinsalperic_dados['dtinicondicao'] = read_from_xml(iniInsalPeric.dtIniCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_iniinsalperic = s2241iniInsalPeric.objects.create(**s2241_iniinsalperic_dados)

                    if 'infoAmb' in dir(iniInsalPeric):

                        for infoAmb in iniInsalPeric.infoAmb:

                            s2241_iniinsalperic_infoamb_dados = {}
                            s2241_iniinsalperic_infoamb_dados['s2241_iniinsalperic_id'] = s2241_iniinsalperic.id
        
                            try:
                                s2241_iniinsalperic_infoamb_dados['codamb'] = read_from_xml(infoAmb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_iniinsalperic_infoamb = s2241iniInsalPericinfoAmb.objects.create(**s2241_iniinsalperic_infoamb_dados)
        
                            if 'fatRisco' in dir(infoAmb):
        
                                for fatRisco in infoAmb.fatRisco:
        
                                    s2241_iniinsalperic_fatrisco_dados = {}
                                    s2241_iniinsalperic_fatrisco_dados['s2241_iniinsalperic_infoamb_id'] = s2241_iniinsalperic_infoamb.id
                
                                    try:
                                        s2241_iniinsalperic_fatrisco_dados['codfatris'] = read_from_xml(fatRisco.codFatRis.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
        
                                    s2241_iniinsalperic_fatrisco = s2241iniInsalPericfatRisco.objects.create(**s2241_iniinsalperic_fatrisco_dados)

            if 'altInsalPeric' in dir(insalPeric):

                for altInsalPeric in insalPeric.altInsalPeric:

                    s2241_altinsalperic_dados = {}
                    s2241_altinsalperic_dados['s2241_insalperic_id'] = s2241_insalperic.id

                    try:
                        s2241_altinsalperic_dados['dtaltcondicao'] = read_from_xml(altInsalPeric.dtAltCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_altinsalperic = s2241altInsalPeric.objects.create(**s2241_altinsalperic_dados)

                    if 'infoamb' in dir(altInsalPeric):

                        for infoamb in altInsalPeric.infoamb:

                            s2241_altinsalperic_infoamb_dados = {}
                            s2241_altinsalperic_infoamb_dados['s2241_altinsalperic_id'] = s2241_altinsalperic.id
        
                            try:
                                s2241_altinsalperic_infoamb_dados['codamb'] = read_from_xml(infoamb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_altinsalperic_infoamb = s2241altInsalPericinfoamb.objects.create(**s2241_altinsalperic_infoamb_dados)
        
                            if 'fatRisco' in dir(infoamb):
        
                                for fatRisco in infoamb.fatRisco:
        
                                    s2241_altinsalperic_fatrisco_dados = {}
                                    s2241_altinsalperic_fatrisco_dados['s2241_altinsalperic_infoamb_id'] = s2241_altinsalperic_infoamb.id
                
                                    try:
                                        s2241_altinsalperic_fatrisco_dados['codfatris'] = read_from_xml(fatRisco.codFatRis.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
        
                                    s2241_altinsalperic_fatrisco = s2241altInsalPericfatRisco.objects.create(**s2241_altinsalperic_fatrisco_dados)

            if 'fimInsalPeric' in dir(insalPeric):

                for fimInsalPeric in insalPeric.fimInsalPeric:

                    s2241_fiminsalperic_dados = {}
                    s2241_fiminsalperic_dados['s2241_insalperic_id'] = s2241_insalperic.id

                    try:
                        s2241_fiminsalperic_dados['dtfimcondicao'] = read_from_xml(fimInsalPeric.dtFimCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_fiminsalperic = s2241fimInsalPeric.objects.create(**s2241_fiminsalperic_dados)

                    if 'infoAmb' in dir(fimInsalPeric):

                        for infoAmb in fimInsalPeric.infoAmb:

                            s2241_fiminsalperic_infoamb_dados = {}
                            s2241_fiminsalperic_infoamb_dados['s2241_fiminsalperic_id'] = s2241_fiminsalperic.id
        
                            try:
                                s2241_fiminsalperic_infoamb_dados['codamb'] = read_from_xml(infoAmb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_fiminsalperic_infoamb = s2241fimInsalPericinfoAmb.objects.create(**s2241_fiminsalperic_infoamb_dados)

    if 'aposentEsp' in dir(evtInsApo):

        for aposentEsp in evtInsApo.aposentEsp:

            s2241_aposentesp_dados = {}
            s2241_aposentesp_dados['s2241_evtinsapo_id'] = s2241_evtinsapo.id

            s2241_aposentesp = s2241aposentEsp.objects.create(**s2241_aposentesp_dados)

            if 'iniAposentEsp' in dir(aposentEsp):

                for iniAposentEsp in aposentEsp.iniAposentEsp:

                    s2241_iniaposentesp_dados = {}
                    s2241_iniaposentesp_dados['s2241_aposentesp_id'] = s2241_aposentesp.id

                    try:
                        s2241_iniaposentesp_dados['dtinicondicao'] = read_from_xml(iniAposentEsp.dtIniCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_iniaposentesp = s2241iniAposentEsp.objects.create(**s2241_iniaposentesp_dados)

                    if 'infoAmb' in dir(iniAposentEsp):

                        for infoAmb in iniAposentEsp.infoAmb:

                            s2241_iniaposentesp_infoamb_dados = {}
                            s2241_iniaposentesp_infoamb_dados['s2241_iniaposentesp_id'] = s2241_iniaposentesp.id
        
                            try:
                                s2241_iniaposentesp_infoamb_dados['codamb'] = read_from_xml(infoAmb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_iniaposentesp_infoamb = s2241iniAposentEspinfoAmb.objects.create(**s2241_iniaposentesp_infoamb_dados)
        
                            if 'fatRisco' in dir(infoAmb):
        
                                for fatRisco in infoAmb.fatRisco:
        
                                    s2241_iniaposentesp_fatrisco_dados = {}
                                    s2241_iniaposentesp_fatrisco_dados['s2241_iniaposentesp_infoamb_id'] = s2241_iniaposentesp_infoamb.id
                
                                    try:
                                        s2241_iniaposentesp_fatrisco_dados['codfatris'] = read_from_xml(fatRisco.codFatRis.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
        
                                    s2241_iniaposentesp_fatrisco = s2241iniAposentEspfatRisco.objects.create(**s2241_iniaposentesp_fatrisco_dados)

            if 'altAposentEsp' in dir(aposentEsp):

                for altAposentEsp in aposentEsp.altAposentEsp:

                    s2241_altaposentesp_dados = {}
                    s2241_altaposentesp_dados['s2241_aposentesp_id'] = s2241_aposentesp.id

                    try:
                        s2241_altaposentesp_dados['dtaltcondicao'] = read_from_xml(altAposentEsp.dtAltCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_altaposentesp = s2241altAposentEsp.objects.create(**s2241_altaposentesp_dados)

                    if 'infoamb' in dir(altAposentEsp):

                        for infoamb in altAposentEsp.infoamb:

                            s2241_altaposentesp_infoamb_dados = {}
                            s2241_altaposentesp_infoamb_dados['s2241_altaposentesp_id'] = s2241_altaposentesp.id
        
                            try:
                                s2241_altaposentesp_infoamb_dados['codamb'] = read_from_xml(infoamb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_altaposentesp_infoamb = s2241altAposentEspinfoamb.objects.create(**s2241_altaposentesp_infoamb_dados)
        
                            if 'fatRisco' in dir(infoamb):
        
                                for fatRisco in infoamb.fatRisco:
        
                                    s2241_altaposentesp_fatrisco_dados = {}
                                    s2241_altaposentesp_fatrisco_dados['s2241_altaposentesp_infoamb_id'] = s2241_altaposentesp_infoamb.id
                
                                    try:
                                        s2241_altaposentesp_fatrisco_dados['codfatris'] = read_from_xml(fatRisco.codFatRis.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
        
                                    s2241_altaposentesp_fatrisco = s2241altAposentEspfatRisco.objects.create(**s2241_altaposentesp_fatrisco_dados)

            if 'fimAposentEsp' in dir(aposentEsp):

                for fimAposentEsp in aposentEsp.fimAposentEsp:

                    s2241_fimaposentesp_dados = {}
                    s2241_fimaposentesp_dados['s2241_aposentesp_id'] = s2241_aposentesp.id

                    try:
                        s2241_fimaposentesp_dados['dtfimcondicao'] = read_from_xml(fimAposentEsp.dtFimCondicao.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    s2241_fimaposentesp = s2241fimAposentEsp.objects.create(**s2241_fimaposentesp_dados)

                    if 'infoAmb' in dir(fimAposentEsp):

                        for infoAmb in fimAposentEsp.infoAmb:

                            s2241_fimaposentesp_infoamb_dados = {}
                            s2241_fimaposentesp_infoamb_dados['s2241_fimaposentesp_id'] = s2241_fimaposentesp.id
        
                            try:
                                s2241_fimaposentesp_infoamb_dados['codamb'] = read_from_xml(infoAmb.codAmb.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2241_fimaposentesp_infoamb = s2241fimAposentEspinfoAmb.objects.create(**s2241_fimaposentesp_infoamb_dados)
    s2241_evtinsapo_dados['evento'] = 's2241'
    s2241_evtinsapo_dados['id'] = s2241_evtinsapo.id
    s2241_evtinsapo_dados['identidade_evento'] = doc.eSocial.evtInsApo['Id']

    from emensageriapro.esocial.views.s2241_evtinsapo_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2241_evtinsapo.id)

    return s2241_evtinsapo_dados
예제 #11
0
def read_s1295_evttotconting_obj(request,
                                 doc,
                                 status,
                                 validar=False,
                                 arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1295_evttotconting_dados = {}
    s1295_evttotconting_dados['status'] = status
    s1295_evttotconting_dados['arquivo_original'] = 1
    if arquivo:
        s1295_evttotconting_dados['arquivo'] = arquivo.arquivo
    s1295_evttotconting_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1295_evttotconting_dados['identidade'] = doc.eSocial.evtTotConting['Id']
    evtTotConting = doc.eSocial.evtTotConting

    try:
        s1295_evttotconting_dados['indapuracao'] = read_from_xml(
            evtTotConting.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['perapur'] = read_from_xml(
            evtTotConting.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['tpamb'] = read_from_xml(
            evtTotConting.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['procemi'] = read_from_xml(
            evtTotConting.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['verproc'] = read_from_xml(
            evtTotConting.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['tpinsc'] = read_from_xml(
            evtTotConting.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1295_evttotconting_dados['nrinsc'] = read_from_xml(
            evtTotConting.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1295_evttotconting = s1295evtTotConting.objects.create(
        **s1295_evttotconting_dados)

    if 'ideRespInf' in dir(evtTotConting):

        for ideRespInf in evtTotConting.ideRespInf:

            s1295_iderespinf_dados = {}
            s1295_iderespinf_dados[
                's1295_evttotconting_id'] = s1295_evttotconting.id

            try:
                s1295_iderespinf_dados['nmresp'] = read_from_xml(
                    ideRespInf.nmResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1295_iderespinf_dados['cpfresp'] = read_from_xml(
                    ideRespInf.cpfResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1295_iderespinf_dados['telefone'] = read_from_xml(
                    ideRespInf.telefone.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1295_iderespinf_dados['email'] = read_from_xml(
                    ideRespInf.email.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1295_iderespinf = s1295ideRespInf.objects.create(
                **s1295_iderespinf_dados)
    s1295_evttotconting_dados['evento'] = 's1295'
    s1295_evttotconting_dados['id'] = s1295_evttotconting.id
    s1295_evttotconting_dados['identidade_evento'] = doc.eSocial.evtTotConting[
        'Id']

    from emensageriapro.esocial.views.s1295_evttotconting_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1295_evttotconting.id)

    return s1295_evttotconting_dados
예제 #12
0
def read_s5001_evtbasestrab_obj(request,
                                doc,
                                status,
                                validar=False,
                                arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s5001_evtbasestrab_dados = {}
    s5001_evtbasestrab_dados['status'] = status
    s5001_evtbasestrab_dados['arquivo_original'] = 1
    if arquivo:
        s5001_evtbasestrab_dados['arquivo'] = arquivo.arquivo
    s5001_evtbasestrab_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s5001_evtbasestrab_dados['identidade'] = doc.eSocial.evtBasesTrab['Id']
    evtBasesTrab = doc.eSocial.evtBasesTrab

    try:
        s5001_evtbasestrab_dados['nrrecarqbase'] = read_from_xml(
            evtBasesTrab.ideEvento.nrRecArqBase.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5001_evtbasestrab_dados['indapuracao'] = read_from_xml(
            evtBasesTrab.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5001_evtbasestrab_dados['perapur'] = read_from_xml(
            evtBasesTrab.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5001_evtbasestrab_dados['tpinsc'] = read_from_xml(
            evtBasesTrab.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s5001_evtbasestrab_dados['nrinsc'] = read_from_xml(
            evtBasesTrab.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s5001_evtbasestrab_dados['cpftrab'] = read_from_xml(
            evtBasesTrab.ideTrabalhador.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s5001_evtbasestrab = s5001evtBasesTrab.objects.create(
        **s5001_evtbasestrab_dados)

    if 'ideTrabalhador' in dir(evtBasesTrab) and 'procJudTrab' in dir(
            evtBasesTrab.ideTrabalhador):

        for procJudTrab in evtBasesTrab.ideTrabalhador.procJudTrab:

            s5001_procjudtrab_dados = {}
            s5001_procjudtrab_dados[
                's5001_evtbasestrab_id'] = s5001_evtbasestrab.id

            try:
                s5001_procjudtrab_dados['nrprocjud'] = read_from_xml(
                    procJudTrab.nrProcJud.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s5001_procjudtrab_dados['codsusp'] = read_from_xml(
                    procJudTrab.codSusp.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s5001_procjudtrab = s5001procJudTrab.objects.create(
                **s5001_procjudtrab_dados)

    if 'infoCpCalc' in dir(evtBasesTrab):

        for infoCpCalc in evtBasesTrab.infoCpCalc:

            s5001_infocpcalc_dados = {}
            s5001_infocpcalc_dados[
                's5001_evtbasestrab_id'] = s5001_evtbasestrab.id

            try:
                s5001_infocpcalc_dados['tpcr'] = read_from_xml(
                    infoCpCalc.tpCR.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s5001_infocpcalc_dados['vrcpseg'] = read_from_xml(
                    infoCpCalc.vrCpSeg.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            try:
                s5001_infocpcalc_dados['vrdescseg'] = read_from_xml(
                    infoCpCalc.vrDescSeg.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s5001_infocpcalc = s5001infoCpCalc.objects.create(
                **s5001_infocpcalc_dados)

    if 'infoCp' in dir(evtBasesTrab):

        for infoCp in evtBasesTrab.infoCp:

            s5001_infocp_dados = {}
            s5001_infocp_dados['s5001_evtbasestrab_id'] = s5001_evtbasestrab.id

            s5001_infocp = s5001infoCp.objects.create(**s5001_infocp_dados)

            if 'ideEstabLot' in dir(infoCp):

                for ideEstabLot in infoCp.ideEstabLot:

                    s5001_ideestablot_dados = {}
                    s5001_ideestablot_dados[
                        's5001_infocp_id'] = s5001_infocp.id

                    try:
                        s5001_ideestablot_dados['tpinsc'] = read_from_xml(
                            ideEstabLot.tpInsc.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s5001_ideestablot_dados['nrinsc'] = read_from_xml(
                            ideEstabLot.nrInsc.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s5001_ideestablot_dados['codlotacao'] = read_from_xml(
                            ideEstabLot.codLotacao.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s5001_ideestablot = s5001ideEstabLot.objects.create(
                        **s5001_ideestablot_dados)

                    if 'infoCategIncid' in dir(ideEstabLot):

                        for infoCategIncid in ideEstabLot.infoCategIncid:

                            s5001_infocategincid_dados = {}
                            s5001_infocategincid_dados[
                                's5001_ideestablot_id'] = s5001_ideestablot.id

                            try:
                                s5001_infocategincid_dados[
                                    'matricula'] = read_from_xml(
                                        infoCategIncid.matricula.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s5001_infocategincid_dados[
                                    'codcateg'] = read_from_xml(
                                        infoCategIncid.codCateg.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                s5001_infocategincid_dados[
                                    'indsimples'] = read_from_xml(
                                        infoCategIncid.indSimples.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            s5001_infocategincid = s5001infoCategIncid.objects.create(
                                **s5001_infocategincid_dados)

                            if 'infoBaseCS' in dir(infoCategIncid):

                                for infoBaseCS in infoCategIncid.infoBaseCS:

                                    s5001_infobasecs_dados = {}
                                    s5001_infobasecs_dados[
                                        's5001_infocategincid_id'] = s5001_infocategincid.id

                                    try:
                                        s5001_infobasecs_dados[
                                            'ind13'] = read_from_xml(
                                                infoBaseCS.ind13.cdata,
                                                'esocial', 'N', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s5001_infobasecs_dados[
                                            'tpvalor'] = read_from_xml(
                                                infoBaseCS.tpValor.cdata,
                                                'esocial', 'N', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s5001_infobasecs_dados[
                                            'valor'] = read_from_xml(
                                                infoBaseCS.valor.cdata,
                                                'esocial', 'N', 2)
                                    except AttributeError:
                                        pass

                                    s5001_infobasecs = s5001infoBaseCS.objects.create(
                                        **s5001_infobasecs_dados)

                            if 'calcTerc' in dir(infoCategIncid):

                                for calcTerc in infoCategIncid.calcTerc:

                                    s5001_calcterc_dados = {}
                                    s5001_calcterc_dados[
                                        's5001_infocategincid_id'] = s5001_infocategincid.id

                                    try:
                                        s5001_calcterc_dados[
                                            'tpcr'] = read_from_xml(
                                                calcTerc.tpCR.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s5001_calcterc_dados[
                                            'vrcssegterc'] = read_from_xml(
                                                calcTerc.vrCsSegTerc.cdata,
                                                'esocial', 'N', 2)
                                    except AttributeError:
                                        pass

                                    try:
                                        s5001_calcterc_dados[
                                            'vrdescterc'] = read_from_xml(
                                                calcTerc.vrDescTerc.cdata,
                                                'esocial', 'N', 2)
                                    except AttributeError:
                                        pass

                                    s5001_calcterc = s5001calcTerc.objects.create(
                                        **s5001_calcterc_dados)

                            if 'infoPerRef' in dir(infoCategIncid):

                                for infoPerRef in infoCategIncid.infoPerRef:

                                    s5001_infoperref_dados = {}
                                    s5001_infoperref_dados[
                                        's5001_infocategincid_id'] = s5001_infocategincid.id

                                    try:
                                        s5001_infoperref_dados[
                                            'perref'] = read_from_xml(
                                                infoPerRef.perRef.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    s5001_infoperref = s5001infoPerRef.objects.create(
                                        **s5001_infoperref_dados)

                                    if 'detInfoPerRef' in dir(infoPerRef):

                                        for detInfoPerRef in infoPerRef.detInfoPerRef:

                                            s5001_detinfoperref_dados = {}
                                            s5001_detinfoperref_dados[
                                                's5001_infoperref_id'] = s5001_infoperref.id

                                            try:
                                                s5001_detinfoperref_dados[
                                                    'ind13'] = read_from_xml(
                                                        detInfoPerRef.ind13.
                                                        cdata, 'esocial', 'N',
                                                        None)
                                            except AttributeError:
                                                pass

                                            try:
                                                s5001_detinfoperref_dados[
                                                    'tpvalor'] = read_from_xml(
                                                        detInfoPerRef.tpValor.
                                                        cdata, 'esocial', 'N',
                                                        None)
                                            except AttributeError:
                                                pass

                                            try:
                                                s5001_detinfoperref_dados[
                                                    'vrperref'] = read_from_xml(
                                                        detInfoPerRef.vrPerRef.
                                                        cdata, 'esocial', 'N',
                                                        2)
                                            except AttributeError:
                                                pass

                                            s5001_detinfoperref = s5001detInfoPerRef.objects.create(
                                                **s5001_detinfoperref_dados)
    s5001_evtbasestrab_dados['evento'] = 's5001'
    s5001_evtbasestrab_dados['id'] = s5001_evtbasestrab.id
    s5001_evtbasestrab_dados['identidade_evento'] = doc.eSocial.evtBasesTrab[
        'Id']

    from emensageriapro.esocial.views.s5001_evtbasestrab_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s5001_evtbasestrab.id)

    return s5001_evtbasestrab_dados
예제 #13
0
def read_r2030_evtassocdesprec_obj(request,
                                   doc,
                                   status,
                                   validar=False,
                                   arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r2030_evtassocdesprec_dados = {}
    r2030_evtassocdesprec_dados['status'] = status
    r2030_evtassocdesprec_dados['arquivo_original'] = 1
    if arquivo:
        r2030_evtassocdesprec_dados['arquivo'] = arquivo.arquivo
    r2030_evtassocdesprec_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r2030_evtassocdesprec_dados['identidade'] = doc.Reinf.evtAssocDespRec['id']
    evtAssocDespRec = doc.Reinf.evtAssocDespRec

    try:
        r2030_evtassocdesprec_dados['indretif'] = read_from_xml(
            evtAssocDespRec.ideEvento.indRetif.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['nrrecibo'] = read_from_xml(
            evtAssocDespRec.ideEvento.nrRecibo.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['perapur'] = read_from_xml(
            evtAssocDespRec.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['tpamb'] = read_from_xml(
            evtAssocDespRec.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['procemi'] = read_from_xml(
            evtAssocDespRec.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['verproc'] = read_from_xml(
            evtAssocDespRec.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['tpinsc'] = read_from_xml(
            evtAssocDespRec.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['nrinsc'] = read_from_xml(
            evtAssocDespRec.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['tpinscestab'] = read_from_xml(
            evtAssocDespRec.ideContri.ideEstab.tpInscEstab.cdata, 'efdreinf',
            'N', None)
    except AttributeError:
        pass

    try:
        r2030_evtassocdesprec_dados['nrinscestab'] = read_from_xml(
            evtAssocDespRec.ideContri.ideEstab.nrInscEstab.cdata, 'efdreinf',
            'C', None)
    except AttributeError:
        pass

    r2030_evtassocdesprec = r2030evtAssocDespRec.objects.create(
        **r2030_evtassocdesprec_dados)

    if 'ideContri' in dir(evtAssocDespRec) and 'ideEstab' in dir(
            evtAssocDespRec.ideContri) and 'recursosRec' in dir(
                evtAssocDespRec.ideContri.ideEstab):

        for recursosRec in evtAssocDespRec.ideContri.ideEstab.recursosRec:

            r2030_recursosrec_dados = {}
            r2030_recursosrec_dados[
                'r2030_evtassocdesprec_id'] = r2030_evtassocdesprec.id

            try:
                r2030_recursosrec_dados['cnpjorigrecurso'] = read_from_xml(
                    recursosRec.cnpjOrigRecurso.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r2030_recursosrec_dados['vlrtotalrec'] = read_from_xml(
                    recursosRec.vlrTotalRec.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            try:
                r2030_recursosrec_dados['vlrtotalret'] = read_from_xml(
                    recursosRec.vlrTotalRet.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            try:
                r2030_recursosrec_dados['vlrtotalnret'] = read_from_xml(
                    recursosRec.vlrTotalNRet.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r2030_recursosrec = r2030recursosRec.objects.create(
                **r2030_recursosrec_dados)

            if 'infoRecurso' in dir(recursosRec):

                for infoRecurso in recursosRec.infoRecurso:

                    r2030_inforecurso_dados = {}
                    r2030_inforecurso_dados[
                        'r2030_recursosrec_id'] = r2030_recursosrec.id

                    try:
                        r2030_inforecurso_dados['tprepasse'] = read_from_xml(
                            infoRecurso.tpRepasse.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2030_inforecurso_dados['descrecurso'] = read_from_xml(
                            infoRecurso.descRecurso.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r2030_inforecurso_dados['vlrbruto'] = read_from_xml(
                            infoRecurso.vlrBruto.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2030_inforecurso_dados['vlrretapur'] = read_from_xml(
                            infoRecurso.vlrRetApur.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r2030_inforecurso = r2030infoRecurso.objects.create(
                        **r2030_inforecurso_dados)

            if 'infoProc' in dir(recursosRec):

                for infoProc in recursosRec.infoProc:

                    r2030_infoproc_dados = {}
                    r2030_infoproc_dados[
                        'r2030_recursosrec_id'] = r2030_recursosrec.id

                    try:
                        r2030_infoproc_dados['tpproc'] = read_from_xml(
                            infoProc.tpProc.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2030_infoproc_dados['nrproc'] = read_from_xml(
                            infoProc.nrProc.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r2030_infoproc_dados['codsusp'] = read_from_xml(
                            infoProc.codSusp.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2030_infoproc_dados['vlrnret'] = read_from_xml(
                            infoProc.vlrNRet.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r2030_infoproc = r2030infoProc.objects.create(
                        **r2030_infoproc_dados)
    r2030_evtassocdesprec_dados['evento'] = 'r2030'
    r2030_evtassocdesprec_dados['id'] = r2030_evtassocdesprec.id
    r2030_evtassocdesprec_dados[
        'identidade_evento'] = doc.Reinf.evtAssocDespRec['id']

    from emensageriapro.efdreinf.views.r2030_evtassocdesprec_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r2030_evtassocdesprec.id)

    return r2030_evtassocdesprec_dados
예제 #14
0
def read_s1210_evtpgtos_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1210_evtpgtos_dados = {}
    s1210_evtpgtos_dados['status'] = status
    s1210_evtpgtos_dados['arquivo_original'] = 1
    if arquivo:
        s1210_evtpgtos_dados['arquivo'] = arquivo.arquivo
    s1210_evtpgtos_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    s1210_evtpgtos_dados['identidade'] = doc.eSocial.evtPgtos['Id']
    evtPgtos = doc.eSocial.evtPgtos

    try:
        s1210_evtpgtos_dados['indretif'] = read_from_xml(evtPgtos.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['nrrecibo'] = read_from_xml(evtPgtos.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['indapuracao'] = read_from_xml(evtPgtos.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['perapur'] = read_from_xml(evtPgtos.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['tpamb'] = read_from_xml(evtPgtos.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['procemi'] = read_from_xml(evtPgtos.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['verproc'] = read_from_xml(evtPgtos.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['tpinsc'] = read_from_xml(evtPgtos.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['nrinsc'] = read_from_xml(evtPgtos.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1210_evtpgtos_dados['cpfbenef'] = read_from_xml(evtPgtos.ideBenef.cpfBenef.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1210_evtpgtos = s1210evtPgtos.objects.create(**s1210_evtpgtos_dados)

    if 'ideBenef' in dir(evtPgtos) and 'deps' in dir(evtPgtos.ideBenef):

        for deps in evtPgtos.ideBenef.deps:

            s1210_deps_dados = {}
            s1210_deps_dados['s1210_evtpgtos_id'] = s1210_evtpgtos.id

            try:
                s1210_deps_dados['vrdeddep'] = read_from_xml(deps.vrDedDep.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s1210_deps = s1210deps.objects.create(**s1210_deps_dados)

    if 'ideBenef' in dir(evtPgtos) and 'infoPgto' in dir(evtPgtos.ideBenef):

        for infoPgto in evtPgtos.ideBenef.infoPgto:

            s1210_infopgto_dados = {}
            s1210_infopgto_dados['s1210_evtpgtos_id'] = s1210_evtpgtos.id

            try:
                s1210_infopgto_dados['dtpgto'] = read_from_xml(infoPgto.dtPgto.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s1210_infopgto_dados['tppgto'] = read_from_xml(infoPgto.tpPgto.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1210_infopgto_dados['indresbr'] = read_from_xml(infoPgto.indResBr.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1210_infopgto = s1210infoPgto.objects.create(**s1210_infopgto_dados)

            if 'detPgtoFl' in dir(infoPgto):

                for detPgtoFl in infoPgto.detPgtoFl:

                    s1210_detpgtofl_dados = {}
                    s1210_detpgtofl_dados['s1210_infopgto_id'] = s1210_infopgto.id

                    try:
                        s1210_detpgtofl_dados['perref'] = read_from_xml(detPgtoFl.perRef.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofl_dados['idedmdev'] = read_from_xml(detPgtoFl.ideDmDev.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofl_dados['indpgtott'] = read_from_xml(detPgtoFl.indPgtoTt.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofl_dados['vrliq'] = read_from_xml(detPgtoFl.vrLiq.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofl_dados['nrrecarq'] = read_from_xml(detPgtoFl.nrRecArq.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1210_detpgtofl = s1210detPgtoFl.objects.create(**s1210_detpgtofl_dados)

                    if 'retPgtoTot' in dir(detPgtoFl):

                        for retPgtoTot in detPgtoFl.retPgtoTot:

                            s1210_detpgtofl_retpgtotot_dados = {}
                            s1210_detpgtofl_retpgtotot_dados['s1210_detpgtofl_id'] = s1210_detpgtofl.id
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['codrubr'] = read_from_xml(retPgtoTot.codRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['idetabrubr'] = read_from_xml(retPgtoTot.ideTabRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['qtdrubr'] = read_from_xml(retPgtoTot.qtdRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['fatorrubr'] = read_from_xml(retPgtoTot.fatorRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['vrunit'] = read_from_xml(retPgtoTot.vrUnit.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_retpgtotot_dados['vrrubr'] = read_from_xml(retPgtoTot.vrRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtofl_retpgtotot = s1210detPgtoFlretPgtoTot.objects.create(**s1210_detpgtofl_retpgtotot_dados)
        
                            if 'penAlim' in dir(retPgtoTot):
        
                                for penAlim in retPgtoTot.penAlim:
        
                                    s1210_detpgtofl_penalim_dados = {}
                                    s1210_detpgtofl_penalim_dados['s1210_detpgtofl_retpgtotot_id'] = s1210_detpgtofl_retpgtotot.id
                
                                    try:
                                        s1210_detpgtofl_penalim_dados['cpfbenef'] = read_from_xml(penAlim.cpfBenef.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofl_penalim_dados['dtnasctobenef'] = read_from_xml(penAlim.dtNasctoBenef.cdata, 'esocial', 'D', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofl_penalim_dados['nmbenefic'] = read_from_xml(penAlim.nmBenefic.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofl_penalim_dados['vlrpensao'] = read_from_xml(penAlim.vlrPensao.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
        
                                    s1210_detpgtofl_penalim = s1210detPgtoFlpenAlim.objects.create(**s1210_detpgtofl_penalim_dados)

                    if 'infoPgtoParc' in dir(detPgtoFl):

                        for infoPgtoParc in detPgtoFl.infoPgtoParc:

                            s1210_detpgtofl_infopgtoparc_dados = {}
                            s1210_detpgtofl_infopgtoparc_dados['s1210_detpgtofl_id'] = s1210_detpgtofl.id
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['matricula'] = read_from_xml(infoPgtoParc.matricula.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['codrubr'] = read_from_xml(infoPgtoParc.codRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['idetabrubr'] = read_from_xml(infoPgtoParc.ideTabRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['qtdrubr'] = read_from_xml(infoPgtoParc.qtdRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['fatorrubr'] = read_from_xml(infoPgtoParc.fatorRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['vrunit'] = read_from_xml(infoPgtoParc.vrUnit.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofl_infopgtoparc_dados['vrrubr'] = read_from_xml(infoPgtoParc.vrRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtofl_infopgtoparc = s1210detPgtoFlinfoPgtoParc.objects.create(**s1210_detpgtofl_infopgtoparc_dados)

            if 'detPgtoBenPr' in dir(infoPgto):

                for detPgtoBenPr in infoPgto.detPgtoBenPr:

                    s1210_detpgtobenpr_dados = {}
                    s1210_detpgtobenpr_dados['s1210_infopgto_id'] = s1210_infopgto.id

                    try:
                        s1210_detpgtobenpr_dados['perref'] = read_from_xml(detPgtoBenPr.perRef.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtobenpr_dados['idedmdev'] = read_from_xml(detPgtoBenPr.ideDmDev.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtobenpr_dados['indpgtott'] = read_from_xml(detPgtoBenPr.indPgtoTt.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtobenpr_dados['vrliq'] = read_from_xml(detPgtoBenPr.vrLiq.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s1210_detpgtobenpr = s1210detPgtoBenPr.objects.create(**s1210_detpgtobenpr_dados)

                    if 'retPgtoTot' in dir(detPgtoBenPr):

                        for retPgtoTot in detPgtoBenPr.retPgtoTot:

                            s1210_detpgtobenpr_retpgtotot_dados = {}
                            s1210_detpgtobenpr_retpgtotot_dados['s1210_detpgtobenpr_id'] = s1210_detpgtobenpr.id
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['codrubr'] = read_from_xml(retPgtoTot.codRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['idetabrubr'] = read_from_xml(retPgtoTot.ideTabRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['qtdrubr'] = read_from_xml(retPgtoTot.qtdRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['fatorrubr'] = read_from_xml(retPgtoTot.fatorRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['vrunit'] = read_from_xml(retPgtoTot.vrUnit.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_retpgtotot_dados['vrrubr'] = read_from_xml(retPgtoTot.vrRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtobenpr_retpgtotot = s1210detPgtoBenPrretPgtoTot.objects.create(**s1210_detpgtobenpr_retpgtotot_dados)

                    if 'infoPgtoParc' in dir(detPgtoBenPr):

                        for infoPgtoParc in detPgtoBenPr.infoPgtoParc:

                            s1210_detpgtobenpr_infopgtoparc_dados = {}
                            s1210_detpgtobenpr_infopgtoparc_dados['s1210_detpgtobenpr_id'] = s1210_detpgtobenpr.id
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['codrubr'] = read_from_xml(infoPgtoParc.codRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['idetabrubr'] = read_from_xml(infoPgtoParc.ideTabRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['qtdrubr'] = read_from_xml(infoPgtoParc.qtdRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['fatorrubr'] = read_from_xml(infoPgtoParc.fatorRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['vrunit'] = read_from_xml(infoPgtoParc.vrUnit.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtobenpr_infopgtoparc_dados['vrrubr'] = read_from_xml(infoPgtoParc.vrRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtobenpr_infopgtoparc = s1210detPgtoBenPrinfoPgtoParc.objects.create(**s1210_detpgtobenpr_infopgtoparc_dados)

            if 'detPgtoFer' in dir(infoPgto):

                for detPgtoFer in infoPgto.detPgtoFer:

                    s1210_detpgtofer_dados = {}
                    s1210_detpgtofer_dados['s1210_infopgto_id'] = s1210_infopgto.id

                    try:
                        s1210_detpgtofer_dados['codcateg'] = read_from_xml(detPgtoFer.codCateg.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofer_dados['matricula'] = read_from_xml(detPgtoFer.matricula.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofer_dados['dtinigoz'] = read_from_xml(detPgtoFer.dtIniGoz.cdata, 'esocial', 'D', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofer_dados['qtdias'] = read_from_xml(detPgtoFer.qtDias.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_detpgtofer_dados['vrliq'] = read_from_xml(detPgtoFer.vrLiq.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s1210_detpgtofer = s1210detPgtoFer.objects.create(**s1210_detpgtofer_dados)

                    if 'detRubrFer' in dir(detPgtoFer):

                        for detRubrFer in detPgtoFer.detRubrFer:

                            s1210_detpgtofer_detrubrfer_dados = {}
                            s1210_detpgtofer_detrubrfer_dados['s1210_detpgtofer_id'] = s1210_detpgtofer.id
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['codrubr'] = read_from_xml(detRubrFer.codRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['idetabrubr'] = read_from_xml(detRubrFer.ideTabRubr.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['qtdrubr'] = read_from_xml(detRubrFer.qtdRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['fatorrubr'] = read_from_xml(detRubrFer.fatorRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['vrunit'] = read_from_xml(detRubrFer.vrUnit.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtofer_detrubrfer_dados['vrrubr'] = read_from_xml(detRubrFer.vrRubr.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtofer_detrubrfer = s1210detPgtoFerdetRubrFer.objects.create(**s1210_detpgtofer_detrubrfer_dados)
        
                            if 'penAlim' in dir(detRubrFer):
        
                                for penAlim in detRubrFer.penAlim:
        
                                    s1210_detpgtofer_penalim_dados = {}
                                    s1210_detpgtofer_penalim_dados['s1210_detpgtofer_detrubrfer_id'] = s1210_detpgtofer_detrubrfer.id
                
                                    try:
                                        s1210_detpgtofer_penalim_dados['cpfbenef'] = read_from_xml(penAlim.cpfBenef.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofer_penalim_dados['dtnasctobenef'] = read_from_xml(penAlim.dtNasctoBenef.cdata, 'esocial', 'D', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofer_penalim_dados['nmbenefic'] = read_from_xml(penAlim.nmBenefic.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s1210_detpgtofer_penalim_dados['vlrpensao'] = read_from_xml(penAlim.vlrPensao.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
        
                                    s1210_detpgtofer_penalim = s1210detPgtoFerpenAlim.objects.create(**s1210_detpgtofer_penalim_dados)

            if 'detPgtoAnt' in dir(infoPgto):

                for detPgtoAnt in infoPgto.detPgtoAnt:

                    s1210_detpgtoant_dados = {}
                    s1210_detpgtoant_dados['s1210_infopgto_id'] = s1210_infopgto.id

                    try:
                        s1210_detpgtoant_dados['codcateg'] = read_from_xml(detPgtoAnt.codCateg.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s1210_detpgtoant = s1210detPgtoAnt.objects.create(**s1210_detpgtoant_dados)

                    if 'infoPgtoAnt' in dir(detPgtoAnt):

                        for infoPgtoAnt in detPgtoAnt.infoPgtoAnt:

                            s1210_detpgtoant_infopgtoant_dados = {}
                            s1210_detpgtoant_infopgtoant_dados['s1210_detpgtoant_id'] = s1210_detpgtoant.id
        
                            try:
                                s1210_detpgtoant_infopgtoant_dados['tpbcirrf'] = read_from_xml(infoPgtoAnt.tpBcIRRF.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s1210_detpgtoant_infopgtoant_dados['vrbcirrf'] = read_from_xml(infoPgtoAnt.vrBcIRRF.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1210_detpgtoant_infopgtoant = s1210detPgtoAntinfoPgtoAnt.objects.create(**s1210_detpgtoant_infopgtoant_dados)

            if 'idePgtoExt' in dir(infoPgto):

                for idePgtoExt in infoPgto.idePgtoExt:

                    s1210_idepgtoext_dados = {}
                    s1210_idepgtoext_dados['s1210_infopgto_id'] = s1210_infopgto.id

                    try:
                        s1210_idepgtoext_dados['codpais'] = read_from_xml(idePgtoExt.idePais.codPais.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['indnif'] = read_from_xml(idePgtoExt.idePais.indNIF.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['nifbenef'] = read_from_xml(idePgtoExt.idePais.nifBenef.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['dsclograd'] = read_from_xml(idePgtoExt.endExt.dscLograd.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['nrlograd'] = read_from_xml(idePgtoExt.endExt.nrLograd.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['complem'] = read_from_xml(idePgtoExt.endExt.complem.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['bairro'] = read_from_xml(idePgtoExt.endExt.bairro.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['nmcid'] = read_from_xml(idePgtoExt.endExt.nmCid.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1210_idepgtoext_dados['codpostal'] = read_from_xml(idePgtoExt.endExt.codPostal.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1210_idepgtoext = s1210idePgtoExt.objects.create(**s1210_idepgtoext_dados)
    s1210_evtpgtos_dados['evento'] = 's1210'
    s1210_evtpgtos_dados['id'] = s1210_evtpgtos.id
    s1210_evtpgtos_dados['identidade_evento'] = doc.eSocial.evtPgtos['Id']

    from emensageriapro.esocial.views.s1210_evtpgtos_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1210_evtpgtos.id)

    return s1210_evtpgtos_dados
예제 #15
0
def read_s2230_evtafasttemp_obj(request,
                                doc,
                                status,
                                validar=False,
                                arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2230_evtafasttemp_dados = {}
    s2230_evtafasttemp_dados['status'] = status
    s2230_evtafasttemp_dados['arquivo_original'] = 1
    if arquivo:
        s2230_evtafasttemp_dados['arquivo'] = arquivo.arquivo
    s2230_evtafasttemp_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2230_evtafasttemp_dados['identidade'] = doc.eSocial.evtAfastTemp['Id']
    evtAfastTemp = doc.eSocial.evtAfastTemp

    try:
        s2230_evtafasttemp_dados['indretif'] = read_from_xml(
            evtAfastTemp.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['nrrecibo'] = read_from_xml(
            evtAfastTemp.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['tpamb'] = read_from_xml(
            evtAfastTemp.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['procemi'] = read_from_xml(
            evtAfastTemp.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['verproc'] = read_from_xml(
            evtAfastTemp.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['tpinsc'] = read_from_xml(
            evtAfastTemp.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['nrinsc'] = read_from_xml(
            evtAfastTemp.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['cpftrab'] = read_from_xml(
            evtAfastTemp.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['nistrab'] = read_from_xml(
            evtAfastTemp.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['matricula'] = read_from_xml(
            evtAfastTemp.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2230_evtafasttemp_dados['codcateg'] = read_from_xml(
            evtAfastTemp.ideVinculo.codCateg.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    s2230_evtafasttemp = s2230evtAfastTemp.objects.create(
        **s2230_evtafasttemp_dados)

    if 'infoAfastamento' in dir(evtAfastTemp) and 'iniAfastamento' in dir(
            evtAfastTemp.infoAfastamento):

        for iniAfastamento in evtAfastTemp.infoAfastamento.iniAfastamento:

            s2230_iniafastamento_dados = {}
            s2230_iniafastamento_dados[
                's2230_evtafasttemp_id'] = s2230_evtafasttemp.id

            try:
                s2230_iniafastamento_dados['dtiniafast'] = read_from_xml(
                    iniAfastamento.dtIniAfast.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2230_iniafastamento_dados['codmotafast'] = read_from_xml(
                    iniAfastamento.codMotAfast.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2230_iniafastamento_dados['infomesmomtv'] = read_from_xml(
                    iniAfastamento.infoMesmoMtv.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2230_iniafastamento_dados['tpacidtransito'] = read_from_xml(
                    iniAfastamento.tpAcidTransito.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2230_iniafastamento_dados['observacao'] = read_from_xml(
                    iniAfastamento.observacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2230_iniafastamento = s2230iniAfastamento.objects.create(
                **s2230_iniafastamento_dados)

            if 'infoAtestado' in dir(iniAfastamento):

                for infoAtestado in iniAfastamento.infoAtestado:

                    s2230_infoatestado_dados = {}
                    s2230_infoatestado_dados[
                        's2230_iniafastamento_id'] = s2230_iniafastamento.id

                    try:
                        s2230_infoatestado_dados['codcid'] = read_from_xml(
                            infoAtestado.codCID.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2230_infoatestado_dados[
                            'qtddiasafast'] = read_from_xml(
                                infoAtestado.qtdDiasAfast.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    s2230_infoatestado = s2230infoAtestado.objects.create(
                        **s2230_infoatestado_dados)

                    if 'emitente' in dir(infoAtestado):

                        for emitente in infoAtestado.emitente:

                            s2230_emitente_dados = {}
                            s2230_emitente_dados[
                                's2230_infoatestado_id'] = s2230_infoatestado.id

                            try:
                                s2230_emitente_dados['nmemit'] = read_from_xml(
                                    emitente.nmEmit.cdata, 'esocial', 'C',
                                    None)
                            except AttributeError:
                                pass

                            try:
                                s2230_emitente_dados['ideoc'] = read_from_xml(
                                    emitente.ideOC.cdata, 'esocial', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                s2230_emitente_dados['nroc'] = read_from_xml(
                                    emitente.nrOc.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s2230_emitente_dados['ufoc'] = read_from_xml(
                                    emitente.ufOC.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2230_emitente = s2230emitente.objects.create(
                                **s2230_emitente_dados)

            if 'infoCessao' in dir(iniAfastamento):

                for infoCessao in iniAfastamento.infoCessao:

                    s2230_infocessao_dados = {}
                    s2230_infocessao_dados[
                        's2230_iniafastamento_id'] = s2230_iniafastamento.id

                    try:
                        s2230_infocessao_dados['cnpjcess'] = read_from_xml(
                            infoCessao.cnpjCess.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2230_infocessao_dados['infonus'] = read_from_xml(
                            infoCessao.infOnus.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s2230_infocessao = s2230infoCessao.objects.create(
                        **s2230_infocessao_dados)

            if 'infoMandSind' in dir(iniAfastamento):

                for infoMandSind in iniAfastamento.infoMandSind:

                    s2230_infomandsind_dados = {}
                    s2230_infomandsind_dados[
                        's2230_iniafastamento_id'] = s2230_iniafastamento.id

                    try:
                        s2230_infomandsind_dados['cnpjsind'] = read_from_xml(
                            infoMandSind.cnpjSind.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2230_infomandsind_dados[
                            'infonusremun'] = read_from_xml(
                                infoMandSind.infOnusRemun.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    s2230_infomandsind = s2230infoMandSind.objects.create(
                        **s2230_infomandsind_dados)

    if 'infoAfastamento' in dir(evtAfastTemp) and 'infoRetif' in dir(
            evtAfastTemp.infoAfastamento):

        for infoRetif in evtAfastTemp.infoAfastamento.infoRetif:

            s2230_inforetif_dados = {}
            s2230_inforetif_dados[
                's2230_evtafasttemp_id'] = s2230_evtafasttemp.id

            try:
                s2230_inforetif_dados['origretif'] = read_from_xml(
                    infoRetif.origRetif.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2230_inforetif_dados['tpproc'] = read_from_xml(
                    infoRetif.tpProc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2230_inforetif_dados['nrproc'] = read_from_xml(
                    infoRetif.nrProc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2230_inforetif = s2230infoRetif.objects.create(
                **s2230_inforetif_dados)

    if 'infoAfastamento' in dir(evtAfastTemp) and 'fimAfastamento' in dir(
            evtAfastTemp.infoAfastamento):

        for fimAfastamento in evtAfastTemp.infoAfastamento.fimAfastamento:

            s2230_fimafastamento_dados = {}
            s2230_fimafastamento_dados[
                's2230_evtafasttemp_id'] = s2230_evtafasttemp.id

            try:
                s2230_fimafastamento_dados['dttermafast'] = read_from_xml(
                    fimAfastamento.dtTermAfast.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            s2230_fimafastamento = s2230fimAfastamento.objects.create(
                **s2230_fimafastamento_dados)
    s2230_evtafasttemp_dados['evento'] = 's2230'
    s2230_evtafasttemp_dados['id'] = s2230_evtafasttemp.id
    s2230_evtafasttemp_dados['identidade_evento'] = doc.eSocial.evtAfastTemp[
        'Id']

    from emensageriapro.esocial.views.s2230_evtafasttemp_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2230_evtafasttemp.id)

    return s2230_evtafasttemp_dados
예제 #16
0
def read_s1260_evtcomprod_obj(request,
                              doc,
                              status,
                              validar=False,
                              arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1260_evtcomprod_dados = {}
    s1260_evtcomprod_dados['status'] = status
    s1260_evtcomprod_dados['arquivo_original'] = 1
    if arquivo:
        s1260_evtcomprod_dados['arquivo'] = arquivo.arquivo
    s1260_evtcomprod_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1260_evtcomprod_dados['identidade'] = doc.eSocial.evtComProd['Id']
    evtComProd = doc.eSocial.evtComProd

    try:
        s1260_evtcomprod_dados['indretif'] = read_from_xml(
            evtComProd.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['nrrecibo'] = read_from_xml(
            evtComProd.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['indapuracao'] = read_from_xml(
            evtComProd.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['perapur'] = read_from_xml(
            evtComProd.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['tpamb'] = read_from_xml(
            evtComProd.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['procemi'] = read_from_xml(
            evtComProd.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['verproc'] = read_from_xml(
            evtComProd.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['tpinsc'] = read_from_xml(
            evtComProd.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['nrinsc'] = read_from_xml(
            evtComProd.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1260_evtcomprod_dados['nrinscestabrural'] = read_from_xml(
            evtComProd.infoComProd.ideEstabel.nrInscEstabRural.cdata,
            'esocial', 'C', None)
    except AttributeError:
        pass

    s1260_evtcomprod = s1260evtComProd.objects.create(**s1260_evtcomprod_dados)

    if 'infoComProd' in dir(evtComProd) and 'ideEstabel' in dir(
            evtComProd.infoComProd) and 'tpComerc' in dir(
                evtComProd.infoComProd.ideEstabel):

        for tpComerc in evtComProd.infoComProd.ideEstabel.tpComerc:

            s1260_tpcomerc_dados = {}
            s1260_tpcomerc_dados['s1260_evtcomprod_id'] = s1260_evtcomprod.id

            try:
                s1260_tpcomerc_dados['indcomerc'] = read_from_xml(
                    tpComerc.indComerc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1260_tpcomerc_dados['vrtotcom'] = read_from_xml(
                    tpComerc.vrTotCom.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s1260_tpcomerc = s1260tpComerc.objects.create(
                **s1260_tpcomerc_dados)

            if 'ideAdquir' in dir(tpComerc):

                for ideAdquir in tpComerc.ideAdquir:

                    s1260_ideadquir_dados = {}
                    s1260_ideadquir_dados[
                        's1260_tpcomerc_id'] = s1260_tpcomerc.id

                    try:
                        s1260_ideadquir_dados['tpinsc'] = read_from_xml(
                            ideAdquir.tpInsc.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1260_ideadquir_dados['nrinsc'] = read_from_xml(
                            ideAdquir.nrInsc.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1260_ideadquir_dados['vrcomerc'] = read_from_xml(
                            ideAdquir.vrComerc.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s1260_ideadquir = s1260ideAdquir.objects.create(
                        **s1260_ideadquir_dados)

                    if 'nfs' in dir(ideAdquir):

                        for nfs in ideAdquir.nfs:

                            s1260_nfs_dados = {}
                            s1260_nfs_dados[
                                's1260_ideadquir_id'] = s1260_ideadquir.id

                            try:
                                s1260_nfs_dados['serie'] = read_from_xml(
                                    nfs.serie.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['nrdocto'] = read_from_xml(
                                    nfs.nrDocto.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['dtemisnf'] = read_from_xml(
                                    nfs.dtEmisNF.cdata, 'esocial', 'D', None)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['vlrbruto'] = read_from_xml(
                                    nfs.vlrBruto.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['vrcpdescpr'] = read_from_xml(
                                    nfs.vrCPDescPR.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['vrratdescpr'] = read_from_xml(
                                    nfs.vrRatDescPR.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1260_nfs_dados['vrsenardesc'] = read_from_xml(
                                    nfs.vrSenarDesc.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1260_nfs = s1260nfs.objects.create(
                                **s1260_nfs_dados)

            if 'infoProcJud' in dir(tpComerc):

                for infoProcJud in tpComerc.infoProcJud:

                    s1260_infoprocjud_dados = {}
                    s1260_infoprocjud_dados[
                        's1260_tpcomerc_id'] = s1260_tpcomerc.id

                    try:
                        s1260_infoprocjud_dados['tpproc'] = read_from_xml(
                            infoProcJud.tpProc.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1260_infoprocjud_dados['nrproc'] = read_from_xml(
                            infoProcJud.nrProc.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1260_infoprocjud_dados['codsusp'] = read_from_xml(
                            infoProcJud.codSusp.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1260_infoprocjud_dados['vrcpsusp'] = read_from_xml(
                            infoProcJud.vrCPSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1260_infoprocjud_dados['vrratsusp'] = read_from_xml(
                            infoProcJud.vrRatSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1260_infoprocjud_dados['vrsenarsusp'] = read_from_xml(
                            infoProcJud.vrSenarSusp.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s1260_infoprocjud = s1260infoProcJud.objects.create(
                        **s1260_infoprocjud_dados)
    s1260_evtcomprod_dados['evento'] = 's1260'
    s1260_evtcomprod_dados['id'] = s1260_evtcomprod.id
    s1260_evtcomprod_dados['identidade_evento'] = doc.eSocial.evtComProd['Id']

    from emensageriapro.esocial.views.s1260_evtcomprod_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1260_evtcomprod.id)

    return s1260_evtcomprod_dados
예제 #17
0
def read_r9012_evtretcons_obj(request,
                              doc,
                              status,
                              validar=False,
                              arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r9012_evtretcons_dados = {}
    r9012_evtretcons_dados['status'] = status
    r9012_evtretcons_dados['arquivo_original'] = 1
    if arquivo:
        r9012_evtretcons_dados['arquivo'] = arquivo.arquivo
    r9012_evtretcons_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r9012_evtretcons_dados['identidade'] = doc.Reinf.evtRetCons['id']
    evtRetCons = doc.Reinf.evtRetCons

    try:
        r9012_evtretcons_dados['perapur'] = read_from_xml(
            evtRetCons.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['tpinsc'] = read_from_xml(
            evtRetCons.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['nrinsc'] = read_from_xml(
            evtRetCons.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['cdretorno'] = read_from_xml(
            evtRetCons.ideRecRetorno.ideStatus.cdRetorno.cdata, 'efdreinf',
            'N', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['descretorno'] = read_from_xml(
            evtRetCons.ideRecRetorno.ideStatus.descRetorno.cdata, 'efdreinf',
            'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['nrprotentr'] = read_from_xml(
            evtRetCons.infoRecEv.nrProtEntr.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['dhprocess'] = read_from_xml(
            evtRetCons.infoRecEv.dhProcess.cdata, 'efdreinf', 'D', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['tpev'] = read_from_xml(
            evtRetCons.infoRecEv.tpEv.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['idev'] = read_from_xml(
            evtRetCons.infoRecEv.idEv.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r9012_evtretcons_dados['hash'] = read_from_xml(
            evtRetCons.infoRecEv.hash.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    r9012_evtretcons = r9012evtRetCons.objects.create(**r9012_evtretcons_dados)

    if 'ideRecRetorno' in dir(evtRetCons) and 'ideStatus' in dir(
            evtRetCons.ideRecRetorno) and 'regOcorrs' in dir(
                evtRetCons.ideRecRetorno.ideStatus):

        for regOcorrs in evtRetCons.ideRecRetorno.ideStatus.regOcorrs:

            r9012_regocorrs_dados = {}
            r9012_regocorrs_dados['r9012_evtretcons_id'] = r9012_evtretcons.id

            try:
                r9012_regocorrs_dados['tpocorr'] = read_from_xml(
                    regOcorrs.tpOcorr.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r9012_regocorrs_dados['localerroaviso'] = read_from_xml(
                    regOcorrs.localErroAviso.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r9012_regocorrs_dados['codresp'] = read_from_xml(
                    regOcorrs.codResp.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r9012_regocorrs_dados['dscresp'] = read_from_xml(
                    regOcorrs.dscResp.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            r9012_regocorrs = r9012regOcorrs.objects.create(
                **r9012_regocorrs_dados)

    if 'infoTotalContrib' in dir(evtRetCons):

        for infoTotalContrib in evtRetCons.infoTotalContrib:

            r9012_infototalcontrib_dados = {}
            r9012_infototalcontrib_dados[
                'r9012_evtretcons_id'] = r9012_evtretcons.id

            try:
                r9012_infototalcontrib_dados['nrrecarqbase'] = read_from_xml(
                    infoTotalContrib.nrRecArqBase.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r9012_infototalcontrib_dados['indexistinfo'] = read_from_xml(
                    infoTotalContrib.indExistInfo.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            r9012_infototalcontrib = r9012infoTotalContrib.objects.create(
                **r9012_infototalcontrib_dados)

            if 'totApurMen' in dir(infoTotalContrib):

                for totApurMen in infoTotalContrib.totApurMen:

                    r9012_totapurmen_dados = {}
                    r9012_totapurmen_dados[
                        'r9012_infototalcontrib_id'] = r9012_infototalcontrib.id

                    try:
                        r9012_totapurmen_dados['crmen'] = read_from_xml(
                            totApurMen.CRMen.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurmen_dados['vlrbasecrmen'] = read_from_xml(
                            totApurMen.vlrBaseCRMen.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurmen_dados['vlrcrmen'] = read_from_xml(
                            totApurMen.vlrCRMen.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurmen_dados[
                            'vlrbasecrmensusp'] = read_from_xml(
                                totApurMen.vlrBaseCRMenSusp.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurmen_dados['vlrcrmensusp'] = read_from_xml(
                            totApurMen.vlrCRMenSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r9012_totapurmen = r9012totApurMen.objects.create(
                        **r9012_totapurmen_dados)

            if 'totApurQui' in dir(infoTotalContrib):

                for totApurQui in infoTotalContrib.totApurQui:

                    r9012_totapurqui_dados = {}
                    r9012_totapurqui_dados[
                        'r9012_infototalcontrib_id'] = r9012_infototalcontrib.id

                    try:
                        r9012_totapurqui_dados['perapurqui'] = read_from_xml(
                            totApurQui.perApurQui.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurqui_dados['crqui'] = read_from_xml(
                            totApurQui.CRQui.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurqui_dados['vlrbasecrqui'] = read_from_xml(
                            totApurQui.vlrBaseCRQui.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurqui_dados['vlrcrqui'] = read_from_xml(
                            totApurQui.vlrCRQui.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurqui_dados[
                            'vlrbasecrquisusp'] = read_from_xml(
                                totApurQui.vlrBaseCRQuiSusp.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurqui_dados['vlrcrquisusp'] = read_from_xml(
                            totApurQui.vlrCRQuiSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r9012_totapurqui = r9012totApurQui.objects.create(
                        **r9012_totapurqui_dados)

            if 'totApurDec' in dir(infoTotalContrib):

                for totApurDec in infoTotalContrib.totApurDec:

                    r9012_totapurdec_dados = {}
                    r9012_totapurdec_dados[
                        'r9012_infototalcontrib_id'] = r9012_infototalcontrib.id

                    try:
                        r9012_totapurdec_dados['perapurdec'] = read_from_xml(
                            totApurDec.perApurDec.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdec_dados['crdec'] = read_from_xml(
                            totApurDec.CRDec.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdec_dados['vlrbasecrdec'] = read_from_xml(
                            totApurDec.vlrBaseCRDec.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdec_dados['vlrcrdec'] = read_from_xml(
                            totApurDec.vlrCRDec.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdec_dados[
                            'vlrbasecrdecsusp'] = read_from_xml(
                                totApurDec.vlrBaseCRDecSusp.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdec_dados['vlrcrdecsusp'] = read_from_xml(
                            totApurDec.vlrCRDecSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r9012_totapurdec = r9012totApurDec.objects.create(
                        **r9012_totapurdec_dados)

            if 'totApurSem' in dir(infoTotalContrib):

                for totApurSem in infoTotalContrib.totApurSem:

                    r9012_totapursem_dados = {}
                    r9012_totapursem_dados[
                        'r9012_infototalcontrib_id'] = r9012_infototalcontrib.id

                    try:
                        r9012_totapursem_dados['perapursem'] = read_from_xml(
                            totApurSem.perApurSem.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapursem_dados['crsem'] = read_from_xml(
                            totApurSem.CRSem.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapursem_dados['vlrbasecrsem'] = read_from_xml(
                            totApurSem.vlrBaseCRSem.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapursem_dados['vlrcrsem'] = read_from_xml(
                            totApurSem.vlrCRSem.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapursem_dados[
                            'vlrbasecrsemsusp'] = read_from_xml(
                                totApurSem.vlrBaseCRSemSusp.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapursem_dados['vlrcrsemsusp'] = read_from_xml(
                            totApurSem.vlrCRSemSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r9012_totapursem = r9012totApurSem.objects.create(
                        **r9012_totapursem_dados)

            if 'totApurDia' in dir(infoTotalContrib):

                for totApurDia in infoTotalContrib.totApurDia:

                    r9012_totapurdia_dados = {}
                    r9012_totapurdia_dados[
                        'r9012_infototalcontrib_id'] = r9012_infototalcontrib.id

                    try:
                        r9012_totapurdia_dados['perapurdia'] = read_from_xml(
                            totApurDia.perApurDia.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdia_dados['crdia'] = read_from_xml(
                            totApurDia.CRDia.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdia_dados['vlrbasecrdia'] = read_from_xml(
                            totApurDia.vlrBaseCRDia.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdia_dados['vlrcrdia'] = read_from_xml(
                            totApurDia.vlrCRDia.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdia_dados[
                            'vlrbasecrdiasusp'] = read_from_xml(
                                totApurDia.vlrBaseCRDiaSusp.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r9012_totapurdia_dados['vlrcrdiasusp'] = read_from_xml(
                            totApurDia.vlrCRDiaSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r9012_totapurdia = r9012totApurDia.objects.create(
                        **r9012_totapurdia_dados)
    r9012_evtretcons_dados['evento'] = 'r9012'
    r9012_evtretcons_dados['id'] = r9012_evtretcons.id
    r9012_evtretcons_dados['identidade_evento'] = doc.Reinf.evtRetCons['id']

    from emensageriapro.efdreinf.views.r9012_evtretcons_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r9012_evtretcons.id)

    return r9012_evtretcons_dados
예제 #18
0
def read_s1250_evtaqprod_obj(request,
                             doc,
                             status,
                             validar=False,
                             arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1250_evtaqprod_dados = {}
    s1250_evtaqprod_dados['status'] = status
    s1250_evtaqprod_dados['arquivo_original'] = 1
    if arquivo:
        s1250_evtaqprod_dados['arquivo'] = arquivo.arquivo
    s1250_evtaqprod_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1250_evtaqprod_dados['identidade'] = doc.eSocial.evtAqProd['Id']
    evtAqProd = doc.eSocial.evtAqProd

    try:
        s1250_evtaqprod_dados['indretif'] = read_from_xml(
            evtAqProd.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['nrrecibo'] = read_from_xml(
            evtAqProd.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['indapuracao'] = read_from_xml(
            evtAqProd.ideEvento.indApuracao.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['perapur'] = read_from_xml(
            evtAqProd.ideEvento.perApur.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['tpamb'] = read_from_xml(
            evtAqProd.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['procemi'] = read_from_xml(
            evtAqProd.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['verproc'] = read_from_xml(
            evtAqProd.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['tpinsc'] = read_from_xml(
            evtAqProd.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['nrinsc'] = read_from_xml(
            evtAqProd.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['tpinscadq'] = read_from_xml(
            evtAqProd.infoAquisProd.ideEstabAdquir.tpInscAdq.cdata, 'esocial',
            'N', None)
    except AttributeError:
        pass

    try:
        s1250_evtaqprod_dados['nrinscadq'] = read_from_xml(
            evtAqProd.infoAquisProd.ideEstabAdquir.nrInscAdq.cdata, 'esocial',
            'C', None)
    except AttributeError:
        pass

    s1250_evtaqprod = s1250evtAqProd.objects.create(**s1250_evtaqprod_dados)

    if 'infoAquisProd' in dir(evtAqProd) and 'ideEstabAdquir' in dir(
            evtAqProd.infoAquisProd) and 'tpAquis' in dir(
                evtAqProd.infoAquisProd.ideEstabAdquir):

        for tpAquis in evtAqProd.infoAquisProd.ideEstabAdquir.tpAquis:

            s1250_tpaquis_dados = {}
            s1250_tpaquis_dados['s1250_evtaqprod_id'] = s1250_evtaqprod.id

            try:
                s1250_tpaquis_dados['indaquis'] = read_from_xml(
                    tpAquis.indAquis.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1250_tpaquis_dados['vlrtotaquis'] = read_from_xml(
                    tpAquis.vlrTotAquis.cdata, 'esocial', 'N', 2)
            except AttributeError:
                pass

            s1250_tpaquis = s1250tpAquis.objects.create(**s1250_tpaquis_dados)

            if 'ideProdutor' in dir(tpAquis):

                for ideProdutor in tpAquis.ideProdutor:

                    s1250_ideprodutor_dados = {}
                    s1250_ideprodutor_dados[
                        's1250_tpaquis_id'] = s1250_tpaquis.id

                    try:
                        s1250_ideprodutor_dados['tpinscprod'] = read_from_xml(
                            ideProdutor.tpInscProd.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['nrinscprod'] = read_from_xml(
                            ideProdutor.nrInscProd.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['vlrbruto'] = read_from_xml(
                            ideProdutor.vlrBruto.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['vrcpdescpr'] = read_from_xml(
                            ideProdutor.vrCPDescPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['vrratdescpr'] = read_from_xml(
                            ideProdutor.vrRatDescPR.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['vrsenardesc'] = read_from_xml(
                            ideProdutor.vrSenarDesc.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_ideprodutor_dados['indopccp'] = read_from_xml(
                            ideProdutor.indOpcCP.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s1250_ideprodutor = s1250ideProdutor.objects.create(
                        **s1250_ideprodutor_dados)

                    if 'nfs' in dir(ideProdutor):

                        for nfs in ideProdutor.nfs:

                            s1250_nfs_dados = {}
                            s1250_nfs_dados[
                                's1250_ideprodutor_id'] = s1250_ideprodutor.id

                            try:
                                s1250_nfs_dados['serie'] = read_from_xml(
                                    nfs.serie.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['nrdocto'] = read_from_xml(
                                    nfs.nrDocto.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['dtemisnf'] = read_from_xml(
                                    nfs.dtEmisNF.cdata, 'esocial', 'D', None)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['vlrbruto'] = read_from_xml(
                                    nfs.vlrBruto.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['vrcpdescpr'] = read_from_xml(
                                    nfs.vrCPDescPR.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['vrratdescpr'] = read_from_xml(
                                    nfs.vrRatDescPR.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1250_nfs_dados['vrsenardesc'] = read_from_xml(
                                    nfs.vrSenarDesc.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1250_nfs = s1250nfs.objects.create(
                                **s1250_nfs_dados)

                    if 'infoProcJud' in dir(ideProdutor):

                        for infoProcJud in ideProdutor.infoProcJud:

                            s1250_infoprocjud_dados = {}
                            s1250_infoprocjud_dados[
                                's1250_ideprodutor_id'] = s1250_ideprodutor.id

                            try:
                                s1250_infoprocjud_dados[
                                    'nrprocjud'] = read_from_xml(
                                        infoProcJud.nrProcJud.cdata, 'esocial',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1250_infoprocjud_dados[
                                    'codsusp'] = read_from_xml(
                                        infoProcJud.codSusp.cdata, 'esocial',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                s1250_infoprocjud_dados[
                                    'vrcpnret'] = read_from_xml(
                                        infoProcJud.vrCPNRet.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1250_infoprocjud_dados[
                                    'vrratnret'] = read_from_xml(
                                        infoProcJud.vrRatNRet.cdata, 'esocial',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                s1250_infoprocjud_dados[
                                    'vrsenarnret'] = read_from_xml(
                                        infoProcJud.vrSenarNRet.cdata,
                                        'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s1250_infoprocjud = s1250infoProcJud.objects.create(
                                **s1250_infoprocjud_dados)

            if 'infoProcJ' in dir(tpAquis):

                for infoProcJ in tpAquis.infoProcJ:

                    s1250_infoprocj_dados = {}
                    s1250_infoprocj_dados[
                        's1250_tpaquis_id'] = s1250_tpaquis.id

                    try:
                        s1250_infoprocj_dados['nrprocjud'] = read_from_xml(
                            infoProcJ.nrProcJud.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1250_infoprocj_dados['codsusp'] = read_from_xml(
                            infoProcJ.codSusp.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1250_infoprocj_dados['vrcpnret'] = read_from_xml(
                            infoProcJ.vrCPNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_infoprocj_dados['vrratnret'] = read_from_xml(
                            infoProcJ.vrRatNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        s1250_infoprocj_dados['vrsenarnret'] = read_from_xml(
                            infoProcJ.vrSenarNRet.cdata, 'esocial', 'N', 2)
                    except AttributeError:
                        pass

                    s1250_infoprocj = s1250infoProcJ.objects.create(
                        **s1250_infoprocj_dados)
    s1250_evtaqprod_dados['evento'] = 's1250'
    s1250_evtaqprod_dados['id'] = s1250_evtaqprod.id
    s1250_evtaqprod_dados['identidade_evento'] = doc.eSocial.evtAqProd['Id']

    from emensageriapro.esocial.views.s1250_evtaqprod_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1250_evtaqprod.id)

    return s1250_evtaqprod_dados
예제 #19
0
def read_r2050_evtcomprod_obj(request,
                              doc,
                              status,
                              validar=False,
                              arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r2050_evtcomprod_dados = {}
    r2050_evtcomprod_dados['status'] = status
    r2050_evtcomprod_dados['arquivo_original'] = 1
    if arquivo:
        r2050_evtcomprod_dados['arquivo'] = arquivo.arquivo
    r2050_evtcomprod_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r2050_evtcomprod_dados['identidade'] = doc.Reinf.evtComProd['id']
    evtComProd = doc.Reinf.evtComProd

    try:
        r2050_evtcomprod_dados['indretif'] = read_from_xml(
            evtComProd.ideEvento.indRetif.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['nrrecibo'] = read_from_xml(
            evtComProd.ideEvento.nrRecibo.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['perapur'] = read_from_xml(
            evtComProd.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['tpamb'] = read_from_xml(
            evtComProd.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['procemi'] = read_from_xml(
            evtComProd.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['verproc'] = read_from_xml(
            evtComProd.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['tpinsc'] = read_from_xml(
            evtComProd.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['nrinsc'] = read_from_xml(
            evtComProd.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['tpinscestab'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.tpInscEstab.cdata, 'efdreinf', 'N',
            None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['nrinscestab'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.nrInscEstab.cdata, 'efdreinf', 'C',
            None)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrrecbrutatotal'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrRecBrutaTotal.cdata, 'efdreinf',
            'N', 2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrcpapur'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrCPApur.cdata, 'efdreinf', 'N',
            2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrratapur'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrRatApur.cdata, 'efdreinf', 'N',
            2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrsenarapur'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrSenarApur.cdata, 'efdreinf',
            'N', 2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrcpsusptotal'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrCPSuspTotal.cdata, 'efdreinf',
            'N', 2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrratsusptotal'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrRatSuspTotal.cdata, 'efdreinf',
            'N', 2)
    except AttributeError:
        pass

    try:
        r2050_evtcomprod_dados['vlrsenarsusptotal'] = read_from_xml(
            evtComProd.infoComProd.ideEstab.vlrSenarSuspTotal.cdata,
            'efdreinf', 'N', 2)
    except AttributeError:
        pass

    r2050_evtcomprod = r2050evtComProd.objects.create(**r2050_evtcomprod_dados)

    if 'infoComProd' in dir(evtComProd) and 'ideEstab' in dir(
            evtComProd.infoComProd) and 'tipoCom' in dir(
                evtComProd.infoComProd.ideEstab):

        for tipoCom in evtComProd.infoComProd.ideEstab.tipoCom:

            r2050_tipocom_dados = {}
            r2050_tipocom_dados['r2050_evtcomprod_id'] = r2050_evtcomprod.id

            try:
                r2050_tipocom_dados['indcom'] = read_from_xml(
                    tipoCom.indCom.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r2050_tipocom_dados['vlrrecbruta'] = read_from_xml(
                    tipoCom.vlrRecBruta.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r2050_tipocom = r2050tipoCom.objects.create(**r2050_tipocom_dados)

            if 'infoProc' in dir(tipoCom):

                for infoProc in tipoCom.infoProc:

                    r2050_infoproc_dados = {}
                    r2050_infoproc_dados['r2050_tipocom_id'] = r2050_tipocom.id

                    try:
                        r2050_infoproc_dados['tpproc'] = read_from_xml(
                            infoProc.tpProc.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2050_infoproc_dados['nrproc'] = read_from_xml(
                            infoProc.nrProc.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r2050_infoproc_dados['codsusp'] = read_from_xml(
                            infoProc.codSusp.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r2050_infoproc_dados['vlrcpsusp'] = read_from_xml(
                            infoProc.vlrCPSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2050_infoproc_dados['vlrratsusp'] = read_from_xml(
                            infoProc.vlrRatSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r2050_infoproc_dados['vlrsenarsusp'] = read_from_xml(
                            infoProc.vlrSenarSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r2050_infoproc = r2050infoProc.objects.create(
                        **r2050_infoproc_dados)
    r2050_evtcomprod_dados['evento'] = 'r2050'
    r2050_evtcomprod_dados['id'] = r2050_evtcomprod.id
    r2050_evtcomprod_dados['identidade_evento'] = doc.Reinf.evtComProd['id']

    from emensageriapro.efdreinf.views.r2050_evtcomprod_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r2050_evtcomprod.id)

    return r2050_evtcomprod_dados
예제 #20
0
def read_s2240_evtexprisco_obj(request,
                               doc,
                               status,
                               validar=False,
                               arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2240_evtexprisco_dados = {}
    s2240_evtexprisco_dados['status'] = status
    s2240_evtexprisco_dados['arquivo_original'] = 1
    if arquivo:
        s2240_evtexprisco_dados['arquivo'] = arquivo.arquivo
    s2240_evtexprisco_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2240_evtexprisco_dados['identidade'] = doc.eSocial.evtExpRisco['Id']
    evtExpRisco = doc.eSocial.evtExpRisco

    try:
        s2240_evtexprisco_dados['indretif'] = read_from_xml(
            evtExpRisco.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['nrrecibo'] = read_from_xml(
            evtExpRisco.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['tpamb'] = read_from_xml(
            evtExpRisco.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['procemi'] = read_from_xml(
            evtExpRisco.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['verproc'] = read_from_xml(
            evtExpRisco.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['tpinsc'] = read_from_xml(
            evtExpRisco.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['nrinsc'] = read_from_xml(
            evtExpRisco.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['cpftrab'] = read_from_xml(
            evtExpRisco.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['nistrab'] = read_from_xml(
            evtExpRisco.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['matricula'] = read_from_xml(
            evtExpRisco.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['codcateg'] = read_from_xml(
            evtExpRisco.ideVinculo.codCateg.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['dtinicondicao'] = read_from_xml(
            evtExpRisco.infoExpRisco.dtIniCondicao.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2240_evtexprisco_dados['dscativdes'] = read_from_xml(
            evtExpRisco.infoExpRisco.infoAtiv.dscAtivDes.cdata, 'esocial', 'C',
            None)
    except AttributeError:
        pass

    s2240_evtexprisco = s2240evtExpRisco.objects.create(
        **s2240_evtexprisco_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'infoAmb' in dir(
            evtExpRisco.infoExpRisco):

        for infoAmb in evtExpRisco.infoExpRisco.infoAmb:

            s2240_iniexprisco_infoamb_dados = {}
            s2240_iniexprisco_infoamb_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_iniexprisco_infoamb_dados['codamb'] = read_from_xml(
                    infoAmb.codAmb.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2240_iniexprisco_infoamb = s2240iniExpRiscoinfoAmb.objects.create(
                **s2240_iniexprisco_infoamb_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'infoAtiv' in dir(
            evtExpRisco.infoExpRisco) and 'ativPericInsal' in dir(
                evtExpRisco.infoExpRisco.infoAtiv):

        for ativPericInsal in evtExpRisco.infoExpRisco.infoAtiv.ativPericInsal:

            s2240_iniexprisco_ativpericinsal_dados = {}
            s2240_iniexprisco_ativpericinsal_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_iniexprisco_ativpericinsal_dados[
                    'codativ'] = read_from_xml(ativPericInsal.codAtiv.cdata,
                                               'esocial', 'C', None)
            except AttributeError:
                pass

            s2240_iniexprisco_ativpericinsal = s2240iniExpRiscoativPericInsal.objects.create(
                **s2240_iniexprisco_ativpericinsal_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'fatRisco' in dir(
            evtExpRisco.infoExpRisco):

        for fatRisco in evtExpRisco.infoExpRisco.fatRisco:

            s2240_iniexprisco_fatrisco_dados = {}
            s2240_iniexprisco_fatrisco_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_iniexprisco_fatrisco_dados['codfatris'] = read_from_xml(
                    fatRisco.codFatRis.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['dscfatrisc'] = read_from_xml(
                    fatRisco.dscFatRisc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['tpaval'] = read_from_xml(
                    fatRisco.tpAval.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['intconc'] = read_from_xml(
                    fatRisco.intConc.cdata, 'esocial', 'N', 4)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['limtol'] = read_from_xml(
                    fatRisco.limTol.cdata, 'esocial', 'N', 4)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['unmed'] = read_from_xml(
                    fatRisco.unMed.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['tecmedicao'] = read_from_xml(
                    fatRisco.tecMedicao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados[
                    'insalubridade'] = read_from_xml(
                        fatRisco.insalubridade.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados[
                    'periculosidade'] = read_from_xml(
                        fatRisco.periculosidade.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['aposentesp'] = read_from_xml(
                    fatRisco.aposentEsp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['utilizepc'] = read_from_xml(
                    fatRisco.epcEpi.utilizEPC.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['eficepc'] = read_from_xml(
                    fatRisco.epcEpi.eficEpc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_fatrisco_dados['utilizepi'] = read_from_xml(
                    fatRisco.epcEpi.utilizEPI.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s2240_iniexprisco_fatrisco = s2240iniExpRiscofatRisco.objects.create(
                **s2240_iniexprisco_fatrisco_dados)

            if 'epcEpi' in dir(fatRisco) and 'epc' in dir(fatRisco.epcEpi):

                for epc in fatRisco.epcEpi.epc:

                    s2240_iniexprisco_epc_dados = {}
                    s2240_iniexprisco_epc_dados[
                        's2240_iniexprisco_fatrisco_id'] = s2240_iniexprisco_fatrisco.id

                    try:
                        s2240_iniexprisco_epc_dados['codep'] = read_from_xml(
                            epc.codEP.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epc_dados['dscepc'] = read_from_xml(
                            epc.dscEpc.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epc_dados['eficepc'] = read_from_xml(
                            epc.eficEpc.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s2240_iniexprisco_epc = s2240iniExpRiscoepc.objects.create(
                        **s2240_iniexprisco_epc_dados)

            if 'epcEpi' in dir(fatRisco) and 'epi' in dir(fatRisco.epcEpi):

                for epi in fatRisco.epcEpi.epi:

                    s2240_iniexprisco_epi_dados = {}
                    s2240_iniexprisco_epi_dados[
                        's2240_iniexprisco_fatrisco_id'] = s2240_iniexprisco_fatrisco.id

                    try:
                        s2240_iniexprisco_epi_dados['caepi'] = read_from_xml(
                            epi.caEPI.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados['dscepi'] = read_from_xml(
                            epi.dscEPI.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados['eficepi'] = read_from_xml(
                            epi.eficEpi.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'medprotecao'] = read_from_xml(
                                epi.medProtecao.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'condfuncto'] = read_from_xml(
                                epi.condFuncto.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'usoinint'] = read_from_xml(
                                epi.usoInint.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'przvalid'] = read_from_xml(
                                epi.przValid.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'periodictroca'] = read_from_xml(
                                epi.periodicTroca.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_iniexprisco_epi_dados[
                            'higienizacao'] = read_from_xml(
                                epi.higienizacao.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s2240_iniexprisco_epi = s2240iniExpRiscoepi.objects.create(
                        **s2240_iniexprisco_epi_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'respReg' in dir(
            evtExpRisco.infoExpRisco):

        for respReg in evtExpRisco.infoExpRisco.respReg:

            s2240_iniexprisco_respreg_dados = {}
            s2240_iniexprisco_respreg_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_iniexprisco_respreg_dados['cpfresp'] = read_from_xml(
                    respReg.cpfResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['nisresp'] = read_from_xml(
                    respReg.nisResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['nmresp'] = read_from_xml(
                    respReg.nmResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['ideoc'] = read_from_xml(
                    respReg.ideOC.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['dscoc'] = read_from_xml(
                    respReg.dscOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['nroc'] = read_from_xml(
                    respReg.nrOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_respreg_dados['ufoc'] = read_from_xml(
                    respReg.ufOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2240_iniexprisco_respreg = s2240iniExpRiscorespReg.objects.create(
                **s2240_iniexprisco_respreg_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'obs' in dir(
            evtExpRisco.infoExpRisco):

        for obs in evtExpRisco.infoExpRisco.obs:

            s2240_iniexprisco_obs_dados = {}
            s2240_iniexprisco_obs_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_iniexprisco_obs_dados['meterg'] = read_from_xml(
                    obs.metErg.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_obs_dados['obscompl'] = read_from_xml(
                    obs.obsCompl.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_iniexprisco_obs_dados['observacao'] = read_from_xml(
                    obs.observacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2240_iniexprisco_obs = s2240iniExpRiscoobs.objects.create(
                **s2240_iniexprisco_obs_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'altExpRisco' in dir(
            evtExpRisco.infoExpRisco):

        for altExpRisco in evtExpRisco.infoExpRisco.altExpRisco:

            s2240_altexprisco_dados = {}
            s2240_altexprisco_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_altexprisco_dados['dtaltcondicao'] = read_from_xml(
                    altExpRisco.dtAltCondicao.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            s2240_altexprisco = s2240altExpRisco.objects.create(
                **s2240_altexprisco_dados)

            if 'infoAmb' in dir(altExpRisco):

                for infoAmb in altExpRisco.infoAmb:

                    s2240_altexprisco_infoamb_dados = {}
                    s2240_altexprisco_infoamb_dados[
                        's2240_altexprisco_id'] = s2240_altexprisco.id

                    try:
                        s2240_altexprisco_infoamb_dados[
                            'codamb'] = read_from_xml(infoAmb.codAmb.cdata,
                                                      'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2240_altexprisco_infoamb_dados[
                            'dscativdes'] = read_from_xml(
                                infoAmb.infoAtiv.dscAtivDes.cdata, 'esocial',
                                'C', None)
                    except AttributeError:
                        pass

                    s2240_altexprisco_infoamb = s2240altExpRiscoinfoAmb.objects.create(
                        **s2240_altexprisco_infoamb_dados)

                    if 'fatRisco' in dir(infoAmb):

                        for fatRisco in infoAmb.fatRisco:

                            s2240_altexprisco_fatrisco_dados = {}
                            s2240_altexprisco_fatrisco_dados[
                                's2240_altexprisco_infoamb_id'] = s2240_altexprisco_infoamb.id

                            try:
                                s2240_altexprisco_fatrisco_dados[
                                    'codfatris'] = read_from_xml(
                                        fatRisco.codFatRis.cdata, 'esocial',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                s2240_altexprisco_fatrisco_dados[
                                    'intconc'] = read_from_xml(
                                        fatRisco.intConc.cdata, 'esocial', 'C',
                                        None)
                            except AttributeError:
                                pass

                            try:
                                s2240_altexprisco_fatrisco_dados[
                                    'tecmedicao'] = read_from_xml(
                                        fatRisco.tecMedicao.cdata, 'esocial',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                s2240_altexprisco_fatrisco_dados[
                                    'utilizepc'] = read_from_xml(
                                        fatRisco.epcEpi.utilizEPC.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                s2240_altexprisco_fatrisco_dados[
                                    'utilizepi'] = read_from_xml(
                                        fatRisco.epcEpi.utilizEPI.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            s2240_altexprisco_fatrisco = s2240altExpRiscofatRisco.objects.create(
                                **s2240_altexprisco_fatrisco_dados)

                            if 'epcEpi' in dir(fatRisco) and 'epc' in dir(
                                    fatRisco.epcEpi):

                                for epc in fatRisco.epcEpi.epc:

                                    s2240_altexprisco_epc_dados = {}
                                    s2240_altexprisco_epc_dados[
                                        's2240_altexprisco_fatrisco_id'] = s2240_altexprisco_fatrisco.id

                                    try:
                                        s2240_altexprisco_epc_dados[
                                            'dscepc'] = read_from_xml(
                                                epc.dscEpc.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epc_dados[
                                            'eficepc'] = read_from_xml(
                                                epc.eficEpc.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    s2240_altexprisco_epc = s2240altExpRiscoepc.objects.create(
                                        **s2240_altexprisco_epc_dados)

                            if 'epcEpi' in dir(fatRisco) and 'epi' in dir(
                                    fatRisco.epcEpi):

                                for epi in fatRisco.epcEpi.epi:

                                    s2240_altexprisco_epi_dados = {}
                                    s2240_altexprisco_epi_dados[
                                        's2240_altexprisco_fatrisco_id'] = s2240_altexprisco_fatrisco.id

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'caepi'] = read_from_xml(
                                                epi.caEPI.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'eficepi'] = read_from_xml(
                                                epi.eficEpi.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'medprotecao'] = read_from_xml(
                                                epi.medProtecao.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'condfuncto'] = read_from_xml(
                                                epi.condFuncto.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'przvalid'] = read_from_xml(
                                                epi.przValid.cdata, 'esocial',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'periodictroca'] = read_from_xml(
                                                epi.periodicTroca.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        s2240_altexprisco_epi_dados[
                                            'higienizacao'] = read_from_xml(
                                                epi.higienizacao.cdata,
                                                'esocial', 'C', None)
                                    except AttributeError:
                                        pass

                                    s2240_altexprisco_epi = s2240altExpRiscoepi.objects.create(
                                        **s2240_altexprisco_epi_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'fimExpRisco' in dir(
            evtExpRisco.infoExpRisco):

        for fimExpRisco in evtExpRisco.infoExpRisco.fimExpRisco:

            s2240_fimexprisco_dados = {}
            s2240_fimexprisco_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_fimexprisco_dados['dtfimcondicao'] = read_from_xml(
                    fimExpRisco.dtFimCondicao.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            s2240_fimexprisco = s2240fimExpRisco.objects.create(
                **s2240_fimexprisco_dados)

            if 'infoAmb' in dir(fimExpRisco):

                for infoAmb in fimExpRisco.infoAmb:

                    s2240_fimexprisco_infoamb_dados = {}
                    s2240_fimexprisco_infoamb_dados[
                        's2240_fimexprisco_id'] = s2240_fimexprisco.id

                    try:
                        s2240_fimexprisco_infoamb_dados[
                            'codamb'] = read_from_xml(infoAmb.codAmb.cdata,
                                                      'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s2240_fimexprisco_infoamb = s2240fimExpRiscoinfoAmb.objects.create(
                        **s2240_fimexprisco_infoamb_dados)

    if 'infoExpRisco' in dir(evtExpRisco) and 'respReg' in dir(
            evtExpRisco.infoExpRisco):

        for respReg in evtExpRisco.infoExpRisco.respReg:

            s2240_fimexprisco_respreg_dados = {}
            s2240_fimexprisco_respreg_dados[
                's2240_evtexprisco_id'] = s2240_evtexprisco.id

            try:
                s2240_fimexprisco_respreg_dados['dtini'] = read_from_xml(
                    respReg.dtIni.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2240_fimexprisco_respreg_dados['dtfim'] = read_from_xml(
                    respReg.dtFim.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2240_fimexprisco_respreg_dados['nisresp'] = read_from_xml(
                    respReg.nisResp.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_fimexprisco_respreg_dados['nroc'] = read_from_xml(
                    respReg.nrOc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2240_fimexprisco_respreg_dados['ufoc'] = read_from_xml(
                    respReg.ufOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2240_fimexprisco_respreg = s2240fimExpRiscorespReg.objects.create(
                **s2240_fimexprisco_respreg_dados)
    s2240_evtexprisco_dados['evento'] = 's2240'
    s2240_evtexprisco_dados['id'] = s2240_evtexprisco.id
    s2240_evtexprisco_dados['identidade_evento'] = doc.eSocial.evtExpRisco[
        'Id']

    from emensageriapro.esocial.views.s2240_evtexprisco_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2240_evtexprisco.id)

    return s2240_evtexprisco_dados
예제 #21
0
def read_s2210_evtcat_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2210_evtcat_dados = {}
    s2210_evtcat_dados['status'] = status
    s2210_evtcat_dados['arquivo_original'] = 1
    if arquivo:
        s2210_evtcat_dados['arquivo'] = arquivo.arquivo
    s2210_evtcat_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2210_evtcat_dados['identidade'] = doc.eSocial.evtCAT['Id']
    evtCAT = doc.eSocial.evtCAT

    try:
        s2210_evtcat_dados['indretif'] = read_from_xml(
            evtCAT.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['nrrecibo'] = read_from_xml(
            evtCAT.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tpamb'] = read_from_xml(
            evtCAT.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['procemi'] = read_from_xml(
            evtCAT.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['verproc'] = read_from_xml(
            evtCAT.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tpinsc'] = read_from_xml(
            evtCAT.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['nrinsc'] = read_from_xml(
            evtCAT.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['cpftrab'] = read_from_xml(
            evtCAT.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['nistrab'] = read_from_xml(
            evtCAT.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['matricula'] = read_from_xml(
            evtCAT.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['codcateg'] = read_from_xml(
            evtCAT.ideVinculo.codCateg.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['dtacid'] = read_from_xml(evtCAT.cat.dtAcid.cdata,
                                                     'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tpacid'] = read_from_xml(evtCAT.cat.tpAcid.cdata,
                                                     'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['hracid'] = read_from_xml(evtCAT.cat.hrAcid.cdata,
                                                     'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['hrstrabantesacid'] = read_from_xml(
            evtCAT.cat.hrsTrabAntesAcid.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tpcat'] = read_from_xml(evtCAT.cat.tpCat.cdata,
                                                    'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['indcatobito'] = read_from_xml(
            evtCAT.cat.indCatObito.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['dtobito'] = read_from_xml(evtCAT.cat.dtObito.cdata,
                                                      'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['indcomunpolicia'] = read_from_xml(
            evtCAT.cat.indComunPolicia.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['codsitgeradora'] = read_from_xml(
            evtCAT.cat.codSitGeradora.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['iniciatcat'] = read_from_xml(
            evtCAT.cat.iniciatCAT.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['obscat'] = read_from_xml(evtCAT.cat.obsCAT.cdata,
                                                     'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['observacao'] = read_from_xml(
            evtCAT.cat.observacao.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tplocal'] = read_from_xml(
            evtCAT.cat.localAcidente.tpLocal.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['dsclocal'] = read_from_xml(
            evtCAT.cat.localAcidente.dscLocal.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['codamb'] = read_from_xml(
            evtCAT.cat.localAcidente.codAmb.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['tplograd'] = read_from_xml(
            evtCAT.cat.localAcidente.tpLograd.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['dsclograd'] = read_from_xml(
            evtCAT.cat.localAcidente.dscLograd.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['nrlograd'] = read_from_xml(
            evtCAT.cat.localAcidente.nrLograd.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['complemento'] = read_from_xml(
            evtCAT.cat.localAcidente.complemento.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['bairro'] = read_from_xml(
            evtCAT.cat.localAcidente.bairro.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['cep'] = read_from_xml(
            evtCAT.cat.localAcidente.cep.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['codmunic'] = read_from_xml(
            evtCAT.cat.localAcidente.codMunic.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['uf'] = read_from_xml(
            evtCAT.cat.localAcidente.uf.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['pais'] = read_from_xml(
            evtCAT.cat.localAcidente.pais.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2210_evtcat_dados['codpostal'] = read_from_xml(
            evtCAT.cat.localAcidente.codPostal.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s2210_evtcat = s2210evtCAT.objects.create(**s2210_evtcat_dados)

    if 'cat' in dir(evtCAT) and 'localAcidente' in dir(
            evtCAT.cat) and 'ideLocalAcid' in dir(evtCAT.cat.localAcidente):

        for ideLocalAcid in evtCAT.cat.localAcidente.ideLocalAcid:

            s2210_idelocalacid_dados = {}
            s2210_idelocalacid_dados['s2210_evtcat_id'] = s2210_evtcat.id

            try:
                s2210_idelocalacid_dados['tpinsc'] = read_from_xml(
                    ideLocalAcid.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2210_idelocalacid_dados['nrinsc'] = read_from_xml(
                    ideLocalAcid.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2210_idelocalacid = s2210ideLocalAcid.objects.create(
                **s2210_idelocalacid_dados)

    if 'cat' in dir(evtCAT) and 'parteAtingida' in dir(evtCAT.cat):

        for parteAtingida in evtCAT.cat.parteAtingida:

            s2210_parteatingida_dados = {}
            s2210_parteatingida_dados['s2210_evtcat_id'] = s2210_evtcat.id

            try:
                s2210_parteatingida_dados['codparteating'] = read_from_xml(
                    parteAtingida.codParteAting.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2210_parteatingida_dados['lateralidade'] = read_from_xml(
                    parteAtingida.lateralidade.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s2210_parteatingida = s2210parteAtingida.objects.create(
                **s2210_parteatingida_dados)

    if 'cat' in dir(evtCAT) and 'agenteCausador' in dir(evtCAT.cat):

        for agenteCausador in evtCAT.cat.agenteCausador:

            s2210_agentecausador_dados = {}
            s2210_agentecausador_dados['s2210_evtcat_id'] = s2210_evtcat.id

            try:
                s2210_agentecausador_dados['codagntcausador'] = read_from_xml(
                    agenteCausador.codAgntCausador.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            s2210_agentecausador = s2210agenteCausador.objects.create(
                **s2210_agentecausador_dados)

    if 'cat' in dir(evtCAT) and 'atestado' in dir(evtCAT.cat):

        for atestado in evtCAT.cat.atestado:

            s2210_atestado_dados = {}
            s2210_atestado_dados['s2210_evtcat_id'] = s2210_evtcat.id

            try:
                s2210_atestado_dados['codcnes'] = read_from_xml(
                    atestado.codCNES.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['dtatendimento'] = read_from_xml(
                    atestado.dtAtendimento.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['hratendimento'] = read_from_xml(
                    atestado.hrAtendimento.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['indinternacao'] = read_from_xml(
                    atestado.indInternacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['durtrat'] = read_from_xml(
                    atestado.durTrat.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['indafast'] = read_from_xml(
                    atestado.indAfast.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['dsclesao'] = read_from_xml(
                    atestado.dscLesao.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['dsccomplesao'] = read_from_xml(
                    atestado.dscCompLesao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['diagprovavel'] = read_from_xml(
                    atestado.diagProvavel.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['codcid'] = read_from_xml(
                    atestado.codCID.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['observacao'] = read_from_xml(
                    atestado.observacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['nmemit'] = read_from_xml(
                    atestado.emitente.nmEmit.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['ideoc'] = read_from_xml(
                    atestado.emitente.ideOC.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['nroc'] = read_from_xml(
                    atestado.emitente.nrOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2210_atestado_dados['ufoc'] = read_from_xml(
                    atestado.emitente.ufOC.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2210_atestado = s2210atestado.objects.create(
                **s2210_atestado_dados)

    if 'cat' in dir(evtCAT) and 'catOrigem' in dir(evtCAT.cat):

        for catOrigem in evtCAT.cat.catOrigem:

            s2210_catorigem_dados = {}
            s2210_catorigem_dados['s2210_evtcat_id'] = s2210_evtcat.id

            try:
                s2210_catorigem_dados['dtcatorig'] = read_from_xml(
                    catOrigem.dtCatOrig.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2210_catorigem_dados['nrreccatorig'] = read_from_xml(
                    catOrigem.nrRecCatOrig.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2210_catorigem = s2210catOrigem.objects.create(
                **s2210_catorigem_dados)
    s2210_evtcat_dados['evento'] = 's2210'
    s2210_evtcat_dados['id'] = s2210_evtcat.id
    s2210_evtcat_dados['identidade_evento'] = doc.eSocial.evtCAT['Id']

    from emensageriapro.esocial.views.s2210_evtcat_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2210_evtcat.id)

    return s2210_evtcat_dados
예제 #22
0
def read_s2298_evtreintegr_obj(request,
                               doc,
                               status,
                               validar=False,
                               arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2298_evtreintegr_dados = {}
    s2298_evtreintegr_dados['status'] = status
    s2298_evtreintegr_dados['arquivo_original'] = 1
    if arquivo:
        s2298_evtreintegr_dados['arquivo'] = arquivo.arquivo
    s2298_evtreintegr_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2298_evtreintegr_dados['identidade'] = doc.eSocial.evtReintegr['Id']
    evtReintegr = doc.eSocial.evtReintegr

    try:
        s2298_evtreintegr_dados['indretif'] = read_from_xml(
            evtReintegr.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['nrrecibo'] = read_from_xml(
            evtReintegr.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['tpamb'] = read_from_xml(
            evtReintegr.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['procemi'] = read_from_xml(
            evtReintegr.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['verproc'] = read_from_xml(
            evtReintegr.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['tpinsc'] = read_from_xml(
            evtReintegr.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['nrinsc'] = read_from_xml(
            evtReintegr.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['cpftrab'] = read_from_xml(
            evtReintegr.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['nistrab'] = read_from_xml(
            evtReintegr.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['matricula'] = read_from_xml(
            evtReintegr.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['tpreint'] = read_from_xml(
            evtReintegr.infoReintegr.tpReint.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['nrprocjud'] = read_from_xml(
            evtReintegr.infoReintegr.nrProcJud.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['nrleianistia'] = read_from_xml(
            evtReintegr.infoReintegr.nrLeiAnistia.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['dtefetretorno'] = read_from_xml(
            evtReintegr.infoReintegr.dtEfetRetorno.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['dtefeito'] = read_from_xml(
            evtReintegr.infoReintegr.dtEfeito.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2298_evtreintegr_dados['indpagtojuizo'] = read_from_xml(
            evtReintegr.infoReintegr.indPagtoJuizo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s2298_evtreintegr = s2298evtReintegr.objects.create(
        **s2298_evtreintegr_dados)
    s2298_evtreintegr_dados['evento'] = 's2298'
    s2298_evtreintegr_dados['id'] = s2298_evtreintegr.id
    s2298_evtreintegr_dados['identidade_evento'] = doc.eSocial.evtReintegr[
        'Id']

    from emensageriapro.esocial.views.s2298_evtreintegr_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2298_evtreintegr.id)

    return s2298_evtreintegr_dados
예제 #23
0
def read_s1020_evttablotacao_obj(request,
                                 doc,
                                 status,
                                 validar=False,
                                 arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1020_evttablotacao_dados = {}
    s1020_evttablotacao_dados['status'] = status
    s1020_evttablotacao_dados['arquivo_original'] = 1
    if arquivo:
        s1020_evttablotacao_dados['arquivo'] = arquivo.arquivo
    s1020_evttablotacao_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1020_evttablotacao_dados['identidade'] = doc.eSocial.evtTabLotacao['Id']
    evtTabLotacao = doc.eSocial.evtTabLotacao

    if 'inclusao' in dir(evtTabLotacao.infoLotacao):
        s1020_evttablotacao_dados['operacao'] = 1
    elif 'alteracao' in dir(evtTabLotacao.infoLotacao):
        s1020_evttablotacao_dados['operacao'] = 2
    elif 'exclusao' in dir(evtTabLotacao.infoLotacao):
        s1020_evttablotacao_dados['operacao'] = 3

    try:
        s1020_evttablotacao_dados['tpamb'] = read_from_xml(
            evtTabLotacao.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1020_evttablotacao_dados['procemi'] = read_from_xml(
            evtTabLotacao.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1020_evttablotacao_dados['verproc'] = read_from_xml(
            evtTabLotacao.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1020_evttablotacao_dados['tpinsc'] = read_from_xml(
            evtTabLotacao.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1020_evttablotacao_dados['nrinsc'] = read_from_xml(
            evtTabLotacao.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1020_evttablotacao = s1020evtTabLotacao.objects.create(
        **s1020_evttablotacao_dados)

    if 'infoLotacao' in dir(evtTabLotacao) and 'inclusao' in dir(
            evtTabLotacao.infoLotacao):

        for inclusao in evtTabLotacao.infoLotacao.inclusao:

            s1020_inclusao_dados = {}
            s1020_inclusao_dados[
                's1020_evttablotacao_id'] = s1020_evttablotacao.id

            try:
                s1020_inclusao_dados['codlotacao'] = read_from_xml(
                    inclusao.ideLotacao.codLotacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['inivalid'] = read_from_xml(
                    inclusao.ideLotacao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['fimvalid'] = read_from_xml(
                    inclusao.ideLotacao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['tplotacao'] = read_from_xml(
                    inclusao.dadosLotacao.tpLotacao.cdata, 'esocial', 'C',
                    None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['tpinsc'] = read_from_xml(
                    inclusao.dadosLotacao.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['nrinsc'] = read_from_xml(
                    inclusao.dadosLotacao.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['fpas'] = read_from_xml(
                    inclusao.dadosLotacao.fpasLotacao.fpas.cdata, 'esocial',
                    'N', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['codtercs'] = read_from_xml(
                    inclusao.dadosLotacao.fpasLotacao.codTercs.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_inclusao_dados['codtercssusp'] = read_from_xml(
                    inclusao.dadosLotacao.fpasLotacao.codTercsSusp.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            s1020_inclusao = s1020inclusao.objects.create(
                **s1020_inclusao_dados)

            if 'dadosLotacao' in dir(inclusao) and 'fpasLotacao' in dir(
                    inclusao.dadosLotacao) and 'infoProcJudTerceiros' in dir(
                        inclusao.dadosLotacao.fpasLotacao):

                for infoProcJudTerceiros in inclusao.dadosLotacao.fpasLotacao.infoProcJudTerceiros:

                    s1020_inclusao_infoprocjudterceiros_dados = {}
                    s1020_inclusao_infoprocjudterceiros_dados[
                        's1020_inclusao_id'] = s1020_inclusao.id

                    s1020_inclusao_infoprocjudterceiros = s1020inclusaoinfoProcJudTerceiros.objects.create(
                        **s1020_inclusao_infoprocjudterceiros_dados)

                    if 'procJudTerceiro' in dir(infoProcJudTerceiros):

                        for procJudTerceiro in infoProcJudTerceiros.procJudTerceiro:

                            s1020_inclusao_procjudterceiro_dados = {}
                            s1020_inclusao_procjudterceiro_dados[
                                's1020_inclusao_infoprocjudterceiros_id'] = s1020_inclusao_infoprocjudterceiros.id

                            try:
                                s1020_inclusao_procjudterceiro_dados[
                                    'codterc'] = read_from_xml(
                                        procJudTerceiro.codTerc.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1020_inclusao_procjudterceiro_dados[
                                    'nrprocjud'] = read_from_xml(
                                        procJudTerceiro.nrProcJud.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1020_inclusao_procjudterceiro_dados[
                                    'codsusp'] = read_from_xml(
                                        procJudTerceiro.codSusp.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            s1020_inclusao_procjudterceiro = s1020inclusaoprocJudTerceiro.objects.create(
                                **s1020_inclusao_procjudterceiro_dados)

            if 'dadosLotacao' in dir(inclusao) and 'infoEmprParcial' in dir(
                    inclusao.dadosLotacao):

                for infoEmprParcial in inclusao.dadosLotacao.infoEmprParcial:

                    s1020_inclusao_infoemprparcial_dados = {}
                    s1020_inclusao_infoemprparcial_dados[
                        's1020_inclusao_id'] = s1020_inclusao.id

                    try:
                        s1020_inclusao_infoemprparcial_dados[
                            'tpinsccontrat'] = read_from_xml(
                                infoEmprParcial.tpInscContrat.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_inclusao_infoemprparcial_dados[
                            'nrinsccontrat'] = read_from_xml(
                                infoEmprParcial.nrInscContrat.cdata, 'esocial',
                                'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_inclusao_infoemprparcial_dados[
                            'tpinscprop'] = read_from_xml(
                                infoEmprParcial.tpInscProp.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_inclusao_infoemprparcial_dados[
                            'nrinscprop'] = read_from_xml(
                                infoEmprParcial.nrInscProp.cdata, 'esocial',
                                'C', None)
                    except AttributeError:
                        pass

                    s1020_inclusao_infoemprparcial = s1020inclusaoinfoEmprParcial.objects.create(
                        **s1020_inclusao_infoemprparcial_dados)

    if 'infoLotacao' in dir(evtTabLotacao) and 'alteracao' in dir(
            evtTabLotacao.infoLotacao):

        for alteracao in evtTabLotacao.infoLotacao.alteracao:

            s1020_alteracao_dados = {}
            s1020_alteracao_dados[
                's1020_evttablotacao_id'] = s1020_evttablotacao.id

            try:
                s1020_alteracao_dados['codlotacao'] = read_from_xml(
                    alteracao.ideLotacao.codLotacao.cdata, 'esocial', 'C',
                    None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['inivalid'] = read_from_xml(
                    alteracao.ideLotacao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['fimvalid'] = read_from_xml(
                    alteracao.ideLotacao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['tplotacao'] = read_from_xml(
                    alteracao.dadosLotacao.tpLotacao.cdata, 'esocial', 'C',
                    None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['tpinsc'] = read_from_xml(
                    alteracao.dadosLotacao.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['nrinsc'] = read_from_xml(
                    alteracao.dadosLotacao.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['fpas'] = read_from_xml(
                    alteracao.dadosLotacao.fpasLotacao.fpas.cdata, 'esocial',
                    'N', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['codtercs'] = read_from_xml(
                    alteracao.dadosLotacao.fpasLotacao.codTercs.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_alteracao_dados['codtercssusp'] = read_from_xml(
                    alteracao.dadosLotacao.fpasLotacao.codTercsSusp.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            s1020_alteracao = s1020alteracao.objects.create(
                **s1020_alteracao_dados)

            if 'dadosLotacao' in dir(alteracao) and 'fpasLotacao' in dir(
                    alteracao.dadosLotacao) and 'infoProcJudTerceiros' in dir(
                        alteracao.dadosLotacao.fpasLotacao):

                for infoProcJudTerceiros in alteracao.dadosLotacao.fpasLotacao.infoProcJudTerceiros:

                    s1020_alteracao_infoprocjudterceiros_dados = {}
                    s1020_alteracao_infoprocjudterceiros_dados[
                        's1020_alteracao_id'] = s1020_alteracao.id

                    s1020_alteracao_infoprocjudterceiros = s1020alteracaoinfoProcJudTerceiros.objects.create(
                        **s1020_alteracao_infoprocjudterceiros_dados)

                    if 'procJudTerceiro' in dir(infoProcJudTerceiros):

                        for procJudTerceiro in infoProcJudTerceiros.procJudTerceiro:

                            s1020_alteracao_procjudterceiro_dados = {}
                            s1020_alteracao_procjudterceiro_dados[
                                's1020_alteracao_infoprocjudterceiros_id'] = s1020_alteracao_infoprocjudterceiros.id

                            try:
                                s1020_alteracao_procjudterceiro_dados[
                                    'codterc'] = read_from_xml(
                                        procJudTerceiro.codTerc.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1020_alteracao_procjudterceiro_dados[
                                    'nrprocjud'] = read_from_xml(
                                        procJudTerceiro.nrProcJud.cdata,
                                        'esocial', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                s1020_alteracao_procjudterceiro_dados[
                                    'codsusp'] = read_from_xml(
                                        procJudTerceiro.codSusp.cdata,
                                        'esocial', 'N', None)
                            except AttributeError:
                                pass

                            s1020_alteracao_procjudterceiro = s1020alteracaoprocJudTerceiro.objects.create(
                                **s1020_alteracao_procjudterceiro_dados)

            if 'dadosLotacao' in dir(alteracao) and 'infoEmprParcial' in dir(
                    alteracao.dadosLotacao):

                for infoEmprParcial in alteracao.dadosLotacao.infoEmprParcial:

                    s1020_alteracao_infoemprparcial_dados = {}
                    s1020_alteracao_infoemprparcial_dados[
                        's1020_alteracao_id'] = s1020_alteracao.id

                    try:
                        s1020_alteracao_infoemprparcial_dados[
                            'tpinsccontrat'] = read_from_xml(
                                infoEmprParcial.tpInscContrat.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_alteracao_infoemprparcial_dados[
                            'nrinsccontrat'] = read_from_xml(
                                infoEmprParcial.nrInscContrat.cdata, 'esocial',
                                'C', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_alteracao_infoemprparcial_dados[
                            'tpinscprop'] = read_from_xml(
                                infoEmprParcial.tpInscProp.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1020_alteracao_infoemprparcial_dados[
                            'nrinscprop'] = read_from_xml(
                                infoEmprParcial.nrInscProp.cdata, 'esocial',
                                'C', None)
                    except AttributeError:
                        pass

                    s1020_alteracao_infoemprparcial = s1020alteracaoinfoEmprParcial.objects.create(
                        **s1020_alteracao_infoemprparcial_dados)

            if 'novaValidade' in dir(alteracao):

                for novaValidade in alteracao.novaValidade:

                    s1020_alteracao_novavalidade_dados = {}
                    s1020_alteracao_novavalidade_dados[
                        's1020_alteracao_id'] = s1020_alteracao.id

                    try:
                        s1020_alteracao_novavalidade_dados[
                            'inivalid'] = read_from_xml(
                                novaValidade.iniValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1020_alteracao_novavalidade_dados[
                            'fimvalid'] = read_from_xml(
                                novaValidade.fimValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    s1020_alteracao_novavalidade = s1020alteracaonovaValidade.objects.create(
                        **s1020_alteracao_novavalidade_dados)

    if 'infoLotacao' in dir(evtTabLotacao) and 'exclusao' in dir(
            evtTabLotacao.infoLotacao):

        for exclusao in evtTabLotacao.infoLotacao.exclusao:

            s1020_exclusao_dados = {}
            s1020_exclusao_dados[
                's1020_evttablotacao_id'] = s1020_evttablotacao.id

            try:
                s1020_exclusao_dados['codlotacao'] = read_from_xml(
                    exclusao.ideLotacao.codLotacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_exclusao_dados['inivalid'] = read_from_xml(
                    exclusao.ideLotacao.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1020_exclusao_dados['fimvalid'] = read_from_xml(
                    exclusao.ideLotacao.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1020_exclusao = s1020exclusao.objects.create(
                **s1020_exclusao_dados)
    s1020_evttablotacao_dados['evento'] = 's1020'
    s1020_evttablotacao_dados['id'] = s1020_evttablotacao.id
    s1020_evttablotacao_dados['identidade_evento'] = doc.eSocial.evtTabLotacao[
        'Id']

    from emensageriapro.esocial.views.s1020_evttablotacao_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1020_evttablotacao.id)

    return s1020_evttablotacao_dados
예제 #24
0
def read_r1070_evttabprocesso_obj(request,
                                  doc,
                                  status,
                                  validar=False,
                                  arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r1070_evttabprocesso_dados = {}
    r1070_evttabprocesso_dados['status'] = status
    r1070_evttabprocesso_dados['arquivo_original'] = 1
    if arquivo:
        r1070_evttabprocesso_dados['arquivo'] = arquivo.arquivo
    r1070_evttabprocesso_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r1070_evttabprocesso_dados['identidade'] = doc.Reinf.evtTabProcesso['id']
    evtTabProcesso = doc.Reinf.evtTabProcesso

    if 'inclusao' in dir(evtTabProcesso.infoProcesso):
        r1070_evttabprocesso_dados['operacao'] = 1
    elif 'alteracao' in dir(evtTabProcesso.infoProcesso):
        r1070_evttabprocesso_dados['operacao'] = 2
    elif 'exclusao' in dir(evtTabProcesso.infoProcesso):
        r1070_evttabprocesso_dados['operacao'] = 3

    try:
        r1070_evttabprocesso_dados['tpamb'] = read_from_xml(
            evtTabProcesso.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r1070_evttabprocesso_dados['procemi'] = read_from_xml(
            evtTabProcesso.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r1070_evttabprocesso_dados['verproc'] = read_from_xml(
            evtTabProcesso.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r1070_evttabprocesso_dados['tpinsc'] = read_from_xml(
            evtTabProcesso.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r1070_evttabprocesso_dados['nrinsc'] = read_from_xml(
            evtTabProcesso.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    r1070_evttabprocesso = r1070evtTabProcesso.objects.create(
        **r1070_evttabprocesso_dados)

    if 'infoProcesso' in dir(evtTabProcesso) and 'inclusao' in dir(
            evtTabProcesso.infoProcesso):

        for inclusao in evtTabProcesso.infoProcesso.inclusao:

            r1070_inclusao_dados = {}
            r1070_inclusao_dados[
                'r1070_evttabprocesso_id'] = r1070_evttabprocesso.id

            try:
                r1070_inclusao_dados['tpproc'] = read_from_xml(
                    inclusao.ideProcesso.tpProc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r1070_inclusao_dados['nrproc'] = read_from_xml(
                    inclusao.ideProcesso.nrProc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_inclusao_dados['inivalid'] = read_from_xml(
                    inclusao.ideProcesso.iniValid.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_inclusao_dados['fimvalid'] = read_from_xml(
                    inclusao.ideProcesso.fimValid.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_inclusao_dados['indautoria'] = read_from_xml(
                    inclusao.ideProcesso.indAutoria.cdata, 'efdreinf', 'N',
                    None)
            except AttributeError:
                pass

            r1070_inclusao = r1070inclusao.objects.create(
                **r1070_inclusao_dados)

            if 'ideProcesso' in dir(inclusao) and 'infoSusp' in dir(
                    inclusao.ideProcesso):

                for infoSusp in inclusao.ideProcesso.infoSusp:

                    r1070_inclusao_infosusp_dados = {}
                    r1070_inclusao_infosusp_dados[
                        'r1070_inclusao_id'] = r1070_inclusao.id

                    try:
                        r1070_inclusao_infosusp_dados[
                            'codsusp'] = read_from_xml(infoSusp.codSusp.cdata,
                                                       'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r1070_inclusao_infosusp_dados[
                            'indsusp'] = read_from_xml(infoSusp.indSusp.cdata,
                                                       'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r1070_inclusao_infosusp_dados[
                            'dtdecisao'] = read_from_xml(
                                infoSusp.dtDecisao.cdata, 'efdreinf', 'D',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_inclusao_infosusp_dados[
                            'inddeposito'] = read_from_xml(
                                infoSusp.indDeposito.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    r1070_inclusao_infosusp = r1070inclusaoinfoSusp.objects.create(
                        **r1070_inclusao_infosusp_dados)

            if 'ideProcesso' in dir(inclusao) and 'dadosProcJud' in dir(
                    inclusao.ideProcesso):

                for dadosProcJud in inclusao.ideProcesso.dadosProcJud:

                    r1070_inclusao_dadosprocjud_dados = {}
                    r1070_inclusao_dadosprocjud_dados[
                        'r1070_inclusao_id'] = r1070_inclusao.id

                    try:
                        r1070_inclusao_dadosprocjud_dados[
                            'ufvara'] = read_from_xml(
                                dadosProcJud.ufVara.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_inclusao_dadosprocjud_dados[
                            'codmunic'] = read_from_xml(
                                dadosProcJud.codMunic.cdata, 'efdreinf', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_inclusao_dadosprocjud_dados[
                            'idvara'] = read_from_xml(
                                dadosProcJud.idVara.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    r1070_inclusao_dadosprocjud = r1070inclusaodadosProcJud.objects.create(
                        **r1070_inclusao_dadosprocjud_dados)

    if 'infoProcesso' in dir(evtTabProcesso) and 'alteracao' in dir(
            evtTabProcesso.infoProcesso):

        for alteracao in evtTabProcesso.infoProcesso.alteracao:

            r1070_alteracao_dados = {}
            r1070_alteracao_dados[
                'r1070_evttabprocesso_id'] = r1070_evttabprocesso.id

            try:
                r1070_alteracao_dados['tpproc'] = read_from_xml(
                    alteracao.ideProcesso.tpProc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r1070_alteracao_dados['nrproc'] = read_from_xml(
                    alteracao.ideProcesso.nrProc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_alteracao_dados['inivalid'] = read_from_xml(
                    alteracao.ideProcesso.iniValid.cdata, 'efdreinf', 'C',
                    None)
            except AttributeError:
                pass

            try:
                r1070_alteracao_dados['fimvalid'] = read_from_xml(
                    alteracao.ideProcesso.fimValid.cdata, 'efdreinf', 'C',
                    None)
            except AttributeError:
                pass

            try:
                r1070_alteracao_dados['indautoria'] = read_from_xml(
                    alteracao.ideProcesso.indAutoria.cdata, 'efdreinf', 'N',
                    None)
            except AttributeError:
                pass

            r1070_alteracao = r1070alteracao.objects.create(
                **r1070_alteracao_dados)

            if 'ideProcesso' in dir(alteracao) and 'infoSusp' in dir(
                    alteracao.ideProcesso):

                for infoSusp in alteracao.ideProcesso.infoSusp:

                    r1070_alteracao_infosusp_dados = {}
                    r1070_alteracao_infosusp_dados[
                        'r1070_alteracao_id'] = r1070_alteracao.id

                    try:
                        r1070_alteracao_infosusp_dados[
                            'codsusp'] = read_from_xml(infoSusp.codSusp.cdata,
                                                       'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_infosusp_dados[
                            'indsusp'] = read_from_xml(infoSusp.indSusp.cdata,
                                                       'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_infosusp_dados[
                            'dtdecisao'] = read_from_xml(
                                infoSusp.dtDecisao.cdata, 'efdreinf', 'D',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_infosusp_dados[
                            'inddeposito'] = read_from_xml(
                                infoSusp.indDeposito.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    r1070_alteracao_infosusp = r1070alteracaoinfoSusp.objects.create(
                        **r1070_alteracao_infosusp_dados)

            if 'ideProcesso' in dir(alteracao) and 'dadosProcJud' in dir(
                    alteracao.ideProcesso):

                for dadosProcJud in alteracao.ideProcesso.dadosProcJud:

                    r1070_alteracao_dadosprocjud_dados = {}
                    r1070_alteracao_dadosprocjud_dados[
                        'r1070_alteracao_id'] = r1070_alteracao.id

                    try:
                        r1070_alteracao_dadosprocjud_dados[
                            'ufvara'] = read_from_xml(
                                dadosProcJud.ufVara.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_dadosprocjud_dados[
                            'codmunic'] = read_from_xml(
                                dadosProcJud.codMunic.cdata, 'efdreinf', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_dadosprocjud_dados[
                            'idvara'] = read_from_xml(
                                dadosProcJud.idVara.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    r1070_alteracao_dadosprocjud = r1070alteracaodadosProcJud.objects.create(
                        **r1070_alteracao_dadosprocjud_dados)

            if 'novaValidade' in dir(alteracao):

                for novaValidade in alteracao.novaValidade:

                    r1070_alteracao_novavalidade_dados = {}
                    r1070_alteracao_novavalidade_dados[
                        'r1070_alteracao_id'] = r1070_alteracao.id

                    try:
                        r1070_alteracao_novavalidade_dados[
                            'inivalid'] = read_from_xml(
                                novaValidade.iniValid.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        r1070_alteracao_novavalidade_dados[
                            'fimvalid'] = read_from_xml(
                                novaValidade.fimValid.cdata, 'efdreinf', 'C',
                                None)
                    except AttributeError:
                        pass

                    r1070_alteracao_novavalidade = r1070alteracaonovaValidade.objects.create(
                        **r1070_alteracao_novavalidade_dados)

    if 'infoProcesso' in dir(evtTabProcesso) and 'exclusao' in dir(
            evtTabProcesso.infoProcesso):

        for exclusao in evtTabProcesso.infoProcesso.exclusao:

            r1070_exclusao_dados = {}
            r1070_exclusao_dados[
                'r1070_evttabprocesso_id'] = r1070_evttabprocesso.id

            try:
                r1070_exclusao_dados['tpproc'] = read_from_xml(
                    exclusao.ideProcesso.tpProc.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r1070_exclusao_dados['nrproc'] = read_from_xml(
                    exclusao.ideProcesso.nrProc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_exclusao_dados['inivalid'] = read_from_xml(
                    exclusao.ideProcesso.iniValid.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r1070_exclusao_dados['fimvalid'] = read_from_xml(
                    exclusao.ideProcesso.fimValid.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            r1070_exclusao = r1070exclusao.objects.create(
                **r1070_exclusao_dados)
    r1070_evttabprocesso_dados['evento'] = 'r1070'
    r1070_evttabprocesso_dados['id'] = r1070_evttabprocesso.id
    r1070_evttabprocesso_dados['identidade_evento'] = doc.Reinf.evtTabProcesso[
        'id']

    from emensageriapro.efdreinf.views.r1070_evttabprocesso_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r1070_evttabprocesso.id)

    return r1070_evttabprocesso_dados
예제 #25
0
def read_r4010_evtretpf_obj(request,
                            doc,
                            status,
                            validar=False,
                            arquivo=False):

    xmlns_lista = doc.Reinf['xmlns'].split('/')

    r4010_evtretpf_dados = {}
    r4010_evtretpf_dados['status'] = status
    r4010_evtretpf_dados['arquivo_original'] = 1
    if arquivo:
        r4010_evtretpf_dados['arquivo'] = arquivo.arquivo
    r4010_evtretpf_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    r4010_evtretpf_dados['identidade'] = doc.Reinf.evtRetPF['id']
    evtRetPF = doc.Reinf.evtRetPF

    try:
        r4010_evtretpf_dados['indretif'] = read_from_xml(
            evtRetPF.ideEvento.indRetif.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['nrrecibo'] = read_from_xml(
            evtRetPF.ideEvento.nrRecibo.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['perapur'] = read_from_xml(
            evtRetPF.ideEvento.perApur.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['tpamb'] = read_from_xml(
            evtRetPF.ideEvento.tpAmb.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['procemi'] = read_from_xml(
            evtRetPF.ideEvento.procEmi.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['verproc'] = read_from_xml(
            evtRetPF.ideEvento.verProc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['tpinsc'] = read_from_xml(
            evtRetPF.ideContri.tpInsc.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['nrinsc'] = read_from_xml(
            evtRetPF.ideContri.nrInsc.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['tpinscestab'] = read_from_xml(
            evtRetPF.ideEstab.tpInscEstab.cdata, 'efdreinf', 'N', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['nrinscestab'] = read_from_xml(
            evtRetPF.ideEstab.nrInscEstab.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['cpfbenef'] = read_from_xml(
            evtRetPF.ideEstab.ideBenef.cpfBenef.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    try:
        r4010_evtretpf_dados['nmbenef'] = read_from_xml(
            evtRetPF.ideEstab.ideBenef.nmBenef.cdata, 'efdreinf', 'C', None)
    except AttributeError:
        pass

    r4010_evtretpf = r4010evtRetPF.objects.create(**r4010_evtretpf_dados)

    if 'ideEstab' in dir(evtRetPF) and 'ideBenef' in dir(
            evtRetPF.ideEstab) and 'idePgto' in dir(
                evtRetPF.ideEstab.ideBenef):

        for idePgto in evtRetPF.ideEstab.ideBenef.idePgto:

            r4010_idepgto_dados = {}
            r4010_idepgto_dados['r4010_evtretpf_id'] = r4010_evtretpf.id

            try:
                r4010_idepgto_dados['natrend'] = read_from_xml(
                    idePgto.natRend.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r4010_idepgto_dados['paisresid'] = read_from_xml(
                    idePgto.paisResid.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r4010_idepgto_dados['observ'] = read_from_xml(
                    idePgto.observ.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            r4010_idepgto = r4010idePgto.objects.create(**r4010_idepgto_dados)

            if 'infoPgto' in dir(idePgto):

                for infoPgto in idePgto.infoPgto:

                    r4010_infopgto_dados = {}
                    r4010_infopgto_dados['r4010_idepgto_id'] = r4010_idepgto.id

                    try:
                        r4010_infopgto_dados['dtfg'] = read_from_xml(
                            infoPgto.dtFG.cdata, 'efdreinf', 'D', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['inddecterc'] = read_from_xml(
                            infoPgto.indDecTerc.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrrendbruto'] = read_from_xml(
                            infoPgto.vlrRendBruto.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrrendtrib'] = read_from_xml(
                            infoPgto.vlrRendTrib.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrir'] = read_from_xml(
                            infoPgto.vlrIR.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrrendsusp'] = read_from_xml(
                            infoPgto.vlrRendSusp.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrnir'] = read_from_xml(
                            infoPgto.vlrNIR.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrdeposito'] = read_from_xml(
                            infoPgto.vlrDeposito.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados[
                            'vlrcompanocalend'] = read_from_xml(
                                infoPgto.vlrCompAnoCalend.cdata, 'efdreinf',
                                'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgto_dados['vlrcompanoant'] = read_from_xml(
                            infoPgto.vlrCompAnoAnt.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r4010_infopgto = r4010infoPgto.objects.create(
                        **r4010_infopgto_dados)

                    if 'FCI' in dir(infoPgto):

                        for FCI in infoPgto.FCI:

                            r4010_fci_dados = {}
                            r4010_fci_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_fci_dados['nrinscfci'] = read_from_xml(
                                    FCI.nrInscFCI.cdata, 'efdreinf', 'C', None)
                            except AttributeError:
                                pass

                            r4010_fci = r4010FCI.objects.create(
                                **r4010_fci_dados)

                    if 'SCP' in dir(infoPgto):

                        for SCP in infoPgto.SCP:

                            r4010_scp_dados = {}
                            r4010_scp_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_scp_dados['nrinscscp'] = read_from_xml(
                                    SCP.nrInscSCP.cdata, 'efdreinf', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_scp_dados['percscp'] = read_from_xml(
                                    SCP.percSCP.cdata, 'efdreinf', 'N', 4)
                            except AttributeError:
                                pass

                            r4010_scp = r4010SCP.objects.create(
                                **r4010_scp_dados)

                    if 'detDed' in dir(infoPgto):

                        for detDed in infoPgto.detDed:

                            r4010_detded_dados = {}
                            r4010_detded_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_detded_dados[
                                    'indtpdeducao'] = read_from_xml(
                                        detDed.indTpDeducao.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_detded_dados[
                                    'vlrdeducao'] = read_from_xml(
                                        detDed.vlrDeducao.cdata, 'efdreinf',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                r4010_detded_dados[
                                    'vlrdedsusp'] = read_from_xml(
                                        detDed.vlrDedSusp.cdata, 'efdreinf',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                r4010_detded_dados[
                                    'nrinscprevcomp'] = read_from_xml(
                                        detDed.nrInscPrevComp.cdata,
                                        'efdreinf', 'C', None)
                            except AttributeError:
                                pass

                            r4010_detded = r4010detDed.objects.create(
                                **r4010_detded_dados)

                            if 'benefPen' in dir(detDed):

                                for benefPen in detDed.benefPen:

                                    r4010_benefpen_dados = {}
                                    r4010_benefpen_dados[
                                        'r4010_detded_id'] = r4010_detded.id

                                    try:
                                        r4010_benefpen_dados[
                                            'cpf'] = read_from_xml(
                                                benefPen.cpf.cdata, 'efdreinf',
                                                'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_benefpen_dados[
                                            'dtnascto'] = read_from_xml(
                                                benefPen.dtNascto.cdata,
                                                'efdreinf', 'D', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_benefpen_dados[
                                            'nome'] = read_from_xml(
                                                benefPen.nome.cdata,
                                                'efdreinf', 'C', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_benefpen_dados[
                                            'reldep'] = read_from_xml(
                                                benefPen.relDep.cdata,
                                                'efdreinf', 'N', None)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_benefpen_dados[
                                            'descrdep'] = read_from_xml(
                                                benefPen.descrDep.cdata,
                                                'efdreinf', 'C', None)
                                    except AttributeError:
                                        pass

                                    r4010_benefpen = r4010benefPen.objects.create(
                                        **r4010_benefpen_dados)

                    if 'rendIsento' in dir(infoPgto):

                        for rendIsento in infoPgto.rendIsento:

                            r4010_rendisento_dados = {}
                            r4010_rendisento_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_rendisento_dados[
                                    'tpisencao'] = read_from_xml(
                                        rendIsento.tpIsencao.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_rendisento_dados[
                                    'vlrisento'] = read_from_xml(
                                        rendIsento.vlrIsento.cdata, 'efdreinf',
                                        'N', 2)
                            except AttributeError:
                                pass

                            try:
                                r4010_rendisento_dados[
                                    'descrendimento'] = read_from_xml(
                                        rendIsento.descRendimento.cdata,
                                        'efdreinf', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_rendisento_dados[
                                    'dtlaudo'] = read_from_xml(
                                        rendIsento.dtLaudo.cdata, 'efdreinf',
                                        'D', None)
                            except AttributeError:
                                pass

                            r4010_rendisento = r4010rendIsento.objects.create(
                                **r4010_rendisento_dados)

                    if 'infoProcRet' in dir(infoPgto):

                        for infoProcRet in infoPgto.infoProcRet:

                            r4010_infoprocret_dados = {}
                            r4010_infoprocret_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_infoprocret_dados[
                                    'tpprocret'] = read_from_xml(
                                        infoProcRet.tpProcRet.cdata,
                                        'efdreinf', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocret_dados[
                                    'nrprocret'] = read_from_xml(
                                        infoProcRet.nrProcRet.cdata,
                                        'efdreinf', 'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocret_dados[
                                    'codsusp'] = read_from_xml(
                                        infoProcRet.codSusp.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocret_dados[
                                    'vlrnretido'] = read_from_xml(
                                        infoProcRet.vlrNRetido.cdata,
                                        'efdreinf', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocret_dados[
                                    'vlrdep'] = read_from_xml(
                                        infoProcRet.vlrDep.cdata, 'efdreinf',
                                        'N', 2)
                            except AttributeError:
                                pass

                            r4010_infoprocret = r4010infoProcRet.objects.create(
                                **r4010_infoprocret_dados)

                    if 'infoRRA' in dir(infoPgto):

                        for infoRRA in infoPgto.infoRRA:

                            r4010_inforra_dados = {}
                            r4010_inforra_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_inforra_dados[
                                    'tpprocrra'] = read_from_xml(
                                        infoRRA.tpProcRRA.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforra_dados[
                                    'nrprocrra'] = read_from_xml(
                                        infoRRA.nrProcRRA.cdata, 'efdreinf',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforra_dados[
                                    'indorigrec'] = read_from_xml(
                                        infoRRA.indOrigRec.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforra_dados['descrra'] = read_from_xml(
                                    infoRRA.descRRA.cdata, 'efdreinf', 'C',
                                    None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforra_dados[
                                    'qtdmesesrra'] = read_from_xml(
                                        infoRRA.qtdMesesRRA.cdata, 'efdreinf',
                                        'N', 1)
                            except AttributeError:
                                pass

                            r4010_inforra = r4010infoRRA.objects.create(
                                **r4010_inforra_dados)

                            if 'despProcJud' in dir(infoRRA):

                                for despProcJud in infoRRA.despProcJud:

                                    r4010_inforra_despprocjud_dados = {}
                                    r4010_inforra_despprocjud_dados[
                                        'r4010_inforra_id'] = r4010_inforra.id

                                    try:
                                        r4010_inforra_despprocjud_dados[
                                            'vlrdespcustas'] = read_from_xml(
                                                despProcJud.vlrDespCustas.
                                                cdata, 'efdreinf', 'N', 2)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_inforra_despprocjud_dados[
                                            'vlrdespadvogados'] = read_from_xml(
                                                despProcJud.vlrDespAdvogados.
                                                cdata, 'efdreinf', 'N', 2)
                                    except AttributeError:
                                        pass

                                    r4010_inforra_despprocjud = r4010infoRRAdespProcJud.objects.create(
                                        **r4010_inforra_despprocjud_dados)

                                    if 'ideAdv' in dir(despProcJud):

                                        for ideAdv in despProcJud.ideAdv:

                                            r4010_inforra_ideadv_dados = {}
                                            r4010_inforra_ideadv_dados[
                                                'r4010_inforra_despprocjud_id'] = r4010_inforra_despprocjud.id

                                            try:
                                                r4010_inforra_ideadv_dados[
                                                    'tpinscadv'] = read_from_xml(
                                                        ideAdv.tpInscAdv.cdata,
                                                        'efdreinf', 'N', None)
                                            except AttributeError:
                                                pass

                                            try:
                                                r4010_inforra_ideadv_dados[
                                                    'nrinscadv'] = read_from_xml(
                                                        ideAdv.nrInscAdv.cdata,
                                                        'efdreinf', 'C', None)
                                            except AttributeError:
                                                pass

                                            try:
                                                r4010_inforra_ideadv_dados[
                                                    'vlradv'] = read_from_xml(
                                                        ideAdv.vlrAdv.cdata,
                                                        'efdreinf', 'N', 2)
                                            except AttributeError:
                                                pass

                                            r4010_inforra_ideadv = r4010infoRRAideAdv.objects.create(
                                                **r4010_inforra_ideadv_dados)

                            if 'origemRec' in dir(infoRRA):

                                for origemRec in infoRRA.origemRec:

                                    r4010_inforra_origemrec_dados = {}
                                    r4010_inforra_origemrec_dados[
                                        'r4010_inforra_id'] = r4010_inforra.id

                                    try:
                                        r4010_inforra_origemrec_dados[
                                            'cnpjorigrecurso'] = read_from_xml(
                                                origemRec.cnpjOrigRecurso.
                                                cdata, 'efdreinf', 'C', None)
                                    except AttributeError:
                                        pass

                                    r4010_inforra_origemrec = r4010infoRRAorigemRec.objects.create(
                                        **r4010_inforra_origemrec_dados)

                    if 'infoProcJud' in dir(infoPgto):

                        for infoProcJud in infoPgto.infoProcJud:

                            r4010_infoprocjud_dados = {}
                            r4010_infoprocjud_dados[
                                'r4010_infopgto_id'] = r4010_infopgto.id

                            try:
                                r4010_infoprocjud_dados[
                                    'nrproc'] = read_from_xml(
                                        infoProcJud.nrProc.cdata, 'efdreinf',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocjud_dados[
                                    'indorigrec'] = read_from_xml(
                                        infoProcJud.indOrigRec.cdata,
                                        'efdreinf', 'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_infoprocjud_dados[
                                    'desc'] = read_from_xml(
                                        infoProcJud.desc.cdata, 'efdreinf',
                                        'C', None)
                            except AttributeError:
                                pass

                            r4010_infoprocjud = r4010infoProcJud.objects.create(
                                **r4010_infoprocjud_dados)

                            if 'despProcJud' in dir(infoProcJud):

                                for despProcJud in infoProcJud.despProcJud:

                                    r4010_infoprocjud_despprocjud_dados = {}
                                    r4010_infoprocjud_despprocjud_dados[
                                        'r4010_infoprocjud_id'] = r4010_infoprocjud.id

                                    try:
                                        r4010_infoprocjud_despprocjud_dados[
                                            'vlrdespcustas'] = read_from_xml(
                                                despProcJud.vlrDespCustas.
                                                cdata, 'efdreinf', 'N', 2)
                                    except AttributeError:
                                        pass

                                    try:
                                        r4010_infoprocjud_despprocjud_dados[
                                            'vlrdespadvogados'] = read_from_xml(
                                                despProcJud.vlrDespAdvogados.
                                                cdata, 'efdreinf', 'N', 2)
                                    except AttributeError:
                                        pass

                                    r4010_infoprocjud_despprocjud = r4010infoProcJuddespProcJud.objects.create(
                                        **r4010_infoprocjud_despprocjud_dados)

                                    if 'ideAdv' in dir(despProcJud):

                                        for ideAdv in despProcJud.ideAdv:

                                            r4010_infoprocjud_ideadv_dados = {}
                                            r4010_infoprocjud_ideadv_dados[
                                                'r4010_infoprocjud_despprocjud_id'] = r4010_infoprocjud_despprocjud.id

                                            try:
                                                r4010_infoprocjud_ideadv_dados[
                                                    'tpinscadv'] = read_from_xml(
                                                        ideAdv.tpInscAdv.cdata,
                                                        'efdreinf', 'N', None)
                                            except AttributeError:
                                                pass

                                            try:
                                                r4010_infoprocjud_ideadv_dados[
                                                    'nrinscadv'] = read_from_xml(
                                                        ideAdv.nrInscAdv.cdata,
                                                        'efdreinf', 'C', None)
                                            except AttributeError:
                                                pass

                                            try:
                                                r4010_infoprocjud_ideadv_dados[
                                                    'vlradv'] = read_from_xml(
                                                        ideAdv.vlrAdv.cdata,
                                                        'efdreinf', 'N', 2)
                                            except AttributeError:
                                                pass

                                            r4010_infoprocjud_ideadv = r4010infoProcJudideAdv.objects.create(
                                                **
                                                r4010_infoprocjud_ideadv_dados)

                            if 'origemRec' in dir(infoProcJud):

                                for origemRec in infoProcJud.origemRec:

                                    r4010_infoprocjud_origemrec_dados = {}
                                    r4010_infoprocjud_origemrec_dados[
                                        'r4010_infoprocjud_id'] = r4010_infoprocjud.id

                                    try:
                                        r4010_infoprocjud_origemrec_dados[
                                            'cnpjorigrecurso'] = read_from_xml(
                                                origemRec.cnpjOrigRecurso.
                                                cdata, 'efdreinf', 'C', None)
                                    except AttributeError:
                                        pass

                                    r4010_infoprocjud_origemrec = r4010infoProcJudorigemRec.objects.create(
                                        **r4010_infoprocjud_origemrec_dados)

            if 'infoPgtoExt' in dir(idePgto):

                for infoPgtoExt in idePgto.infoPgtoExt:

                    r4010_infopgtoext_dados = {}
                    r4010_infopgtoext_dados[
                        'r4010_idepgto_id'] = r4010_idepgto.id

                    try:
                        r4010_infopgtoext_dados['dsclograd'] = read_from_xml(
                            infoPgtoExt.endExt.dscLograd.cdata, 'efdreinf',
                            'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['nrlograd'] = read_from_xml(
                            infoPgtoExt.endExt.nrLograd.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['complem'] = read_from_xml(
                            infoPgtoExt.endExt.complem.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['bairro'] = read_from_xml(
                            infoPgtoExt.endExt.bairro.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['cidade'] = read_from_xml(
                            infoPgtoExt.endExt.cidade.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['estado'] = read_from_xml(
                            infoPgtoExt.endExt.estado.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['codpostal'] = read_from_xml(
                            infoPgtoExt.endExt.codPostal.cdata, 'efdreinf',
                            'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['telef'] = read_from_xml(
                            infoPgtoExt.endExt.telef.cdata, 'efdreinf', 'C',
                            None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['indnif'] = read_from_xml(
                            infoPgtoExt.infoFiscal.indNIF.cdata, 'efdreinf',
                            'N', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['nifbenef'] = read_from_xml(
                            infoPgtoExt.infoFiscal.nifBenef.cdata, 'efdreinf',
                            'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infopgtoext_dados['frmtribut'] = read_from_xml(
                            infoPgtoExt.infoFiscal.frmTribut.cdata, 'efdreinf',
                            'C', None)
                    except AttributeError:
                        pass

                    r4010_infopgtoext = r4010infoPgtoExt.objects.create(
                        **r4010_infopgtoext_dados)

    if 'ideEstab' in dir(evtRetPF) and 'ideBenef' in dir(
            evtRetPF.ideEstab) and 'ideOpSaude' in dir(
                evtRetPF.ideEstab.ideBenef):

        for ideOpSaude in evtRetPF.ideEstab.ideBenef.ideOpSaude:

            r4010_ideopsaude_dados = {}
            r4010_ideopsaude_dados['r4010_evtretpf_id'] = r4010_evtretpf.id

            try:
                r4010_ideopsaude_dados['nrinsc'] = read_from_xml(
                    ideOpSaude.nrInsc.cdata, 'efdreinf', 'C', None)
            except AttributeError:
                pass

            try:
                r4010_ideopsaude_dados['regans'] = read_from_xml(
                    ideOpSaude.regANS.cdata, 'efdreinf', 'N', None)
            except AttributeError:
                pass

            try:
                r4010_ideopsaude_dados['vlrsaude'] = read_from_xml(
                    ideOpSaude.vlrSaude.cdata, 'efdreinf', 'N', 2)
            except AttributeError:
                pass

            r4010_ideopsaude = r4010ideOpSaude.objects.create(
                **r4010_ideopsaude_dados)

            if 'infoReemb' in dir(ideOpSaude):

                for infoReemb in ideOpSaude.infoReemb:

                    r4010_inforeemb_dados = {}
                    r4010_inforeemb_dados[
                        'r4010_ideopsaude_id'] = r4010_ideopsaude.id

                    try:
                        r4010_inforeemb_dados['tpinsc'] = read_from_xml(
                            infoReemb.tpInsc.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_inforeemb_dados['nrinsc'] = read_from_xml(
                            infoReemb.nrInsc.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_inforeemb_dados['vlrreemb'] = read_from_xml(
                            infoReemb.vlrReemb.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    try:
                        r4010_inforeemb_dados['vlrreembant'] = read_from_xml(
                            infoReemb.vlrReembAnt.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r4010_inforeemb = r4010infoReemb.objects.create(
                        **r4010_inforeemb_dados)

            if 'infoDependPl' in dir(ideOpSaude):

                for infoDependPl in ideOpSaude.infoDependPl:

                    r4010_infodependpl_dados = {}
                    r4010_infodependpl_dados[
                        'r4010_ideopsaude_id'] = r4010_ideopsaude.id

                    try:
                        r4010_infodependpl_dados['cpf'] = read_from_xml(
                            infoDependPl.cpf.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infodependpl_dados['dtnascto'] = read_from_xml(
                            infoDependPl.dtNascto.cdata, 'efdreinf', 'D', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infodependpl_dados['nome'] = read_from_xml(
                            infoDependPl.nome.cdata, 'efdreinf', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infodependpl_dados['reldep'] = read_from_xml(
                            infoDependPl.relDep.cdata, 'efdreinf', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        r4010_infodependpl_dados['vlrsaude'] = read_from_xml(
                            infoDependPl.vlrSaude.cdata, 'efdreinf', 'N', 2)
                    except AttributeError:
                        pass

                    r4010_infodependpl = r4010infoDependPl.objects.create(
                        **r4010_infodependpl_dados)

                    if 'infoReembDep' in dir(infoDependPl):

                        for infoReembDep in infoDependPl.infoReembDep:

                            r4010_inforeembdep_dados = {}
                            r4010_inforeembdep_dados[
                                'r4010_infodependpl_id'] = r4010_infodependpl.id

                            try:
                                r4010_inforeembdep_dados[
                                    'tpinsc'] = read_from_xml(
                                        infoReembDep.tpInsc.cdata, 'efdreinf',
                                        'N', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforeembdep_dados[
                                    'nrinsc'] = read_from_xml(
                                        infoReembDep.nrInsc.cdata, 'efdreinf',
                                        'C', None)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforeembdep_dados[
                                    'vlrreemb'] = read_from_xml(
                                        infoReembDep.vlrReemb.cdata,
                                        'efdreinf', 'N', 2)
                            except AttributeError:
                                pass

                            try:
                                r4010_inforeembdep_dados[
                                    'vlrreembant'] = read_from_xml(
                                        infoReembDep.vlrReembAnt.cdata,
                                        'efdreinf', 'N', 2)
                            except AttributeError:
                                pass

                            r4010_inforeembdep = r4010infoReembDep.objects.create(
                                **r4010_inforeembdep_dados)
    r4010_evtretpf_dados['evento'] = 'r4010'
    r4010_evtretpf_dados['id'] = r4010_evtretpf.id
    r4010_evtretpf_dados['identidade_evento'] = doc.Reinf.evtRetPF['id']

    from emensageriapro.efdreinf.views.r4010_evtretpf_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, r4010_evtretpf.id)

    return r4010_evtretpf_dados
예제 #26
0
def read_s2399_evttsvtermino_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2399_evttsvtermino_dados = {}
    s2399_evttsvtermino_dados['status'] = status
    s2399_evttsvtermino_dados['arquivo_original'] = 1
    if arquivo:
        s2399_evttsvtermino_dados['arquivo'] = arquivo.arquivo
    s2399_evttsvtermino_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    s2399_evttsvtermino_dados['identidade'] = doc.eSocial.evtTSVTermino['Id']
    evtTSVTermino = doc.eSocial.evtTSVTermino

    try:
        s2399_evttsvtermino_dados['indretif'] = read_from_xml(evtTSVTermino.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['nrrecibo'] = read_from_xml(evtTSVTermino.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['tpamb'] = read_from_xml(evtTSVTermino.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['procemi'] = read_from_xml(evtTSVTermino.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['verproc'] = read_from_xml(evtTSVTermino.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['tpinsc'] = read_from_xml(evtTSVTermino.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['nrinsc'] = read_from_xml(evtTSVTermino.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['cpftrab'] = read_from_xml(evtTSVTermino.ideTrabSemVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['nistrab'] = read_from_xml(evtTSVTermino.ideTrabSemVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['codcateg'] = read_from_xml(evtTSVTermino.ideTrabSemVinculo.codCateg.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['dtterm'] = read_from_xml(evtTSVTermino.infoTSVTermino.dtTerm.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['mtvdesligtsv'] = read_from_xml(evtTSVTermino.infoTSVTermino.mtvDesligTSV.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['pensalim'] = read_from_xml(evtTSVTermino.infoTSVTermino.pensAlim.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['percaliment'] = read_from_xml(evtTSVTermino.infoTSVTermino.percAliment.cdata, 'esocial', 'N', 2)
    except AttributeError:
        pass

    try:
        s2399_evttsvtermino_dados['vralim'] = read_from_xml(evtTSVTermino.infoTSVTermino.vrAlim.cdata, 'esocial', 'N', 2)
    except AttributeError:
        pass

    s2399_evttsvtermino = s2399evtTSVTermino.objects.create(**s2399_evttsvtermino_dados)

    if 'infoTSVTermino' in dir(evtTSVTermino) and 'mudancaCPF' in dir(evtTSVTermino.infoTSVTermino):

        for mudancaCPF in evtTSVTermino.infoTSVTermino.mudancaCPF:

            s2399_mudancacpf_dados = {}
            s2399_mudancacpf_dados['s2399_evttsvtermino_id'] = s2399_evttsvtermino.id

            try:
                s2399_mudancacpf_dados['novocpf'] = read_from_xml(mudancaCPF.novoCPF.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2399_mudancacpf = s2399mudancaCPF.objects.create(**s2399_mudancacpf_dados)

    if 'infoTSVTermino' in dir(evtTSVTermino) and 'verbasResc' in dir(evtTSVTermino.infoTSVTermino):

        for verbasResc in evtTSVTermino.infoTSVTermino.verbasResc:

            s2399_verbasresc_dados = {}
            s2399_verbasresc_dados['s2399_evttsvtermino_id'] = s2399_evttsvtermino.id

            s2399_verbasresc = s2399verbasResc.objects.create(**s2399_verbasresc_dados)

            if 'dmDev' in dir(verbasResc):

                for dmDev in verbasResc.dmDev:

                    s2399_dmdev_dados = {}
                    s2399_dmdev_dados['s2399_verbasresc_id'] = s2399_verbasresc.id

                    try:
                        s2399_dmdev_dados['idedmdev'] = read_from_xml(dmDev.ideDmDev.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s2399_dmdev = s2399dmDev.objects.create(**s2399_dmdev_dados)

                    if 'ideEstabLot' in dir(dmDev):

                        for ideEstabLot in dmDev.ideEstabLot:

                            s2399_ideestablot_dados = {}
                            s2399_ideestablot_dados['s2399_dmdev_id'] = s2399_dmdev.id
        
                            try:
                                s2399_ideestablot_dados['tpinsc'] = read_from_xml(ideEstabLot.tpInsc.cdata, 'esocial', 'N', None)
                            except AttributeError:
                                pass
        
                            try:
                                s2399_ideestablot_dados['nrinsc'] = read_from_xml(ideEstabLot.nrInsc.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s2399_ideestablot_dados['codlotacao'] = read_from_xml(ideEstabLot.codLotacao.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass

                            s2399_ideestablot = s2399ideEstabLot.objects.create(**s2399_ideestablot_dados)
        
                            if 'detVerbas' in dir(ideEstabLot):
        
                                for detVerbas in ideEstabLot.detVerbas:
        
                                    s2399_detverbas_dados = {}
                                    s2399_detverbas_dados['s2399_ideestablot_id'] = s2399_ideestablot.id
                
                                    try:
                                        s2399_detverbas_dados['codrubr'] = read_from_xml(detVerbas.codRubr.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s2399_detverbas_dados['idetabrubr'] = read_from_xml(detVerbas.ideTabRubr.cdata, 'esocial', 'C', None)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s2399_detverbas_dados['qtdrubr'] = read_from_xml(detVerbas.qtdRubr.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s2399_detverbas_dados['fatorrubr'] = read_from_xml(detVerbas.fatorRubr.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s2399_detverbas_dados['vrunit'] = read_from_xml(detVerbas.vrUnit.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
                
                                    try:
                                        s2399_detverbas_dados['vrrubr'] = read_from_xml(detVerbas.vrRubr.cdata, 'esocial', 'N', 2)
                                    except AttributeError:
                                        pass
        
                                    s2399_detverbas = s2399detVerbas.objects.create(**s2399_detverbas_dados)
        
                            if 'infoSaudeColet' in dir(ideEstabLot):
        
                                for infoSaudeColet in ideEstabLot.infoSaudeColet:
        
                                    s2399_infosaudecolet_dados = {}
                                    s2399_infosaudecolet_dados['s2399_ideestablot_id'] = s2399_ideestablot.id
        
                                    s2399_infosaudecolet = s2399infoSaudeColet.objects.create(**s2399_infosaudecolet_dados)
                
                                    if 'detOper' in dir(infoSaudeColet):
                
                                        for detOper in infoSaudeColet.detOper:
                
                                            s2399_detoper_dados = {}
                                            s2399_detoper_dados['s2399_infosaudecolet_id'] = s2399_infosaudecolet.id
                        
                                            try:
                                                s2399_detoper_dados['cnpjoper'] = read_from_xml(detOper.cnpjOper.cdata, 'esocial', 'C', None)
                                            except AttributeError:
                                                pass
                        
                                            try:
                                                s2399_detoper_dados['regans'] = read_from_xml(detOper.regANS.cdata, 'esocial', 'C', None)
                                            except AttributeError:
                                                pass
                        
                                            try:
                                                s2399_detoper_dados['vrpgtit'] = read_from_xml(detOper.vrPgTit.cdata, 'esocial', 'N', 2)
                                            except AttributeError:
                                                pass
                
                                            s2399_detoper = s2399detOper.objects.create(**s2399_detoper_dados)
                        
                                            if 'detPlano' in dir(detOper):
                        
                                                for detPlano in detOper.detPlano:
                        
                                                    s2399_detplano_dados = {}
                                                    s2399_detplano_dados['s2399_detoper_id'] = s2399_detoper.id
                                
                                                    try:
                                                        s2399_detplano_dados['tpdep'] = read_from_xml(detPlano.tpDep.cdata, 'esocial', 'C', None)
                                                    except AttributeError:
                                                        pass
                                
                                                    try:
                                                        s2399_detplano_dados['cpfdep'] = read_from_xml(detPlano.cpfDep.cdata, 'esocial', 'C', None)
                                                    except AttributeError:
                                                        pass
                                
                                                    try:
                                                        s2399_detplano_dados['nmdep'] = read_from_xml(detPlano.nmDep.cdata, 'esocial', 'C', None)
                                                    except AttributeError:
                                                        pass
                                
                                                    try:
                                                        s2399_detplano_dados['dtnascto'] = read_from_xml(detPlano.dtNascto.cdata, 'esocial', 'D', None)
                                                    except AttributeError:
                                                        pass
                                
                                                    try:
                                                        s2399_detplano_dados['vlrpgdep'] = read_from_xml(detPlano.vlrPgDep.cdata, 'esocial', 'N', 2)
                                                    except AttributeError:
                                                        pass
                        
                                                    s2399_detplano = s2399detPlano.objects.create(**s2399_detplano_dados)
        
                            if 'infoAgNocivo' in dir(ideEstabLot):
        
                                for infoAgNocivo in ideEstabLot.infoAgNocivo:
        
                                    s2399_infoagnocivo_dados = {}
                                    s2399_infoagnocivo_dados['s2399_ideestablot_id'] = s2399_ideestablot.id
                
                                    try:
                                        s2399_infoagnocivo_dados['grauexp'] = read_from_xml(infoAgNocivo.grauExp.cdata, 'esocial', 'N', None)
                                    except AttributeError:
                                        pass
        
                                    s2399_infoagnocivo = s2399infoAgNocivo.objects.create(**s2399_infoagnocivo_dados)
        
                            if 'infoSimples' in dir(ideEstabLot):
        
                                for infoSimples in ideEstabLot.infoSimples:
        
                                    s2399_infosimples_dados = {}
                                    s2399_infosimples_dados['s2399_ideestablot_id'] = s2399_ideestablot.id
                
                                    try:
                                        s2399_infosimples_dados['indsimples'] = read_from_xml(infoSimples.indSimples.cdata, 'esocial', 'N', None)
                                    except AttributeError:
                                        pass
        
                                    s2399_infosimples = s2399infoSimples.objects.create(**s2399_infosimples_dados)

            if 'procJudTrab' in dir(verbasResc):

                for procJudTrab in verbasResc.procJudTrab:

                    s2399_procjudtrab_dados = {}
                    s2399_procjudtrab_dados['s2399_verbasresc_id'] = s2399_verbasresc.id

                    try:
                        s2399_procjudtrab_dados['tptrib'] = read_from_xml(procJudTrab.tpTrib.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s2399_procjudtrab_dados['nrprocjud'] = read_from_xml(procJudTrab.nrProcJud.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    try:
                        s2399_procjudtrab_dados['codsusp'] = read_from_xml(procJudTrab.codSusp.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s2399_procjudtrab = s2399procJudTrab.objects.create(**s2399_procjudtrab_dados)

            if 'infoMV' in dir(verbasResc):

                for infoMV in verbasResc.infoMV:

                    s2399_infomv_dados = {}
                    s2399_infomv_dados['s2399_verbasresc_id'] = s2399_verbasresc.id

                    try:
                        s2399_infomv_dados['indmv'] = read_from_xml(infoMV.indMV.cdata, 'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s2399_infomv = s2399infoMV.objects.create(**s2399_infomv_dados)

                    if 'remunOutrEmpr' in dir(infoMV):

                        for remunOutrEmpr in infoMV.remunOutrEmpr:

                            s2399_remunoutrempr_dados = {}
                            s2399_remunoutrempr_dados['s2399_infomv_id'] = s2399_infomv.id
        
                            try:
                                s2399_remunoutrempr_dados['tpinsc'] = read_from_xml(remunOutrEmpr.tpInsc.cdata, 'esocial', 'N', None)
                            except AttributeError:
                                pass
        
                            try:
                                s2399_remunoutrempr_dados['nrinsc'] = read_from_xml(remunOutrEmpr.nrInsc.cdata, 'esocial', 'C', None)
                            except AttributeError:
                                pass
        
                            try:
                                s2399_remunoutrempr_dados['codcateg'] = read_from_xml(remunOutrEmpr.codCateg.cdata, 'esocial', 'N', None)
                            except AttributeError:
                                pass
        
                            try:
                                s2399_remunoutrempr_dados['vlrremunoe'] = read_from_xml(remunOutrEmpr.vlrRemunOE.cdata, 'esocial', 'N', 2)
                            except AttributeError:
                                pass

                            s2399_remunoutrempr = s2399remunOutrEmpr.objects.create(**s2399_remunoutrempr_dados)

    if 'infoTSVTermino' in dir(evtTSVTermino) and 'quarentena' in dir(evtTSVTermino.infoTSVTermino):

        for quarentena in evtTSVTermino.infoTSVTermino.quarentena:

            s2399_quarentena_dados = {}
            s2399_quarentena_dados['s2399_evttsvtermino_id'] = s2399_evttsvtermino.id

            try:
                s2399_quarentena_dados['dtfimquar'] = read_from_xml(quarentena.dtFimQuar.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            s2399_quarentena = s2399quarentena.objects.create(**s2399_quarentena_dados)
    s2399_evttsvtermino_dados['evento'] = 's2399'
    s2399_evttsvtermino_dados['id'] = s2399_evttsvtermino.id
    s2399_evttsvtermino_dados['identidade_evento'] = doc.eSocial.evtTSVTermino['Id']

    from emensageriapro.esocial.views.s2399_evttsvtermino_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2399_evttsvtermino.id)

    return s2399_evttsvtermino_dados
예제 #27
0
def read_s3000_evtexclusao_obj(request,
                               doc,
                               status,
                               validar=False,
                               arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s3000_evtexclusao_dados = {}
    s3000_evtexclusao_dados['status'] = status
    s3000_evtexclusao_dados['arquivo_original'] = 1
    if arquivo:
        s3000_evtexclusao_dados['arquivo'] = arquivo.arquivo
    s3000_evtexclusao_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s3000_evtexclusao_dados['identidade'] = doc.eSocial.evtExclusao['Id']
    evtExclusao = doc.eSocial.evtExclusao

    try:
        s3000_evtexclusao_dados['tpamb'] = read_from_xml(
            evtExclusao.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['procemi'] = read_from_xml(
            evtExclusao.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['verproc'] = read_from_xml(
            evtExclusao.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['tpinsc'] = read_from_xml(
            evtExclusao.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['nrinsc'] = read_from_xml(
            evtExclusao.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['tpevento'] = read_from_xml(
            evtExclusao.infoExclusao.tpEvento.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s3000_evtexclusao_dados['nrrecevt'] = read_from_xml(
            evtExclusao.infoExclusao.nrRecEvt.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s3000_evtexclusao = s3000evtExclusao.objects.create(
        **s3000_evtexclusao_dados)

    if 'infoExclusao' in dir(evtExclusao) and 'ideTrabalhador' in dir(
            evtExclusao.infoExclusao):

        for ideTrabalhador in evtExclusao.infoExclusao.ideTrabalhador:

            s3000_idetrabalhador_dados = {}
            s3000_idetrabalhador_dados[
                's3000_evtexclusao_id'] = s3000_evtexclusao.id

            try:
                s3000_idetrabalhador_dados['cpftrab'] = read_from_xml(
                    ideTrabalhador.cpfTrab.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s3000_idetrabalhador_dados['nistrab'] = read_from_xml(
                    ideTrabalhador.nisTrab.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s3000_idetrabalhador = s3000ideTrabalhador.objects.create(
                **s3000_idetrabalhador_dados)

    if 'infoExclusao' in dir(evtExclusao) and 'ideFolhaPagto' in dir(
            evtExclusao.infoExclusao):

        for ideFolhaPagto in evtExclusao.infoExclusao.ideFolhaPagto:

            s3000_idefolhapagto_dados = {}
            s3000_idefolhapagto_dados[
                's3000_evtexclusao_id'] = s3000_evtexclusao.id

            try:
                s3000_idefolhapagto_dados['indapuracao'] = read_from_xml(
                    ideFolhaPagto.indApuracao.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s3000_idefolhapagto_dados['perapur'] = read_from_xml(
                    ideFolhaPagto.perApur.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s3000_idefolhapagto = s3000ideFolhaPagto.objects.create(
                **s3000_idefolhapagto_dados)
    s3000_evtexclusao_dados['evento'] = 's3000'
    s3000_evtexclusao_dados['id'] = s3000_evtexclusao.id
    s3000_evtexclusao_dados['identidade_evento'] = doc.eSocial.evtExclusao[
        'Id']

    from emensageriapro.esocial.views.s3000_evtexclusao_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s3000_evtexclusao.id)

    return s3000_evtexclusao_dados
예제 #28
0
def read_s1005_evttabestab_obj(request,
                               doc,
                               status,
                               validar=False,
                               arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s1005_evttabestab_dados = {}
    s1005_evttabestab_dados['status'] = status
    s1005_evttabestab_dados['arquivo_original'] = 1
    if arquivo:
        s1005_evttabestab_dados['arquivo'] = arquivo.arquivo
    s1005_evttabestab_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s1005_evttabestab_dados['identidade'] = doc.eSocial.evtTabEstab['Id']
    evtTabEstab = doc.eSocial.evtTabEstab

    if 'inclusao' in dir(evtTabEstab.infoEstab):
        s1005_evttabestab_dados['operacao'] = 1
    elif 'alteracao' in dir(evtTabEstab.infoEstab):
        s1005_evttabestab_dados['operacao'] = 2
    elif 'exclusao' in dir(evtTabEstab.infoEstab):
        s1005_evttabestab_dados['operacao'] = 3

    try:
        s1005_evttabestab_dados['tpamb'] = read_from_xml(
            evtTabEstab.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1005_evttabestab_dados['procemi'] = read_from_xml(
            evtTabEstab.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1005_evttabestab_dados['verproc'] = read_from_xml(
            evtTabEstab.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s1005_evttabestab_dados['tpinsc'] = read_from_xml(
            evtTabEstab.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s1005_evttabestab_dados['nrinsc'] = read_from_xml(
            evtTabEstab.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s1005_evttabestab = s1005evtTabEstab.objects.create(
        **s1005_evttabestab_dados)

    if 'infoEstab' in dir(evtTabEstab) and 'inclusao' in dir(
            evtTabEstab.infoEstab):

        for inclusao in evtTabEstab.infoEstab.inclusao:

            s1005_inclusao_dados = {}
            s1005_inclusao_dados['s1005_evttabestab_id'] = s1005_evttabestab.id

            try:
                s1005_inclusao_dados['tpinsc'] = read_from_xml(
                    inclusao.ideEstab.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['nrinsc'] = read_from_xml(
                    inclusao.ideEstab.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['inivalid'] = read_from_xml(
                    inclusao.ideEstab.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['fimvalid'] = read_from_xml(
                    inclusao.ideEstab.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['cnaeprep'] = read_from_xml(
                    inclusao.dadosEstab.cnaePrep.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['aliqrat'] = read_from_xml(
                    inclusao.dadosEstab.aliqGilrat.aliqRat.cdata, 'esocial',
                    'N', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['fap'] = read_from_xml(
                    inclusao.dadosEstab.aliqGilrat.fap.cdata, 'esocial', 'N',
                    4)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['aliqratajust'] = read_from_xml(
                    inclusao.dadosEstab.aliqGilrat.aliqRatAjust.cdata,
                    'esocial', 'N', 4)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['regpt'] = read_from_xml(
                    inclusao.dadosEstab.infoTrab.regPt.cdata, 'esocial', 'N',
                    None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['contapr'] = read_from_xml(
                    inclusao.dadosEstab.infoTrab.infoApr.contApr.cdata,
                    'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['nrprocjud'] = read_from_xml(
                    inclusao.dadosEstab.infoTrab.infoApr.nrProcJud.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_inclusao_dados['contented'] = read_from_xml(
                    inclusao.dadosEstab.infoTrab.infoApr.contEntEd.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            s1005_inclusao = s1005inclusao.objects.create(
                **s1005_inclusao_dados)

            if 'dadosEstab' in dir(inclusao) and 'aliqGilrat' in dir(
                    inclusao.dadosEstab) and 'procAdmJudRat' in dir(
                        inclusao.dadosEstab.aliqGilrat):

                for procAdmJudRat in inclusao.dadosEstab.aliqGilrat.procAdmJudRat:

                    s1005_inclusao_procadmjudrat_dados = {}
                    s1005_inclusao_procadmjudrat_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_procadmjudrat_dados[
                            'tpproc'] = read_from_xml(
                                procAdmJudRat.tpProc.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_inclusao_procadmjudrat_dados[
                            'nrproc'] = read_from_xml(
                                procAdmJudRat.nrProc.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_inclusao_procadmjudrat_dados[
                            'codsusp'] = read_from_xml(
                                procAdmJudRat.codSusp.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    s1005_inclusao_procadmjudrat = s1005inclusaoprocAdmJudRat.objects.create(
                        **s1005_inclusao_procadmjudrat_dados)

            if 'dadosEstab' in dir(inclusao) and 'aliqGilrat' in dir(
                    inclusao.dadosEstab) and 'procAdmJudFap' in dir(
                        inclusao.dadosEstab.aliqGilrat):

                for procAdmJudFap in inclusao.dadosEstab.aliqGilrat.procAdmJudFap:

                    s1005_inclusao_procadmjudfap_dados = {}
                    s1005_inclusao_procadmjudfap_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_procadmjudfap_dados[
                            'tpproc'] = read_from_xml(
                                procAdmJudFap.tpProc.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_inclusao_procadmjudfap_dados[
                            'nrproc'] = read_from_xml(
                                procAdmJudFap.nrProc.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_inclusao_procadmjudfap_dados[
                            'codsusp'] = read_from_xml(
                                procAdmJudFap.codSusp.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    s1005_inclusao_procadmjudfap = s1005inclusaoprocAdmJudFap.objects.create(
                        **s1005_inclusao_procadmjudfap_dados)

            if 'dadosEstab' in dir(inclusao) and 'infoCaepf' in dir(
                    inclusao.dadosEstab):

                for infoCaepf in inclusao.dadosEstab.infoCaepf:

                    s1005_inclusao_infocaepf_dados = {}
                    s1005_inclusao_infocaepf_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_infocaepf_dados[
                            'tpcaepf'] = read_from_xml(infoCaepf.tpCaepf.cdata,
                                                       'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s1005_inclusao_infocaepf = s1005inclusaoinfoCaepf.objects.create(
                        **s1005_inclusao_infocaepf_dados)

            if 'dadosEstab' in dir(inclusao) and 'infoObra' in dir(
                    inclusao.dadosEstab):

                for infoObra in inclusao.dadosEstab.infoObra:

                    s1005_inclusao_infoobra_dados = {}
                    s1005_inclusao_infoobra_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_infoobra_dados[
                            'indsubstpatrobra'] = read_from_xml(
                                infoObra.indSubstPatrObra.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    s1005_inclusao_infoobra = s1005inclusaoinfoObra.objects.create(
                        **s1005_inclusao_infoobra_dados)

            if 'dadosEstab' in dir(inclusao) and 'infoTrab' in dir(
                    inclusao.dadosEstab) and 'infoApr' in dir(
                        inclusao.dadosEstab.infoTrab) and 'infoEntEduc' in dir(
                            inclusao.dadosEstab.infoTrab.infoApr):

                for infoEntEduc in inclusao.dadosEstab.infoTrab.infoApr.infoEntEduc:

                    s1005_inclusao_infoenteduc_dados = {}
                    s1005_inclusao_infoenteduc_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_infoenteduc_dados[
                            'nrinsc'] = read_from_xml(infoEntEduc.nrInsc.cdata,
                                                      'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1005_inclusao_infoenteduc = s1005inclusaoinfoEntEduc.objects.create(
                        **s1005_inclusao_infoenteduc_dados)

            if 'dadosEstab' in dir(inclusao) and 'infoTrab' in dir(
                    inclusao.dadosEstab) and 'infoPCD' in dir(
                        inclusao.dadosEstab.infoTrab):

                for infoPCD in inclusao.dadosEstab.infoTrab.infoPCD:

                    s1005_inclusao_infopcd_dados = {}
                    s1005_inclusao_infopcd_dados[
                        's1005_inclusao_id'] = s1005_inclusao.id

                    try:
                        s1005_inclusao_infopcd_dados[
                            'contpcd'] = read_from_xml(infoPCD.contPCD.cdata,
                                                       'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1005_inclusao_infopcd_dados[
                            'nrprocjud'] = read_from_xml(
                                infoPCD.nrProcJud.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1005_inclusao_infopcd = s1005inclusaoinfoPCD.objects.create(
                        **s1005_inclusao_infopcd_dados)

    if 'infoEstab' in dir(evtTabEstab) and 'alteracao' in dir(
            evtTabEstab.infoEstab):

        for alteracao in evtTabEstab.infoEstab.alteracao:

            s1005_alteracao_dados = {}
            s1005_alteracao_dados[
                's1005_evttabestab_id'] = s1005_evttabestab.id

            try:
                s1005_alteracao_dados['tpinsc'] = read_from_xml(
                    alteracao.ideEstab.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['nrinsc'] = read_from_xml(
                    alteracao.ideEstab.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['inivalid'] = read_from_xml(
                    alteracao.ideEstab.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['fimvalid'] = read_from_xml(
                    alteracao.ideEstab.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['cnaeprep'] = read_from_xml(
                    alteracao.dadosEstab.cnaePrep.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['aliqrat'] = read_from_xml(
                    alteracao.dadosEstab.aliqGilrat.aliqRat.cdata, 'esocial',
                    'N', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['fap'] = read_from_xml(
                    alteracao.dadosEstab.aliqGilrat.fap.cdata, 'esocial', 'N',
                    4)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['aliqratajust'] = read_from_xml(
                    alteracao.dadosEstab.aliqGilrat.aliqRatAjust.cdata,
                    'esocial', 'N', 4)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['regpt'] = read_from_xml(
                    alteracao.dadosEstab.infoTrab.regPt.cdata, 'esocial', 'N',
                    None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['contapr'] = read_from_xml(
                    alteracao.dadosEstab.infoTrab.infoApr.contApr.cdata,
                    'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['nrprocjud'] = read_from_xml(
                    alteracao.dadosEstab.infoTrab.infoApr.nrProcJud.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_alteracao_dados['contented'] = read_from_xml(
                    alteracao.dadosEstab.infoTrab.infoApr.contEntEd.cdata,
                    'esocial', 'C', None)
            except AttributeError:
                pass

            s1005_alteracao = s1005alteracao.objects.create(
                **s1005_alteracao_dados)

            if 'dadosEstab' in dir(alteracao) and 'aliqGilrat' in dir(
                    alteracao.dadosEstab) and 'procAdmJudRat' in dir(
                        alteracao.dadosEstab.aliqGilrat):

                for procAdmJudRat in alteracao.dadosEstab.aliqGilrat.procAdmJudRat:

                    s1005_alteracao_procadmjudrat_dados = {}
                    s1005_alteracao_procadmjudrat_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_procadmjudrat_dados[
                            'tpproc'] = read_from_xml(
                                procAdmJudRat.tpProc.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_procadmjudrat_dados[
                            'nrproc'] = read_from_xml(
                                procAdmJudRat.nrProc.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_procadmjudrat_dados[
                            'codsusp'] = read_from_xml(
                                procAdmJudRat.codSusp.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    s1005_alteracao_procadmjudrat = s1005alteracaoprocAdmJudRat.objects.create(
                        **s1005_alteracao_procadmjudrat_dados)

            if 'dadosEstab' in dir(alteracao) and 'aliqGilrat' in dir(
                    alteracao.dadosEstab) and 'procAdmJudFap' in dir(
                        alteracao.dadosEstab.aliqGilrat):

                for procAdmJudFap in alteracao.dadosEstab.aliqGilrat.procAdmJudFap:

                    s1005_alteracao_procadmjudfap_dados = {}
                    s1005_alteracao_procadmjudfap_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_procadmjudfap_dados[
                            'tpproc'] = read_from_xml(
                                procAdmJudFap.tpProc.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_procadmjudfap_dados[
                            'nrproc'] = read_from_xml(
                                procAdmJudFap.nrProc.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_procadmjudfap_dados[
                            'codsusp'] = read_from_xml(
                                procAdmJudFap.codSusp.cdata, 'esocial', 'N',
                                None)
                    except AttributeError:
                        pass

                    s1005_alteracao_procadmjudfap = s1005alteracaoprocAdmJudFap.objects.create(
                        **s1005_alteracao_procadmjudfap_dados)

            if 'dadosEstab' in dir(alteracao) and 'infoCaepf' in dir(
                    alteracao.dadosEstab):

                for infoCaepf in alteracao.dadosEstab.infoCaepf:

                    s1005_alteracao_infocaepf_dados = {}
                    s1005_alteracao_infocaepf_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_infocaepf_dados[
                            'tpcaepf'] = read_from_xml(infoCaepf.tpCaepf.cdata,
                                                       'esocial', 'N', None)
                    except AttributeError:
                        pass

                    s1005_alteracao_infocaepf = s1005alteracaoinfoCaepf.objects.create(
                        **s1005_alteracao_infocaepf_dados)

            if 'dadosEstab' in dir(alteracao) and 'infoObra' in dir(
                    alteracao.dadosEstab):

                for infoObra in alteracao.dadosEstab.infoObra:

                    s1005_alteracao_infoobra_dados = {}
                    s1005_alteracao_infoobra_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_infoobra_dados[
                            'indsubstpatrobra'] = read_from_xml(
                                infoObra.indSubstPatrObra.cdata, 'esocial',
                                'N', None)
                    except AttributeError:
                        pass

                    s1005_alteracao_infoobra = s1005alteracaoinfoObra.objects.create(
                        **s1005_alteracao_infoobra_dados)

            if 'dadosEstab' in dir(alteracao) and 'infoTrab' in dir(
                    alteracao.dadosEstab) and 'infoApr' in dir(
                        alteracao.dadosEstab.infoTrab
                    ) and 'infoEntEduc' in dir(
                        alteracao.dadosEstab.infoTrab.infoApr):

                for infoEntEduc in alteracao.dadosEstab.infoTrab.infoApr.infoEntEduc:

                    s1005_alteracao_infoenteduc_dados = {}
                    s1005_alteracao_infoenteduc_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_infoenteduc_dados[
                            'nrinsc'] = read_from_xml(infoEntEduc.nrInsc.cdata,
                                                      'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1005_alteracao_infoenteduc = s1005alteracaoinfoEntEduc.objects.create(
                        **s1005_alteracao_infoenteduc_dados)

            if 'dadosEstab' in dir(alteracao) and 'infoTrab' in dir(
                    alteracao.dadosEstab) and 'infoPCD' in dir(
                        alteracao.dadosEstab.infoTrab):

                for infoPCD in alteracao.dadosEstab.infoTrab.infoPCD:

                    s1005_alteracao_infopcd_dados = {}
                    s1005_alteracao_infopcd_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_infopcd_dados[
                            'contpcd'] = read_from_xml(infoPCD.contPCD.cdata,
                                                       'esocial', 'N', None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_infopcd_dados[
                            'nrprocjud'] = read_from_xml(
                                infoPCD.nrProcJud.cdata, 'esocial', 'C', None)
                    except AttributeError:
                        pass

                    s1005_alteracao_infopcd = s1005alteracaoinfoPCD.objects.create(
                        **s1005_alteracao_infopcd_dados)

            if 'novaValidade' in dir(alteracao):

                for novaValidade in alteracao.novaValidade:

                    s1005_alteracao_novavalidade_dados = {}
                    s1005_alteracao_novavalidade_dados[
                        's1005_alteracao_id'] = s1005_alteracao.id

                    try:
                        s1005_alteracao_novavalidade_dados[
                            'inivalid'] = read_from_xml(
                                novaValidade.iniValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    try:
                        s1005_alteracao_novavalidade_dados[
                            'fimvalid'] = read_from_xml(
                                novaValidade.fimValid.cdata, 'esocial', 'C',
                                None)
                    except AttributeError:
                        pass

                    s1005_alteracao_novavalidade = s1005alteracaonovaValidade.objects.create(
                        **s1005_alteracao_novavalidade_dados)

    if 'infoEstab' in dir(evtTabEstab) and 'exclusao' in dir(
            evtTabEstab.infoEstab):

        for exclusao in evtTabEstab.infoEstab.exclusao:

            s1005_exclusao_dados = {}
            s1005_exclusao_dados['s1005_evttabestab_id'] = s1005_evttabestab.id

            try:
                s1005_exclusao_dados['tpinsc'] = read_from_xml(
                    exclusao.ideEstab.tpInsc.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s1005_exclusao_dados['nrinsc'] = read_from_xml(
                    exclusao.ideEstab.nrInsc.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_exclusao_dados['inivalid'] = read_from_xml(
                    exclusao.ideEstab.iniValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s1005_exclusao_dados['fimvalid'] = read_from_xml(
                    exclusao.ideEstab.fimValid.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s1005_exclusao = s1005exclusao.objects.create(
                **s1005_exclusao_dados)
    s1005_evttabestab_dados['evento'] = 's1005'
    s1005_evttabestab_dados['id'] = s1005_evttabestab.id
    s1005_evttabestab_dados['identidade_evento'] = doc.eSocial.evtTabEstab[
        'Id']

    from emensageriapro.esocial.views.s1005_evttabestab_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s1005_evttabestab.id)

    return s1005_evttabestab_dados
예제 #29
0
def read_s2231_evtcessao_obj(request,
                             doc,
                             status,
                             validar=False,
                             arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2231_evtcessao_dados = {}
    s2231_evtcessao_dados['status'] = status
    s2231_evtcessao_dados['arquivo_original'] = 1
    if arquivo:
        s2231_evtcessao_dados['arquivo'] = arquivo.arquivo
    s2231_evtcessao_dados['versao'] = xmlns_lista[len(xmlns_lista) - 1]
    s2231_evtcessao_dados['identidade'] = doc.eSocial.evtCessao['Id']
    evtCessao = doc.eSocial.evtCessao

    try:
        s2231_evtcessao_dados['indretif'] = read_from_xml(
            evtCessao.ideEvento.indRetif.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['nrrecibo'] = read_from_xml(
            evtCessao.ideEvento.nrRecibo.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['tpamb'] = read_from_xml(
            evtCessao.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['procemi'] = read_from_xml(
            evtCessao.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['verproc'] = read_from_xml(
            evtCessao.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['tpinsc'] = read_from_xml(
            evtCessao.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['nrinsc'] = read_from_xml(
            evtCessao.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['cpftrab'] = read_from_xml(
            evtCessao.ideVinculo.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['nistrab'] = read_from_xml(
            evtCessao.ideVinculo.nisTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2231_evtcessao_dados['matricula'] = read_from_xml(
            evtCessao.ideVinculo.matricula.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    s2231_evtcessao = s2231evtCessao.objects.create(**s2231_evtcessao_dados)

    if 'infoCessao' in dir(evtCessao) and 'iniCessao' in dir(
            evtCessao.infoCessao):

        for iniCessao in evtCessao.infoCessao.iniCessao:

            s2231_inicessao_dados = {}
            s2231_inicessao_dados['s2231_evtcessao_id'] = s2231_evtcessao.id

            try:
                s2231_inicessao_dados['dtinicessao'] = read_from_xml(
                    iniCessao.dtIniCessao.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            try:
                s2231_inicessao_dados['cnpjcess'] = read_from_xml(
                    iniCessao.cnpjCess.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            try:
                s2231_inicessao_dados['infonus'] = read_from_xml(
                    iniCessao.infOnus.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2231_inicessao_dados['indcessao'] = read_from_xml(
                    iniCessao.indCessao.cdata, 'esocial', 'N', None)
            except AttributeError:
                pass

            try:
                s2231_inicessao_dados['dscsituacao'] = read_from_xml(
                    iniCessao.dscSituacao.cdata, 'esocial', 'C', None)
            except AttributeError:
                pass

            s2231_inicessao = s2231iniCessao.objects.create(
                **s2231_inicessao_dados)

    if 'infoCessao' in dir(evtCessao) and 'fimCessao' in dir(
            evtCessao.infoCessao):

        for fimCessao in evtCessao.infoCessao.fimCessao:

            s2231_fimcessao_dados = {}
            s2231_fimcessao_dados['s2231_evtcessao_id'] = s2231_evtcessao.id

            try:
                s2231_fimcessao_dados['dttermcessao'] = read_from_xml(
                    fimCessao.dtTermCessao.cdata, 'esocial', 'D', None)
            except AttributeError:
                pass

            s2231_fimcessao = s2231fimCessao.objects.create(
                **s2231_fimcessao_dados)
    s2231_evtcessao_dados['evento'] = 's2231'
    s2231_evtcessao_dados['id'] = s2231_evtcessao.id
    s2231_evtcessao_dados['identidade_evento'] = doc.eSocial.evtCessao['Id']

    from emensageriapro.esocial.views.s2231_evtcessao_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2231_evtcessao.id)

    return s2231_evtcessao_dados
예제 #30
0
def read_s2190_evtadmprelim_obj(request, doc, status, validar=False, arquivo=False):

    xmlns_lista = doc.eSocial['xmlns'].split('/')

    s2190_evtadmprelim_dados = {}
    s2190_evtadmprelim_dados['status'] = status
    s2190_evtadmprelim_dados['arquivo_original'] = 1
    if arquivo:
        s2190_evtadmprelim_dados['arquivo'] = arquivo.arquivo
    s2190_evtadmprelim_dados['versao'] = xmlns_lista[len(xmlns_lista)-1]
    s2190_evtadmprelim_dados['identidade'] = doc.eSocial.evtAdmPrelim['Id']
    evtAdmPrelim = doc.eSocial.evtAdmPrelim

    try:
        s2190_evtadmprelim_dados['tpamb'] = read_from_xml(evtAdmPrelim.ideEvento.tpAmb.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['procemi'] = read_from_xml(evtAdmPrelim.ideEvento.procEmi.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['verproc'] = read_from_xml(evtAdmPrelim.ideEvento.verProc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['tpinsc'] = read_from_xml(evtAdmPrelim.ideEmpregador.tpInsc.cdata, 'esocial', 'N', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['nrinsc'] = read_from_xml(evtAdmPrelim.ideEmpregador.nrInsc.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['cpftrab'] = read_from_xml(evtAdmPrelim.infoRegPrelim.cpfTrab.cdata, 'esocial', 'C', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['dtnascto'] = read_from_xml(evtAdmPrelim.infoRegPrelim.dtNascto.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    try:
        s2190_evtadmprelim_dados['dtadm'] = read_from_xml(evtAdmPrelim.infoRegPrelim.dtAdm.cdata, 'esocial', 'D', None)
    except AttributeError:
        pass

    s2190_evtadmprelim = s2190evtAdmPrelim.objects.create(**s2190_evtadmprelim_dados)
    s2190_evtadmprelim_dados['evento'] = 's2190'
    s2190_evtadmprelim_dados['id'] = s2190_evtadmprelim.id
    s2190_evtadmprelim_dados['identidade_evento'] = doc.eSocial.evtAdmPrelim['Id']

    from emensageriapro.esocial.views.s2190_evtadmprelim_validar_evento import validar_evento_funcao

    if validar:
        validar_evento_funcao(request, s2190_evtadmprelim.id)

    return s2190_evtadmprelim_dados