403Webshell
Server IP : 65.108.144.40  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : dev ( 1000)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/erp/attendance/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/attendance/__pycache__/models.cpython-310.pyc
o

hͦh���@s.dZddlZddlZddlZddlmZmZmZddlmZddl	m
Z
ddlmZddl
mZddlmZmZdd	lmZdd
lmZddlmZddlmZmZmZmZmZmZm Z m!Z!dd
l"m#Z#ddl$m%Z%m&Z&ddl'm(Z(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4m5Z5e!Z6Gdd�de2�Z7Gdd�de2�Z8Gdd�de2�Z9Gdd�de2�Z:Gdd�de2�Z;Gdd�de2�Z<Gd d!�d!e2�Z=Gd"d#�d#e2�Z>Gd$d%�d%e2�Z?Gd&d'�d'e2�Z@e�Ad(��re�Ad)��rGd*d+�d+e2�ZBeeeBd,�d-d.��ZCGd/d0�d0ejD�ZEGd1d2�d2e9�ZFdS)3zH
models.py

This module is used to register models for recruitment app

�N)�date�datetime�	timedelta)�apps)�ValidationError)�models)�Q)�	post_save�
pre_delete)�receiver)�timezone)�gettext_lazy)�
MONTH_MAPPING�attendance_date_validate�format_time�
get_diff_dict�strtime_seconds�validate_hh_mm_ss_format�validate_time_format�validate_time_in_minutes)�HorillaCompanyManager)�is_company_leave�
is_holiday)�Company�
EmployeeShift�EmployeeShiftDay�Holidays�WorkType)�Employee)�get_horilla_model_class)�HorillaModel)�HorillaAuditInfo�HorillaAuditLogc@s�eZdZdZejeejded�d�Z	ej
deged�d�Zeje
dejed�d	�Zejdd
�Zej
ded�d�Zejed
�d�Zej
ded�d�Zejdd
�Zejded�d�Zedd�ZGdd�d�Zdd�ZdS)�AttendanceActivityz"
    AttendanceActivity model
    �employee_attendance_activitiesr��	on_delete�related_name�verbose_nameTzAttendance Date��null�
validatorsr(z	Shift Day)r*r&r()r*zIn Date�r*r(zCheck In)r(zOut Datez	Check Out�+employee_id__employee_work_info__company_id��related_company_fieldc@seZdZdZgd�ZdS)zAttendanceActivity.Meta�;
        Meta class to add some additional options
        )�-attendance_date� employee_id__employee_first_name�clock_inN)�__name__�
__module__�__qualname__�__doc__�ordering�r9r9�!/var/www/erp/attendance/models.py�MetaOsr;cCsX|jr|jst����|_t����|_t�|j|j	�}t�|j|j�}||}|�
�S)z1
        Duration calc b/w in-out method
        )�	clock_out�clock_out_dater�todayr�now�time�combine�
clock_in_dater3�
total_seconds)�self�clock_in_datetime�clock_out_datetime�time_differencer9r9r:�durationVszAttendanceActivity.durationN)r4r5r6r7r�
ForeignKeyr�PROTECT�_�employee_id�	DateFieldr�attendance_dater�
DO_NOTHING�	shift_day�
DateTimeField�in_datetimerB�	TimeFieldr3r=�out_datetimer<r�objectsr;rHr9r9r9r:r#/s<����r#c@s$eZdZdZejdd�Zdd�ZdS)�BatchAttendancez 
    Batch attendance model
    ���
