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/employee/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

hͦh��@sdZddlmZmZmZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3m4Z4dd�Z5Gdd�dej6�Z7Gdd�de/�Z8Gdd�dej6�Z9Gdd�de/�Z:Gd d!�d!e/�Z;Gd"d#�d#e/�Z<Gd$d%�d%e/�Z=Gd&d'�d'e/�Z>Gd(d)�d)e/�Z?Gd*d+�d+e/�Z@Gd,d-�d-e/�ZAGd.d/�d/e/�ZBdd0lCmDZDeD�Ed1�eD�Ed2�eD�Ed3�d4S)5zE
models.py

This module is used to register models for employee app

�)�date�datetime�	timedelta)�apps)�settings)�
Permission�User)�ValidationError)�default_storage)�models)�QuerySet)�	post_save)�receiver)�gettext)�gettext_lazy)�HorillaCompanyManager)�Company�
Department�
EmployeeShift�EmployeeType�JobPosition�JobRole�WorkType�validate_time_format)�format_time�strtime_seconds)�horilla_middlewares)�get_horilla_model_class)�HorillaModel��get_diff)�HorillaAuditInfo�HorillaAuditLogcCs|S)z9
    Method to implement reporting manager_validator
    �)�valuer#r#�/var/www/erp/employee/models.py�reporting_manager_validator+sr&cs�eZdZdZded�fded�fded�fgZded	�fd
ed�fded
�ffZejdddd�Z	ej
eejddde
d�d�Zejdde
d�d�Zejddde
d�d�Zejdddd�Zejddd�Zejdd�Zejdddd �Zejd!ddd �Zejd!ddd�Zejd!ddd�Zejd"ddd�Zejddd#�Zejd$dedd%�Zejdddd �Zej ddd#�Z!ejdddedd&�Z"ej ddd'�Z#ejdddd�Z$ejd"ddd�Z%ejd"ddd�Z&ej'dd(�Z(ej)ddd#�Z*ej'ddddd)�Z+ej'ddddd)�Z,e-d*d+�Z.d,d-�Z/d.d/�Z0d0d1�Z1d2d3�Z2d4d5�Z3d6d7�Z4d8d9�Z5d:d;�Z6d<d=�Z7d>d?�Z8d@dA�Z9dBdC�Z:dDdE�Z;dFdG�Z<dHdI�Z=dJdK�Z>dLdM�Z?dNdO�Z@dPeAfdQdR�ZBdSdT�ZCGdUdV�dV�ZDdWdX�ZEdYdZ�ZFd[d\�ZG�fd]d^�ZH�ZIS)_�Employeez
    Employee model
    �male�Male�female�Female�other�Other�single�Single�married�Married�divorced�Divorced�2T)�
max_length�null�blank�employee_getr��	on_deleter7r6�related_name�verbose_name��Fz
First Name�r5r6r<z	Last Name�r5r6r7r<zemployee/profile��	upload_tor6r7�)r5�unique��r5�r5r7r6���r6r7�
)r5r6�choices�default)r5r7r6rKrL�r7r6�rL)rLr6r7�editable�employee_work_info__company_id��related_company_fieldcCsd}|jr	|jj}|S)zV
        This method is used to return the profile image path of the employee
        F)�employee_profile�url)�selfrTr#r#r%�	get_imageuszEmployee.get_imagecCs|jr|j�d|j��S|jS)z7
        Method will return employee full name
        � )�employee_last_name�employee_first_name�rUr#r#r%�
get_full_name~s
���zEmployee.get_full_namecC�tt|dd�dd�S)zK
        This method is used to return the company of the employee
        �employee_work_infoN�
company_id��getattrrZr#r#r%�get_company��zEmployee.get_companycCs<|��r|��ntjjdd���}|r|j}|r|SdSdS)NT)�hqzMMM. D, YYYY)rar�objects�filter�first�date_format)rU�companyrgr#r#r%�get_date_format�s
��zEmployee.get_date_formatcCr\)zP
        This method is used to return the job position of the employee
        r]N�job_position_idr_rZr#r#r%�get_job_position���zEmployee.get_job_positioncCr\)zN
        This method is used to return the department of the employee
        r]N�
