3
ײa+                 @   s   d dl mZ d dlmZmZ d dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZ d dlZd dlZd d	lmZ d d
lT d d
lT d d
lT d d
lT d dlmZmZmZmZ d dlZdd Zdd Zdd Zdd Z dd Z!dd Z"dS )    )render)login_requiredpermission_required)UserGroup)SumQ)HttpResponseRedirect)HttpResponse)IntegrityErrortransactionN)serializers)*)datetimedatetime	timedeltac             C   sZ   | }t |}d}|}x<|dkrP|d }|d | }||d  }d| | }|}qW || S )N    ,)len)numerocadenanresulpp1p2 r   L/home/deybis/data/django/django_ruthia/sistemTransferencia/config_general.py
poner_coma   s    
r    c             C   s6   t | }|jd}|d }|d }t|}|d | S )N.r      )strsplitr    )r   r   partnumdeccader   r   r   
normalizar   s    
r)   c              C   s>   d} y$t jjtddtd dB j } W n   d} Y nX | S )Nr   r   )estado)Notificacionobjectsfilterr   count)r&   r   r   r    notificaciones_Recibidas_Gerente'   s    $
r/   c              C   sB   d} y(t jjtdddtdd dB j } W n   d} Y nX | S )Nr   todosr   )permisosr*   )r+   r,   r-   r   r.   )r&   r   r   r   !notificaciones_Recibidas_Operador0   s    (
r2   c          
   C   sF   d}y,t jj| d}tjj|jddj }|}W n   d}Y nX |S )Nr   )id_usuario__usuarioenviado)id_CajaDestinor*   )Cajasr,   getEnvioCajaCajar-   pkr.   )usrZ	aux_saldoCaux3r   r   r   saldo_recibido_oficinaC   s    