max_lengthcCs|j�d|j��S�N�-)�title�id�rDr9r9r:�__str__nszBatchAttendance.__str__N)r4r5r6r7r�	CharFieldr\r_r9r9r9r:rVgsrVcs�eZdZdZ�fdd�Zded�fded�fded	�fgZeje	ej
d
ded�d
�Zejde
ged�d�Zejeejd
ed�d�Zejed
d
ejed�d�Zejeejd
ed�d�Zejd
ed�d�Zejd
ed�ed�d�Zejd
ed�d�Zejd
ed�ed�d�Zejd
ddeged �d!�Zejddeged"�d#�Zejed
d
ej
ed$�d�Z ejdegded%�d&�Z!ej"ded'�d(�Z#ej"ded)�d(�Z$ej%d
d
d*�Z&ej%d
d
ed+�d,�Z'ej%d-d.�Z(ej"ded/�d(�Z)ej"ddd0�Z*ej"ded1�d(�Z+ej,d
d2d3�Z-ejd4d
edd5�Z.ej"dd.�Z/ej0d
dd6�Z1e2d7d8�Z3e4d9e5gd:�Z6Gd;d<�d<�Z7d=d>�Z8d?d@�Z9dAe:fdBdC�Z;dDdE�Z<dFdG�Z=d`dHdI�Z>dJdK�Z?dLdM�Z@dNdO�ZAdPdQ�ZBdRdS�ZC�fdTdU�ZDdVdW�ZE�fdXdY�ZFdZd[�ZGd\d]�ZH�fd^d_�ZI�ZJS)a�
Attendancez
    Attendance model
    cst�j|i|��d|_dS)NT)�super�__init__�
first_save�rD�args�kwargs��	__class__r9r:rcws
zAttendance.__init__�create_requestzCreate Request�update_requestzUpdate Request�revalidate_requestzRe-validate RequestT�employee_attendancesr)r&r*r'r(FzAttendance dater)�Shift)r&r*r(z	Work Type)r*�blankr&r(zAttendance dayz
Check-In Dater,zCheck-InzFirst Check-In Time)r*r(�	help_textzCheck-Out Datez	Check-OutzLast Check-Out Time�00:00�
�Worked Hours)r*�defaultrYr+r(zMinimum hour�rYrtr+r(zBatch Attendance�Overtime�rtr+rYr(zOvertime approved�rtr(zAttendance validated�r*rozOvertime In Second)r*ror(r�rtzIs validate request)rt�editablezIs validate request approved�)r*rY�)rYr*�choicesrt)r*r{r-r.�history_set)r'�basesc@s$eZdZdZdZddgZgd�ZdS)zAttendance.Metar0)rLrN)�change_validateattendancezValidate Attendance)�change_approveovertimezChange Approve Overtime)r1r2�attendance_clock_inN)r4r5r6r7�unique_together�permissionsr8r9r9r9r:r;�s�r;cCsdS)z?
        Method to check the min ot for the attendance
        Nr9r^r9r9r:�check_min_ot�szAttendance.check_min_otcCs4|j}|dur	dS|jj|jd���}|sdS|jS)z-
        check is night shift or not
        NF)�shift_id)�attendance_day�day_schedule�filterr��first�is_night_shift)rD�day�scheduler9r9r:r��szAttendance.is_night_shift�returncCs|jj�d|jj�d|j��S�Nz
             z - )rL�employee_first_name�employee_last_namerNr^r9r9r:r_s

��zAttendance.__str__cCs"tjj|j|jd�}||��d�S)zl
        This method is used to return the activites and count of activites comes for an attendance
        �rNrL)�query�count)r#rUr�rNrLr�)rD�
activitiesr9r9r:r�
s�zAttendance.activitiescCs4g}|jdurt�|j�}t|��|�}|��}|S)zF
        This method will returns the value difference fields
        N)�requested_data�json�loadsr�	serialize�keys)rDr��data�diffsr9r9r:�requested_fieldss
zAttendance.requested_fieldscCs$tjj|j|j|d��d�}|��S)zS
        This method is used to get the last attendance activity if exists
        )rLrN�clock_out__isnullr])r#rUr�rLrN�order_by�last)rD�
null_activityr�r9r9r:�get_last_clock_outs��zAttendance.get_last_clock_outc
	Cs�tjj|j|jd��d�}d}t��}|D]4}|j}|dur.t�	|t
j|j|j
|jd��}nt�	|j|�}|j}t�	|j|�}||}	||	��}q|S)zY
        This method is used to retun the at work calculated from the activities
        r�r3rN)�hour�minute�second)r#rUr�rNrLr�rr?r<rA�dtr@r�r�r�r=r3rBrC)
rDr��at_work_secondsr?�activity�out_time�combined_out�in_time�combined_inr�r9r9r:�get_at_work_from_activities)s&���z&Attendance.get_at_work_from_activitiescCs4t|j�}t|j�}||}|dkrdSt|�}|S)ze
        This method will returns difference between minimum_hour and attendance_worked_hour
        rrq)r�minimum_hour�attendance_worked_hourr)rD�
minimum_hours�worked_hour�pending_seconds�
pending_hoursr9r9r:�
hours_pending@s

zAttendance.hours_pendingcCs(t|j�s
t|j�rd|_d|_dSdS)zg
        Set minimum_hour to 00:00 if the attendance date falls on a holiday or company leave.
        rqTN)rrNrr�r^r9r9r:�adjust_minimum_hourLs
�zAttendance.adjust_minimum_hourcCs<ttdt|j�t|j���|_t|j�|_t|j�|_dS)zN
        Calculate and update attendance overtime and worked seconds.
        rN)r�maxrr�r��attendance_overtime�at_work_second�overtime_secondr^r9r9r:�update_attendance_overtimeTs���	z%Attendance.update_attendance_overtimecCsvtj��}|jrd|_|_|r5|jr%t|j�}|j|kr%||_t	|�|_
|jr7|jt|j�kr9d|_
dSdSdSdS)NFT)�AttendanceValidationConditionrUr��is_validate_request�is_validate_request_approved�attendance_validated�overtime_cutoffrr�rr��auto_approve_ot�minimum_overtime_to_approve�attendance_overtime_approve)rD�	condition�cutoff_secondsr9r9r:�handle_overtime_conditionsds



�
�	z%Attendance.handle_overtime_conditionsc	s4|��tjj|j�d���d�|_d}|��|�	�|j
dur,tjj|j
d�}|j}|j
jj|j�d���|jjd���}|rG|�|�n	|��}|�|�|j}|j
jj|j�d���|jjd���}|j}|ry|dury|j|_||j}n
|s�||j}d|_t|�|_|��t�j|i|��d|_dS)Nz%A)r�F)�pk�%B��month�yearr)r�rrU�getrN�strftime�lowerr�r�r�r�rar�rL�employee_overtimer�r�r��	update_ot�	create_otr��approved_overtime_secondr�overtime�saverbrd)	rDrfrg�prev_attendance_approved�
prev_state�employee_ot�approved�attendance_account�total_ot_secondsrhr9r:r�wsL�
��
��


zAttendance.savecCsp|jjt|j�t|j�t|j�t|j�t|j�|jr|jjnd|j	r&|j	jnd|j
|j|jr2|jjndd�}|S)z7
        Used to serialize attendance instance
        �)rLrN�attendance_clock_in_dater��attendance_clock_out�attendance_clock_out_dater��work_type_idr�r��batch_attendance_id)
rLr]�strrNr�r�r�r�r�r�r�r�r�)rD�serialized_datar9r9r:r��s�zAttendance.serializecs�t�t��'tjj|j|jd���|jj	j|j�
d���|j�
d�d�}Wd�n1s/wY|��r?|�
|���t�j|i|��dS)Nr�r��%Yr�)�
contextlib�suppress�	Exceptionr#rUr�rNrL�deleter�r�r��existsr�r�rb)rDrfrgr�rhr9r:r��s�
��zAttendance.deletecCsPtjj|j|j�d���|jjd�\}}|jr|j	|_
|jr"|j|_
|��|S)z�
        Create a new Hour Account instance if it doesn't exist for a specific month and year.
        Returns:
            AttendanceOverTime: The created or fetched AttendanceOverTime instance.
        r��rLr�r�)�AttendanceOverTimerU�
get_or_createrLrNr�r�r�r�r�r�r�r��hour_accountr�)rDr��createdr9r9r:r��s
�zAttendance.create_otcCs�t�d�r|jjj|j|jdd�}ng}t�}|r)|D]
}|t|j|jfd�O}qt	j
j|j|jj|jjdd��
|��dd�}d	}d	}|D]}t|d�}	t|	|d�}
||
7}||	7}qE||}t|�|_t|�|_|��|S)
z�
        Update the hour account for the given employee.

        Args:
            employee_ot (obj): AttendanceOverTime instance
        �leaver�)�start_date__lte�
end_date__gte�status)�attendance_date__rangeT)rL�attendance_date__month�attendance_date__yearr�r�r�r)r�is_installedrL�leaverequest_setr�rNr�
start_date�end_daterarUr�r��exclude�valuesr�minr�worked_hoursr�r�)rDr��approved_leave_requests�exclude_conditionr��month_attendances�hour_balance�minimum_hour_second�
attendance�required_work_secondr�r�r9r9r:r��sD
�

���


zAttendance.update_otcs�t�j|i|��t����}t����}|j}|j|j	kr$t
ddi��|jr3|j|jkr3t
ddi��|jrE|j|krG||krIt
ddi��dSdSdS)Nr�z;Attendance check-in date never smaller than attendance dater�zEAttendance check-out date never smaller than attendance check-in dater�z&Check out time not allow in the future)rb�cleanrr?r@r>rr�r�rNrr�)rDrfrgr?r>r�rhr9r:rs.�������zAttendance.clean)F)Kr4r5r6r7rcrKr�rrIrrJrLrMrrNrrOr�rr�rr�r�rSr�r�r�r`rr�r�rVr�r��BooleanFieldr�r��IntegerFieldr�r�r�r��is_bulk_requestr��	TextField�request_description�request_typer�	JSONFieldr�rrUr"r!�historyr;r�r�r�r_r�r�r�r�r�r�r�r�r�r�r�r�r�r�
__classcell__r9r9rhr:rars�


����������������
�������	
-5rac@seZdZejdd�ZdS)�AttendanceRequestFilezattendance/request_files)�	upload_toN)r4r5r6r�	FileField�filer9r9r9r:r6src@s`eZdZdZejeejd�Zeje	ejd�Z
ejedd�Z
ejded�dd�Zdefd	d
�ZdS)�AttendanceRequestCommentz(
    AttendanceRequestComment Model
    )r&T)ro�Commentr|)r*r(rYr�cCs|j�S�N)�commentr^r9r9r:r_Dsz AttendanceRequestComment.__str__N)r4r5r6r7rrIra�CASCADE�
request_idrrL�ManyToManyFieldr�filesrrKrr�r_r9r9r9r:r:srcs>eZdZdZejeejded�d�Z	ej
ded�d�Zejdd	�Z
ej
e���d
�dded�d
�Zej
dddeged�d�Zej
dddeged�d�Zej
ddeged�d�Zejdded�d�Zejdded�d�Zejdded�d�Zedd�ZGdd�d�Zdd�Zdd �Zd!d"�Zd#d$�Z d%d&�Z!�fd'd(�Z"�Z#S))r�z"
    AttendanceOverTime model
    r�rr%rr�Month)rYr(rrzr�T�Year)rtr*rYr(rqrs)rYrtr*r+r(z
Pending Hours�zOvertime HoursruzWorked Seconds)rtr*r(zPending SecondszOvertime Secondsr-r.c@s eZdZdZgd�ZddgZdS)zAttendanceOverTime.Metar0r�z-yearz-month_sequenceN�r4r5r6r7r�r8r9r9r9r:r;�sr;c	CsZzt|j�}d|krdksntdtd�i��WdSttfy,tdtd�i��w)Nili4r�z3Year must be an integer value between 1900 and 2100)�intr�rrK�
ValueError�	TypeError)rDr�r9r9r:r�s

��
��zAttendanceOverTime.cleancCsl|jd}t|j�}t||d�}|dkr%t|ddd�tdd�}||fSt||dd�tdd�}||fS)z�
        this method is used to create new AttendanceOvertime's instance if there
        is no existing for a specific month and year
        ��)�days)�month_sequencerr�rr)rDr�r�r�r�r9r9r:�
month_days�s

�zAttendanceOverTime.month_dayscCs8tttjjt|j|j|jdd�j	ddd���}t
|�S)zH
        This method will return not validated hours in a month
        F)r�r�rLr�r�T��flat��sum�listrarUr�rr�r�rL�values_listr)rD�hrs_to_vlaidater9r9r:�not_validated_hrs�s����
z$AttendanceOverTime.not_validated_hrsc	Cs:tttjjt|j|j|jddd�j	ddd���}t
|�S)zK
        This method will return the overtime hours to be approved
        TF)r�r�rLr�r�r�r&r()rD�hrs_to_approver9r9r:�not_approved_ot_hrs�s����z&AttendanceOverTime.not_approved_ot_hrscCs
t|jS)z@
        This method will return the index of the month
        )rr�r^r9r9r:�get_month_index��
z"AttendanceOverTime.get_month_indexcs^t|j�|_t|j�|_t|j�|_|j�d�d}gd�}|�	|�|_
t�j|i|��dS)Nr[r)�january�february�march�april�may�june�july�august�	september�october�november�december)
rr��hour_account_secondr��hour_pending_secondr�r�r��split�indexr$rbr�)rDrfrg�
month_name�monthsrhr9r:r��szAttendanceOverTime.save)$r4r5r6r7rrIrrJrKrLr`r��PositiveSmallIntegerFieldr$rr?r�r�rr�r�r�rr>r?r�rrUr;rr%r-r/r0r�r
r9r9rhr:r�Hs�����������r�cs�eZdZdZded�fded�fgZejeej	ded�d�Z
ejeejd	ded
�dd�Z
ejd
eed�d�Zedd�Zejd	d	d�Zdd�Zd�fdd�ZGdd�d�Zdefdd�Z�ZS)�AttendanceLateComeEarlyOutz*
    AttendanceLateComeEarlyOut model
    �	late_comez	Late Come�	early_outz	Early Out�late_come_early_outrar%TrF)r&r*r'r(r{r�Type)rYr~r(r-r.)�auto_now_addr*cCs