department_idr_rZr#r#r%�get_department�rbzEmployee.get_departmentcCr\)�I
        This method is used to return the shift of the employee
        r]N�shift_idr_rZr#r#r%�	get_shift�rbzEmployee.get_shiftcCstt|dd�d|j�S)ror]N�email)r`rrrZr#r#r%�get_mail�szEmployee.get_mailcCs|��S�N)rsrZr#r#r%�	get_email��zEmployee.get_emailcCr\)zM
        This method is used to return the work type of the employee
        r]N�work_type_idr_rZr#r#r%�
get_work_type�rbzEmployee.get_work_typecCr\)�Q
        This method is used to return the employee type of the employee
        r]N�employee_type_idr_rZr#r#r%�get_employee_type�rlzEmployee.get_employee_typecCr\)ryr]N�reporting_manager_idr_rZr#r#r%�get_reporting_manager�rlzEmployee.get_reporting_managercCs4d|���d�}|jr|jj}t�|�r|jj}|S)zV
        Method will retun the api to the avatar or path to the profile image
        z!https://ui-avatars.com/api/?name=z&background=random)r[rS�namer
�existsrT)rUrT�
full_filenamer#r#r%�
get_avatar�s�
zEmployee.get_avatarcCs�t��}t�d�r|jj||d�nt���}td�}|�	�r>|jdd��	�r,td�}|S|jdd�r8td�}|Std	�}|St�d
�rP|j
j|d��	�rPtd�}|S)
zM
        This method is used to get the leave status of the employee
        �leave��start_date__lte�
end_date__gte�Expected working�approved)�status�On Leave�	requestedzWaiting ApprovalzCanceled / Rejected�
attendance��attendance_date�
On a break�r�todayr�is_installed�leaverequest_setrer�none�_r�employee_attendances)rUr��leaves_requestsr�r#r#r%�get_leave_status�s0���
�����zEmployee.get_leave_statuscCs�t��}t�d�r|jj||d�nt���}td�}|�	�rH|jdd��	�r,td�}|S|jdd��	�p9|jd	d�}|rBtd
�}|Std�}|St�d�rZ|j
j|d
��	�rZtd�}|S)zR
        This method is used to get the leave Type status of the employee
        r�r�r��)�
leave_type_idzWork From Home�
first_half)�start_date_breakdown�second_halfzHalf Dayr�r�r�r�r�)rUr�r�r��flagr#r#r%�get_leave_type�s2���
�����zEmployee.get_leave_typec
Cs�t�d�rlt��}|tdd�}d}d}t|jj||gd��d��}t	|�dkr0|dd}}nt	|�dkr;|\}}nd	\}}|}|sE|}t
t|d
d��}d}d}	|rW|��}t
d||�}	t|�t|	�||	|dud�SiS)
zO
        This method is used to the employees current day shift status
        r����daysN)�attendance_date__inr�r�)NN�minimum_hour�0)�forecasted_at_work�forecasted_pending_hours�forecasted_at_work_seconds� forecasted_pending_hours_seconds�has_attendance)rr�rr�r�listr�re�order_by�lenrr`�get_at_work_from_activities�maxr)
rUr��	yesterday�today_attendance�yesterday_attendance�attendancesr��minimum_hour_seconds�at_workr�r#r#r%�get_forecasted_at_worksD
��

��zEmployee.get_forecasted_at_workcCs|jjt��d���S)zF
        This method will returns employees todays attendance
        r�)r�rerr�rfrZr#r#r%�get_today_attendance@s
��zEmployee.get_today_attendancecCs�t�d�r tdd�}tdd�}|jj|jd�}|jj|jd�}nd}d}t�d�rDtdd�}tdd�}|jj|jd�}|jj|jd	�}nd}d}tjj|jd
�}	|	��sn|rZ|��sn|r`|��sn|rf|��sn|rl|��sndSg}
g}|	��r�|
�t	d�d
d��|��r�|
�t	d�dd��|��r�|
�t	d�dd��|��r�|
�t	d�dd��|��r�|
�t	d�dd��d|
i}zdt	d�fgdd�t
jjdd��ddd �D�}
|
|d!<W|SY|S)"a�
        Determine whether an employee is eligible for archiving based on their
        involvement in various processes.

        Returns:
            dict or bool: A dictionary containing a list of related models
                        if the employee is not eligible for archiving,
                        otherwise, False.

        This method checks the employee's association with different models,
        such as reporting manager, recruitment stage, onboarding stage, onboarding task,
        and recruitment manager. If the employee is not associated with any of these,
        they are considered eligible for archiving. If they are associated,
        a dictionary is returned with a list of related models of that employee.
        �
onboarding�onboardingstage�onboardingtask��employee_idN�recruitment�stage)�stage_managers)�recruitment_managers)r|FzReporting managerr|)r<�
field_namezRecruitment managerr�zRecruitment stage manager�recruitment_stage_managerszOnboarding stage manager�onboarding_stage_managerzOnboarding task manager�onboarding_task_manager�related_models�z---Choose employee---cSs,g|]\}}}||r|�d|��n|f�qS)rWr#)�.0r��
first_name�	last_namer#r#r%�
<listcomp>�s���z2Employee.get_archive_condition.<locals>.<listcomp>T)�	is_active�idrYrX�employee_choices)rr�rrdre�pk�EmployeeWorkInformationr�appendr�r'�values_list)rU�OnboardingStage�OnboardingTask�onboarding_stage_query�onboarding_task_query�Recruitment�Stage�recruitment_stage_query�recruitment_manager_query�reporting_manager_queryr��related_model_fields�related_models_dict�REPLACE_EMPLOYEE_CHOICESr#r#r%�get_archive_conditionHs�





�����������������������
�
	�zEmployee.get_archive_condition�returncCsF|jdur|jnd}|jdurd|j�d�nd}|j�d|�d|��S)Nr��(�)rW)rX�badge_idrY)rUr�r�r#r#r%�__str__�s�zEmployee.__str__cCs�t�d�rHtdd�}ttjdd�}|durHt|d�r|jdur@t�	��
�}|tdd�}|jj
||dd�jd	dd
�}t|d|�|j}|j|vSdS)zZ
        This method is used to check if the user is in the list of online users.
        r��requestN�working_employeesr�r�T)�attendance_date__gte�attendance_date__lte�!attendance_clock_out_date__isnullr�)�flatF)rr�rr`r�_thread_locals�hasattrr�r�nowrrrdrer��setattrr�)rU�
Attendancer�r�r�r�r#r#r%�check_online�s(

�
��
zEmployee.check_onlinec@s:eZdZdZdZdZdgZejdgej	dd�dd	�gZ
d
S)z
Employee.Metaz#
        Recruitment model
        )rYrXrr))�change_ownprofilezUpdate own profile)�view_ownprofilezView Own ProfilerYr�F)�badge_id__isnull�unique_badge_id)�fields�	conditionr~N)�__name__�
__module__�__qualname__�__doc__�unique_together�permissions�orderingr�UniqueConstraint�Q�constraintsr#r#r#r%�Meta�s�
��rcCsH|j}t��}t|j|j|j�}||krt|jd|j|j�}||jS)zC
        This method will calculate the day until birthday
        r�)�dobrr��year�month�dayr�)rU�birthdayr��
next_birthdayr#r#r%�days_until_birthday�s
zEmployee.days_until_birthdaycCs(ddlm}|jj|��d��d���S)z;
        This method is used to get last send mail
        r)�EmailLog)�
to__icontainsz-created_at)�base.modelsrrdrersr�rf)rUrr#r#r%�get_last_sent_mail�s
�zEmployee.get_last_sent_mailcCstjj|d�}|S)z�
        Function to get all Employee objects of subordinates reporting to a given manager.
        :param manager: Employee object who is the reporting manager.
        :return: QuerySet of Employee objects.
        )�(employee_work_info__reporting_manager_id)r'rdre)rU�subordinatesr#r#r%�get_subordinate_employees�s�z"Employee.get_subordinate_employeescs<tjj|jd���}t�j|i|��ttj	dd�}|r1|j
s1|��dur1d|_
t�j|i|��|}|rE|j|jkrE|j|j
_|j
��|j
dur�|j}|j}|j
rX|j
jnd}tjj||||d�}	|	sotjj|||d�}	|	|_
tjjdd�}
tjjd	d�}|	j�|�|	j�|
�t|d
�s�tjj|d�|��S|S)N)r�r�FT)�usernamerr�password�is_new_employee)rrrrr�)�codenamer�r]r�)r'rdrer�rf�super�saver`rr�r�r�rr�employee_user_idr�phonerr�create_userr�get�user_permissions�addr�r��
get_or_create)rU�args�kwargs�
prev_employeer��employeerr�is_new_employee_flag�userr�r���	__class__r#r%rsH


