ó M¹1Sc@s(ddlTddlmZddlmZddlmZmZmZmZddl Z ddl m Z ddl m Z ddlmZd „Zd „Zd „Zd dd „ƒYZd„Zd„Zd„Zddd„ƒYZd„Zd„Zd„Zd„Zddd„ƒYZd„ZdS(iÿÿÿÿ(t*(tIntegrityError(tObjectDoesNotExist(tdatetimet timedeltattzinfotdateN(t monthrange(t Formatter(t Comentarioc Cstddƒ}|jƒ}|jƒd}xÐ|D]È}|jdƒdjƒdd!}xŸ|D]—}|j|kr_|jdƒd}|jdƒd }tjd ||f|ƒ} tƒ} || _ | | _ y| j ƒWqöt k ròqöXq_q_Wq2WdS( Ns./mnt/henry/MeusArquivosSaida/Registros.txt.txttrs%d/%m/%Y %H:%M:%St iÿÿÿÿi iiýÿÿÿiþÿÿÿs%s %s( topent readlinestclosetsplittrstript matriculaRtstrptimet BatidaPontot funcionariotmomento_batidapontotsaveR( tlista_funcionariostarquivotconteudo_arquivotformatotlinhaRRtdatathorat data_horat batida_ponto((s./ponto/utils.pytpuxar_informacoes_henrys$         cCsStjjƒ}|rKt|ƒtƒ}tjƒ}||_|jƒt St SdS(N( t FuncionariotobjectstallR t SincronizacaoRtnowRRtTruetFalse(Rtnova_sincronizacaotagora((s./ponto/utils.pyt sincronizarBs     cCsÃtƒ}i}idd6dd6dd6dd6}td „t|j|ƒƒƒ}t|jƒƒ}xLd D]D}||krk||jƒkrkt|||ƒ\||<}qkqkW|j||S( Ni€QtDitHi<tMitScSs|dS(Ni((tx((s./ponto/utils.pyt[s(R+R,R-R.( Rtmaptlisttparsetintt total_secondstkeystdivmodtformat(ttdeltatfmttftdtltktremti((s./ponto/utils.pyt strfdeltaWs "! $t ResumoDiariocBs#eZd„Zd„Zd„ZRS(cCs||_||_dS(N(Rthoras(tselfRRC((s./ponto/utils.pyt__init__js cCst|jdƒS(Ns{H:02}:{M:02}:{S:02}(RARC(RD((s./ponto/utils.pythoras_formatadasoscCs|jjdƒS(Ns%d/%m/%Y(Rtstrftime(RD((s./ponto/utils.pytdata_formatadats(t__name__t __module__RERFRH(((s./ponto/utils.pyRBhs  cCs¤t|ƒ}d}d}d}d}|dkr@|dj}n|dkr\|dj}n|dkrx|dj}n|dkr”|dj}n||||fS(Niiiii(tlentNoneR(tbatidas_do_diaRtquantidade_batidas_do_diatbatida_entrada_manhatbatida_saida_manhatbatida_entrada_tardetbatida_saida_tarde((s./ponto/utils.pytorganizar_batidasponto{s     fc Cs¤ttjjd|d|jd|jd|jƒjdƒƒ}tddƒ}t ||ƒ\}}}}|r¿|r¿|j ƒ}||j kr¨t j ||j ƒ}n||} || 7}n|r|r|j ƒ} | |jkrþt j ||jƒ}n||} || 7}nywtjjd|d|ƒ} | jr‹| j} | j}| j}| j}td|dd||dƒ}||7}nWntk rŸnX|S(NRtmomento_batidaponto__daytmomento_batidaponto__monthtmomento_batidaponto__yearRiR(R2RR"tfiltertdaytmonthtyeartorder_byRRSttimethorario_inicial_entradaRtcombinethorario_final_saidaR tgettaprovadot tempo_gastothourtminutetsecondR(RRRMttempo_total_diaRORPRQRRthorario_entradathoras_trabalhadas_manhat horario_saidathoras_trabalhadas_tardet comentarioRbRCtminutostsegundosttempo_gasto_timedelta((s./ponto/utils.pytcalcular_horas_trabalhadas_diaös6?              c Csàg}d}y"tjjd|ƒjdƒ}Wntk rAnX|rÜ|j}tjƒ}||}|j }|}xc|j ƒ|j ƒkrØt ||ƒ}t |j ƒ|ƒ} |j | ƒ|tddƒ7}qyWn|S(NRRtdaysi(RLRR"RWtearliestRRRR%RpRRoRBtappendR( Rtresumostprimeira_batidapontot primeira_datat data_atualtdiferenca_datastquantidade_diast data_tempt horas_diatresumo((s./ponto/utils.pythoras_trabalhadas_diaAs$"      t ResumoSemanalcBs#eZd„Zd„Zd„ZRS(cCs||_||_dS(N(tdomingoRC(RDR~RC((s./ponto/utils.pyREfs cCst|jdƒS(Ns{H:02}:{M:02}:{S:02}(RARC(RD((s./ponto/utils.pyRFksc Cs¹d}|j}|jtd dƒ}d|j}d|j}|jdkr^d|j}n|jdkr}d|j}nd|||jd|j|||jd|jf}|S(NtJaneirot FevereirosMarçotAbriltMaiotJunhotJulhotAgostotSetembrotOutubrotNovembrotDezembroRpis%di s0%ds"De %s de %s de %d a %s de %s de %di( sJaneiros FevereirosMarçosAbrilsMaiosJunhosJulhosAgostosSetembrosOutubrosNovembrosDezembro(R~RRXRYRZ(RDtmesesR~t sexta_feirat dia_domingot dia_sextatsemana((s./ponto/utils.pytsemana_formatadaps   8(RIRJRERFR(((s./ponto/utils.pyR}ds  cCsVtddƒ}|}x:tdƒD],}|t||ƒ7}|tddƒ7}q"W|S(NiiRpi(RtrangeRo(RR~ttempo_total_semanaRyR@((s./ponto/utils.pyt!calcular_horas_trabalhadas_semana†s c Csg}d}y"tjjd|ƒjdƒ}Wntk rAnX|r|j}tjƒ}|j ƒ}x/|dkrš|t ddƒ8}|j ƒ}qlWtjƒ}|}xc|j ƒ|j ƒkrt ||ƒ}t |j ƒ|ƒ}|j|ƒ|t ddƒ7}q°Wn|S(NRRiRpii(RLRR"RWRqRRRR%tweekdayRRR’R}Rr( RRsRtRuRvt dia_semanaRythoras_trabalhadastresumo_semanal((s./ponto/utils.pythoras_trabalhadas_semana”s*"      c Csàt||ƒ}t|||dƒ}t|||dƒ}|}g}|jƒ}x/|dkr„|tddƒ8}|jƒ}qVW|} xN| |krÛt|| ƒ} t| | ƒ} |j| ƒ| tddƒ7} qŽW|S(NiiiRpi(RRR“RR’R}Rr( Rtmestanot limites_mestprimeiro_dia_mestultimo_dia_mesRuRsR”RyR•R–((s./ponto/utils.pyt$horas_trabalhadas_semana_durante_mesºs   cCsFg}tddƒ}x!|D]}|t||ƒ7}qWt|dƒS(Nis{H:02}:{M:02}:{S:02}(RRoRA(RtdatasRst tempo_totalR((s./ponto/utils.pythoras_trabalhadas_datasÛs  tRelatorioDiariocBseZd„ZRS(cCs‚||_||_|r-|jdƒ|_n|rH|jdƒ|_n|rc|jdƒ|_n|r~|jdƒ|_ndS(Ns%H:%M:%S(RRfRGRORPRQRR(RDRRfRORPRQRR((s./ponto/utils.pyREés  (RIRJRE(((s./ponto/utils.pyR¡çsc Csót||ƒd}g}xÓtd|ddƒD]»}g}t|||ƒ}|jdƒ}t||ƒ} t| dƒ} ttjj d|d|d|d|ƒƒ} t | |ƒ\} } }}t || | | ||ƒ}|j |ƒq0W|S(Nis%d/%m/%Ys{H:02}:{M:02}:{S:02}RRURTRV( RRRRGRoRAR2RR"RWRSR¡Rr(RR˜R™t fim_do_mestrelatorios_diariostdiatbatidas_formatadasRRHRfttempo_total_dia_formatadotbatidas_ponto_diaRORPRQRRtrelatorio_diario((s./ponto/utils.pytgerar_relatorio_mensaløs-((((tmodelst django.dbRtdjango.core.exceptionsRRRRRR\tcalendarRtstringRt ponto.modelsR R R*RARBRSRoR|R}R’R—RR R¡R©(((s./ponto/utils.pyts* "  *   { K #"  & !