|j��S)z^
        This method is used to return the total penalties in the late early instance
        )�penaltyaccounts_setr�r^r9r9r:�get_penalties_countr1z.AttendanceLateComeEarlyOut.get_penalties_countr�Ncs2t�j|i|��|jj|_t�j|i|��dSr)rbr��
attendance_idrLrerhr9r:r�	s
zAttendanceLateComeEarlyOut.savec@seZdZdZddgZdgZdS)zAttendanceLateComeEarlyOut.Metar0rM�typez-attendance_id__attendance_dateNrr9r9r9r:r;s
r;cCs"|jjj�d|jjj�d|j��Sr�)rMrLr�r�rNr^r9r9r:r_s
��z"AttendanceLateComeEarlyOut.__str__�r�N)r4r5r6r7rKr~rrIrarJrMrrOrLr`rNrrUrQ�
created_atrLr�r;r�r_r
r9r9rhr:rE�s8

����rEcs�eZdZdZejdeged�d�Zejdddegd�Z	ejdddegd�Z
ejded�d	�Zej
eded
�d�Ze�Z�fdd
�Z�ZS)r�z-
    AttendanceValidationCondition model
    rrzWorked Hours Auto Approve Till)rYr+r(T)ror*rYr+FzAuto Approve OTrxr�ror(cs.t���|jstj��rttd���dSdS)�H
        This method is used to perform some custom validations
        zYou cannot add more conditions.N)rbrr]r�rUr�rrKr^rhr9r:r1s