r=   c       A   >   C   s  | j j}d}d}tj }d}ytjj|d}|jdrd}d}d}	tjj|d}
t	jj|
j
jd}|j
jj d |j
jj  d |j
jj  }tjj|dd	j rd}d
}	|||	|j|d}nt	jj|d}d}d}|j
jj }|j
jj d |j
jj  d |j
jj  }tjj|j
ddj rFtjj|j
dd}|j}|j}d}d}d}d}d}tjj|jdj rtjj|jd}|j}|j}|j}|j}|j}|j
j|jj
jkrd}d}d}tjj|jdj rtjj|jdjd}|j }|j!}|dkrV|dkr t"jj||jdd}n4|dkr@t#jj||jdd}nt"jj||jdd}nt"jj||jdd}t$jj|jd}d}d}|j%}|j&}|j'}|j(} |j)dkr|j)d kr|j)}nd}d}!t*jj|jddj rd}!t+jj|jdj r
t+jj|jd}"|"j,}d}#t-jj|jdj r(d}#tj }$|$t.dd }d}%d}&|dksd|dksd|dkrt"jj|jddj rt$jj|jj|jd}'t"jj|jddjd}(|(j/|k r|'j0dkrd}%t1|(j/t.dd }&t2jj|jd})d}*d}+d},|j3dkr|j3d kr|j3},nd},|)j4|j5ks6|)j6|j5kr@d}*d}+n2|)j4|j5d ksd|)j6|j5d krnd }*d!}+nd"}*|j7 d#krd}|jj8}	|j}-|jj9}.d}/t:jjd$d%j rt:jjd$d%}0|0j|jjkrd}/d"}*d}+d}1t1t;|}2d}3t+jj|jdj rt+jj|jd}4|4j%}3d#}5d#}6t<jj|jdj r^t<jj|jd}7t=|7j4}5t=|7j6}6d#}8d#}9d#}:t>jj|jdj rt>jj|jd};t=|;j4}8t=|;j6}9t=|;j?}:t@jj|jd&d'j7 }<tAjj|jd&d'j7 }=tBjj|jd&d'j7 }>tCjjd(d)j7 }?tCjj|jd(d*j7 }@|.|	|-|||*|+t=|)j4t=|)j6|%|&|/|||2|1|||||||3t1tD |jE|#|jF|,||||| ||!||j
jG|jH|jI|jJ|jK||jL|5|6|8|9|:t1|<t1|=t1|>t1|?t1|@|jM|jNd+7}W n"   dt1tOjP d d,}Y nX |S )-Nr   )usernamezMain.add_oficinaZGERENCIA)usuario)
id_usuario si)id_gerente__usuario
subGerenteZSUBGERENCIA)ZSubGusu_n_cSITE_URLcajanombre_usuario)r3   T)r@   r*   )id_cajafechatransferenciacerrado)fechaHasta__gterI   r*   materialno)rI   independienter"   )dayshibrido)rI   r*   )
id_oficinarI   
fechaHastadangerz@Por favor haga el envio del capital- Usted ya paso el monto topei  warningzEnvie el Capital a tiemposuccessr   central)categoria_oficinar4   )r5   r*   activo)estado_transferencia)idCajaDebe__id_cajar[   )7Z
ObsOficinarF   rG   ZurlfotoZAlertCir*   msjsssdZFCierreFechaCierreZ	OfCentralalternarH   Z	dinero_reZofiExtgtgctipoSiscajaDobaseExtcajaTeZperAutorizarRetZnum_notiZx_st_toofiAsovsoases_va_ca	des_va_caegreZegre_subZ
pt_sin_dnisaldoaltZ	caja_inderE   Z	usu_tel_cZ
DCambioOfiZFilDesdeReRZ	Egreso_ptZ	Egreso_hbcompra_tactilZver_inter_res_cmss_cmds_mss_mds_mmZmaterial_reZdinero_re_mZdinero_re_doZst_procesarZst_procesar_caZprocesar_Stst_banco)rF   fail)Quserr>   r   todayr   r,   r7   has_permGerenter6   r@   r9   nombreupperApellido_paternoApellido_maternoGerente_confr-   exists
capitalizeFotofototituloTConfiguracionSistematipoSistema	cajaDolarconf2conf3ro   rS   Log_EstadoCajalatestr*   descripcion
CajaCierreCajaCierreMaterialConfiguracionExtra_cajar<   aux6aux7aux8aux5caja_independienteconf_permisos_CajasTrans_globalasociador   rT   cierreObligatorior#   SaldoDisponibleCajasaux4saldo_soles
monto_topesaldo_dolaresr.   nombre_oficinaobservacionesOficinar=   SaldoDisponibleCajaCambior)   SaldoDisponibleCajaMaterialsaldo_materialEnvioMaterialCajaCajaEnvioCajaCajaMEnvioCajaCajaDSolicitudTransferenciaBancoar2   extorno_totalaux1telefonocambioOaux9aux10
egreso_habaux11
procesa_stru   sysexc_info)Arequestr:   Zurl_fotoZtituF1resusubZ	usu_nom_coficinaGr;   dictra   rH   frd   re   rf   rg   Zcompra_material_tactiltsrk   rl   ulqTMZtransfGlobalZtransfGlobalCZc_egrrn   Zc_egres_subZc_pt_sin_dniZcaja_indZaux_tgrh   ZfActualZfaltaCierrer`   ZConfigTUcSestr]   ZautSobregiroZcaja_nombreZ	infoPhoneZoficinaCentralZOOZofExZdinero_ingresoZperAutRetSTZcpcrp   rq   Zs_cmrr   rs   rt   Zs_mZre_materialZre_dinero_mZre_dinero_doZre_st_procesarZre_st_procesar_cajar   r   r   data_global]   s   
,,



$




r   )#django.shortcutsr   django.contrib.auth.decoratorsr   r   django.contrib.auth.modelsr   r   django.db.modelsr   r   django.httpr	   r
   	django.dbr   r   jsonr   Zdjango.corer   ZConsult.modelsMain.modelsZProcess.modelsMaintenance.modelsr   r   r   r   r    r)   r/   r2   r=   r   r   r   r   r   <module>   s*   		