����
z
Employee.save)Jr�r�r�r��trans�
choice_gender�choice_maritalr�	CharFieldr��
OneToOneFieldr�CASCADEr�rrYrX�
ImageFieldrS�
EmailFieldrrr�	TextField�address�country�state�city�zip�	DateFieldr�gender�
qualification�IntegerField�
experience�marital_status�children�emergency_contact�emergency_contact_name�emergency_contact_relation�BooleanFieldr��	JSONField�additional_info�is_from_onboarding�is_directly_convertedrrdrVr[rarirkrnrqrsrurxr{r}r�r�r�r�r�r��strr�r�rrrrr�
__classcell__r#r#r"r%r'2s�


�


��
�����
����	

,er'c@s@eZdZdZejdded�d�Zejddd�Zde	fd	d
�Z
dS)�EmployeeTagz
    EmployeeTag Model
    r4T�Titler>rG)r5r6r�cC�|j�Srt��titlerZr#r#r%r�=rvzEmployeeTag.__str__N)r�r�r�r�rr'r�rG�colorrAr�r#r#r#r%rC5s
rCcseZdZdZejeejddded�d�Z	ej
eejdded�d�Z
ej
eejdded�d�Zej
eejdded	�d�Zej
eejdded
�d�Zej
eejdded�d�Zej
eejddded
�d�Zej
eejdded�d�Zejeded�d�Zejddded�d�Zejddded�d�Zejdddd�Z ej
e!ej"dded�d�Z#ej$dded�d�Z%ej$ddd�Z&ej'ddded�d�Z(ej'ddded �d�Z)ej*ddd!�Z+ej,dddd"�Z-e.d#e/gd$�Z0e1�Z2d%e3fd&d'�Z4�fd(d)�Z5�fd*d+�Z6d,d-�Z7d.d/�Z8�Z9S)0r�z'
    EmployeeWorkInformation model
    Tr]r'r9zJob Position)r:r6r7r<rz	Work Typez
Employee TypezJob Role�reporting_managerzReporting Managerr)r:r7r6r<zEmployee tag�r7r<r4z
Work Locationr?rB�Email)r5r7r6r<rF�ShiftzJoining Date)r6r7r<rMrzBasic Salary)r6r7rLr<zSalary Per HourrI)r6r7rL�history_set�r;�basesr�cC�|j�d|j��S)N� - )r�rjrZr#r#r%r���zEmployeeWorkInformation.__str__cs|��t�j|i|��dSrt)�
full_cleanrr�rUrrr"r#r%r�szEmployeeWorkInformation.savecst�j|i|��d|_dS)NF)r�__init__�skip_historyrTr"r#r%rU�s
z EmployeeWorkInformation.__init__cC�t|�S�zS
        This method is used to return the tracked history of the instance
        rrZr#r#r%�tracking��z EmployeeWorkInformation.trackingcCsF|j}|dur	dSt����}||}|j}|d}||_|��|S)zT
        This method is to calculate the default value for experience field
        Nrg�v@)�date_joiningrr�rr�r6r)rU�joining_date�current_date�delta�
total_daysr6r#r#r%�experience_calculator�sz-EmployeeWorkInformation.experience_calculator):r�r�r�r�rr(r'r)r�r��
ForeignKeyr�PROTECTrjrrmrrwrrzr�job_role_idr|rr^�ManyToManyFieldrC�tagsr'�locationr+rr�mobiler�
DO_NOTHINGrpr2r[�contract_end_dater5�basic_salary�salary_hourr=r>�
FloatFieldr6r"r!�historyrrdrAr�rrUrYr`rBr#r#r"r%r�As���������
�����
�����r�c@s�eZdZdZejeejdded�d�Z	ej
dd�Zej
dddd	d
�Zej
dd�Z
ejdd�Zej
dddd�Zej
ddd
�Zej
ddd
�Zej
ddd�Zej
ddddd�Zejddd�Zedd�Zdefdd�Zdd�ZdS)�EmployeeBankDetailsz#
    EmployeeBankDetails model
    T�employee_bank_detailsr')r:r6r;r<r4rEFr�)r5r6r7rL�rF)r5r7zBank Code #1)r5r<zBank Code #2r?rI�+employee_id__employee_work_info__company_idrQr�cCrP)N�-)r��	bank_namerZr#r#r%r��rRzEmployeeBankDetails.__str__cCs@|jdurtjj|jd�j|jd�}|rtdtd�i��dSdS)Nr�)�account_numberrtzCBank details for an employee with this account number already exist)rtrnrd�excluder�rer	r�)rU�bank_detailsr#r#r%�clean�s
������zEmployeeBankDetails.cleanN)r�r�r�r�rr(r'r)r�r�r'rsrt�branchr,r-r.r/r0�any_other_code1�any_other_code2r=r>rrdrAr�rwr#r#r#r%rn�s>����rnc@s,eZdZejdddd�Ze��Zdd�ZdS)�	NoteFileszemployee/NoteFilesT)rAr7r6cCs|jj�d�dS)N�/���)�filesr~�splitrZr#r#r%r�rRzNoteFiles.__str__N)	r�r�r�r�	FileFieldr~�Managerrdr�r#r#r#r%r{sr{c@sleZdZdZejeejdd�Zej	e
d�ddd�Zeje
dd�Zejeejd	�Zed
d�Zdefd
d�ZdS)�EmployeeNotez
    EmployeeNote model
    �
employee_name)r:r;�DescriptionrpT)r<r5r6�r7�r:rqrQr�cCrErt)�descriptionrZr#r#r%r�rvzEmployeeNote.__str__N)r�r�r�r�rrar'r)r�r,r�r�rdr{�
note_files�
updated_byrrdrAr�r#r#r#r%r�s �
��r�c@seZdZdZejdd�ZdS)�PolicyMultipleFilez$
    PoliciesMultipleFile model
    zemployee/policies)rAN)r�r�r�r�rr��
attachmentr#r#r#r%r�"sr�cszeZdZdZejdd�Ze��Zej	dd�Z
ejeddd�Z
ejedd�Zejeded	�d
�Zed�Z�fdd
�Z�ZS)�Policyz
    Policies model
    r4rETrNF)r7rOr�rrJr^cs$t�j|i|��|j����dSrt)r�delete�attachments�allrTr"r#r%r�8sz