�z#AttendanceValidationCondition.clean)r4r5r6r7rr`rrK�validation_at_workr�r�rr�rr�
company_idrrUrr
r9r9rhr:r�s&�
�
��r�cs�eZdZdZejdegded�d�Ze�	�Z
ejded�d�Zejd	ed
�d�Z
ejd	d�Zejeded�d
�Ze�Zdefdd�Z�fdd�Z�fdd�Z�ZS)�	GraceTimez%
    Model for saving Grace time
    z00:00:00rrzAllowed timerwTz1Allcocate this grace time for Check-In Attendance)rtrpFz2Allcocate this grace time for Check-Out AttendancerzrrQr�cCst|j�d��S)Nz - Hours)r��allowed_timer^r9r9r:r_QszGraceTime.__str__cs�t���|jrtjjdd�j|jd���rt	t
d���|j}|j}|}tjj|d�j|d�j|jd���r?t	dt
d�i��dS)	rRT)�
is_default)r]z2There is already a default grace time that exists.)rVrVz?There is already an existing grace time with this allowed time.N)rbrrWrUrUr�r�r]r�rrKrV)rDrVrW�exclude_defaultrhr9r:rTs.
��������zGraceTime.cleanc
s�|j}|�d�\}}}t|�}t|�}t|�}	|d�}
|d�}|	d�}|
�d|�d|��|_|d|d|	|_t�j|i|��dS)N�:�02di�<)rVr@r�allowed_time_in_secsrbr�)
rDrfrgrV�hours�minutes�secs�	hours_int�minutes_int�secs_int�	hours_str�minutes_str�secs_strrhr9r:r�qszGraceTime.save)r4r5r6r7rr`rrKrVrr\r�allowed_clock_in�allowed_clock_outrWrrrTrrUr�r_rr�r
r9r9rhr:rU:s*���rUc@sLeZdZdZejdd�Zejded�ed�d�Zej	e
ejdd�Ze
�ZdS)	�AttendanceGeneralSettingz#
    AttendanceGeneralSettings
    TrzzEnable Check in/Check outzfEnabling this feature allows employees to record their attendance using the Check-In/Check-Out button.)rtr(rp)r&r*N)r4r5r6r7rr�time_runnerrK�enable_check_inrIrrrTrrUr9r9r9r:rh�s��
rhr��payrollcs�eZdZdZejeejddddd�Zeje	ej
ddd�Zejddej
dd	�Zejd
ej
dddd�Zejd
dd�Zejdd�Zejd
dd�Zd�fdd�ZGdd�d�Z�ZS)�PenaltyAccountz0
        LateComeEarlyOutPenaltyAccount
        �penalty_setFrT)r&r'r{r(r*)r&r*r{zleave.LeaveRequest)r*r&r{zleave.LeaveTypez
Leave type)r&ror*r(�)rtr*rzr�Ncs�t���|js|jrtdtd�i��|jr!|js!tdtd�i��|js/|js/tdtd�i��|js5|jr@|js@tdtd�i��dS)N�
leave_type_idz+Specify the leave type to deduct the leave.�minus_leaveszCIf a leave type is chosen for a penalty, minus leaves are required.z3Either minus leaves or a penalty amount is requiredzLeave type is required)rbrrorprrK�penalty_amount�deduct_from_carry_forwardr^rhr9r:r�s6

�������	���zPenaltyAccount.cleanc@seZdZdgZdS)zPenaltyAccount.Metaz-created_atN)r4r5r6r8r9r9r9r:r;�s
r;rO)r4r5r6r7rrIrrJrLrEr�
late_early_id�leave_request_idrOro�
FloatFieldrprrrrqrr;r
r9r9rhr:rl�s>��
��rl��senderc	Ks8|r�|j}|r`tddd�}|�}|jr#|j���d�|_|jjj|_n|jr4d|jj	��|_|jj	|_n
dt
����|_t
��|_d|_d|_
|j|_d|_|��d|_|j�|j�|��|jr�|jr�|jjj|jd	���}t|jd
�d
}|js�td|j|�|_n	td|j|�|_|��dSdSdSdS)
z\
        This is post save method, used to create initial stage for the recruitment
        rk�	deduction��	app_label�modelz penaltyzLeave penalty zPenalty on FT)ro�rN)rqrrs�get_type_displayr\rMrN�
one_time_datertr�rr>�include_active_employees�is_fixed�amount�only_show_under_employeer��specific_employees�addrLrorp�available_leaver�r��roundrrr��available_days�carryforward_days)	rw�instancer�rgrq�	Deduction�penalty�	available�unitr9r9r:�create_initial_stage�sR����
��
��r�csbeZdZdZded�fded�fded�fded	�fd
ed�fded
�fgZejdddd�Zejdded�Z	ej
eejed�d�Z
ejddd�Zejddegddd�Zejddegddd�Zejdddd�Zejdddd�Zejdd�Zejdddd�Zejdd�Zejdd�Zejdd�Zejddd�Ze d�Z!d d!�Z"�fd"d#�Z#�fd$d%�Z$d&d'�Z%�Z&S)(�WorkRecordsz
    WorkRecord Model
    �FDP�Present�HDPzHalf Day Present�ABS�Absent�HDzHoliday/Company Leave�CONF�Conflict�DFT�Draft�T)rYr*ro�)rYr*r~r)r&r(ryrq)r*ror+rtrYr)r*rortr|rX�Frzr-cCsb|j}|dkr/t�d�r/tddd�}|j��r&|jj|j|j|jd��	�j
nd}|d|��7}|S)Nr�r��leaverequestry)rLr�r�z | )�messagerr�rrUr�r�rLrr�ro)rD�
title_message�LeaveRequest�
leave_typer9r9r:r�:s$
����zWorkRecords.title_messagecs t��|_t�j|i|��dSr)rr?�last_updaterbr�rerhr9r:r�Os
zWorkRecords.savecs2t���d|jkrdksnttd���dS)Nrn��?z*Day percentage must be between 0.0 and 1.0)rbr�day_percentagerrKr^rhr9r:rTs
�zWorkRecords.cleancCs"|jdur|jS|j�d|j��SrZ)�record_name�work_record_typerr^r9r9r:r_Ys

