| 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 : |
o
hͦhwG � @ s d Z ddlZddlmZmZmZ ddlmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZmZmZmZmZ dd lmZmZ dd
lmZ ddlmZmZmZ dd
� 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�Payslipc C s || }|j d }|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_days s
r c s t �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� krn n|�qS r r ��.0r �r r r r �
<listcomp>M �
�zget_leaves.<locals>.<listcomp>c r% r r r&