Policy.delete)r�r�r�r�rr'rGr,�bodyr<�is_visible_to_allrdr'�specific_employeesr�r�rr�r^rrdr�rBr#r#r"r%r�*sr�c@s�eZdZdZded�fded�fded�fded	�fd
ed�fgZejeej	ddd
d�Z
ejddd�Zej
deddd�Zejddd�Zejdddd�Zedegd�Zedd�Zdd�Zdd�Zeeed�d d!��Zd"S)#�
BonusPointzS
    Model representing bonus points for employees with associated conditions.
    z==�equals�>zgrater than�<z	less thanz>=zgreater than or equalz<=zless than or equalT�bonus_point)r:r7r6r;rz&Use negative numbers to reduce points.)rL�	help_text�d)r5rKr7r6rMrp)r7r6r5rMrNrqrQcCs|j�d|j�d�S)NrQz Points)r��pointsrZr#r#r%r�bszBonusPoint.__str__cCrWrXrrZr#r#r%rYerZzBonusPoint.tracking)�sendercKs*tjj|jd���stjj|d�dSdS)a�
        Creates a BonusPoint instance for a newly created Employee if one doesn't already exist.

        Args:
            sender (Employee): The model class (Employee) sending the signal.
            instance (Employee): The instance of the Employee model triggering the
                                post-save signal.
            **_kwargs: Additional keyword arguments passed by the signal.
        )�employee_id__idr�N)r�rdrer�r�create)r��instance�_kwargsr#r#r%�bonus_post_saveks�zBonusPoint.bonus_post_saveN)r�r�r�r�r��
CONDITIONSrr(r'r)r�r5r�r'�encashment_condition�redeeming_pointsr,�reasonr"r!rmrrdr�rYrr
r�r#r#r#r%r�=sF




�������
r�c@s|eZdZdZded�fded�fded�fgZejdd	�Zejd
ed�Z	ej
ded
�dd�Zde
fdd�ZGdd�d�ZdS)�
Actiontypez
    Action type model
    �warning�Warning�
suspension�
Suspension�	dismissal�	Dismissalr4rErG)r5rKFzEnable login block :z[If is enabled, employees log in will be blocked based on period of suspension or dismissal.)rLr<r�r�cCrErtrFrZr#r#r%r��rvzActiontype.__str__c@seZdZed�Zed�ZdS)zActiontype.MetazAction TypezAction TypesN)r�r�r�r�r<�verbose_name_pluralr#r#r#r%r�srN)r�r�r�r�r$�choice_actionsrr'rG�action_typer<r��block_optionrAr�rr#r#r#r%r�zs


��r�c@s�eZdZdZded�fded�fgZejeed�d�Z	ej
eejd�Z
ejd	d
�Zejdedd�Zejd
dd�Zejddd
egd�Zejd
d�Zejdd
d
d�Zed�Zdefdd�ZGdd�d�ZdS)�DisciplinaryActionz
    Disciplinary model
    r��Days�hours�Hours�	Employees)r<r�rprErJ)r5rKrLTr�)r6rLr�z00:00)r5rLr6�
validators)r6zemployee/discipliner@rqr�cCrErt)�actionrZr#r#r%r��rvzDisciplinaryAction.__str__c@seZdZdgZdS)zDisciplinaryAction.Metaz-idN)r�r�r�r�r#r#r#r%r�s
rN)r�r�r�r�r�rKrrdr'r�rar�r)r�r,r�r'�unit_inr5r�rr�r2�
start_dater�r�rrdrAr�rr#r#r#r%r��s*��r�c@s8eZdZdZejddd�Zejedej	d�Z
ed�ZdS)	�EmployeeGeneralSettingz 
    EmployeeGeneralSetting
    ��GN0)r5rLT)r6r:r^N)
r�r�r�r�rr'�badge_id_prefixrarr)r^rrdr#r#r#r%r��s
r�)�ACCESSBILITY_FEATURE)�gender_chartzCan view Gender Chart)�department_chartzCan view Department Chart)�employees_chartzCan view Employees ChartN)Fr�rrr�django.appsr�django.confr�django.contrib.auth.modelsrr�django.core.exceptionsr	�django.core.files.storager
�	django.dbr�django.db.models.queryr�django.db.models.signalsr
�django.dispatchr�django.utils.translationrr�rr$�base.horilla_company_managerrr
rrrrrrrr�!employee.methods.duration_methodsrr�horillar�horilla.methodsr�horilla.modelsr�horilla_audit.methodsr �horilla_audit.modelsr!r"r&�Modelr'rCr�rnr{r�r�r�r�r�r�r��accessibility.accessibilityr�r�r#r#r#r%�<module>sV(
3=




Youez - 2016 - github.com/yon3zu
LinuXploit