���zWorkRecords.__str__)'r4r5r6r7rKr~rr`r�r�rIrrJrLrMrr�at_work�min_hourrr��min_hour_secondr�noter�r�is_attendance_record�is_leave_recordrur�rQr�rrUr�r�rr_r
r9r9rhr:r�
sX





�	���	��	r�c@s8eZdZdZeeed�dd��Zeeed�dd��Z	dS)�OverrideAttendancesz8
    Class to override Attendance model save method
    rvcKs�|jr�t|j�}t|j�}|j|krdnd}|jdurdn|}|dkr'td�ntd�}|dkr7||kr7td�n|}tjj	|j
d|jd	�}tjj	|j
|jd
���sSt�ntjj	|j
|jd
��
�}|j|_|j
|_|j|_|j|_||_||_||_||_d|_|jr�||dkr�dnd
|_|��|dkr�|jr�td�}n|dkr�|jr�td�}n|dkr�td�}||_|��|j}|j}|js�d}td�}||_||_|��dSdS)z9
        Overriding Attendance model save method
        r�r�Fr�zValidate the attendance�	ValidatedzIncomplete minimum hourT)rr�rL)rrLr|r�g�?zHalf day leavezAn approved leave existsr�zCurrently workingN)rdrr�r�r�r�rKr�rUr�rNrLr�r�rr�r�r�r�r�r�r�r�r�r�)rwr�rgr�r�r�r��work_recordr9r9r:�attendance_post_savegst

���������

�z(OverrideAttendances.attendance_post_savecKstjj|jd|jd���dS)z;
        Overriding Attendance model delete method
        T)rLr�rN)r�rUr�rLrNr�)rwr��_kwargsr9r9r:�attendance_pre_delete�s�
z)OverrideAttendances.attendance_pre_deleteN)
r4r5r6r7rr	rar�r
r�r9r9r9r:r�as


Fr�)Gr7r�rr�r�rr�django.appsr�django.core.exceptionsr�	django.dbr�django.db.modelsr�django.db.models.signalsr	r
�django.dispatchr�django.utilsr�django.utils.translationr
rK�attendance.methods.utilsrrrrrrrr�base.horilla_company_managerr�base.methodsrr�base.modelsrrrrr�employee.modelsr�horilla.methodsr�horilla.modelsr �horilla_audit.modelsr!r"�_validate_time_in_minutesr#rVrarrr�rEr�rUrhr�rlr��Modelr�r�r9r9r9r:�<module>sT(
8G6H
A
3W

Youez - 2016 - github.com/yon3zu
LinuXploit