Files
ihrm/attendance/models.py

1021 lines
34 KiB
Python
Raw Normal View History

"""
models.py
This module is used to register models for recruitment app
"""
import contextlib
import datetime as dt
import json
from datetime import date, datetime, timedelta
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
from django.apps import apps
from django.core.exceptions import ValidationError
2023-05-10 15:06:57 +05:30
from django.db import models
from django.db.models import Q
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
from django.utils import timezone
2023-05-10 15:06:57 +05:30
from django.utils.translation import gettext_lazy as _
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
from attendance.methods.utils import (
MONTH_MAPPING,
attendance_date_validate,
format_time,
get_diff_dict,
strtime_seconds,
validate_hh_mm_ss_format,
validate_time_format,
validate_time_in_minutes,
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
)
2023-12-01 15:36:51 +05:30
from base.horilla_company_manager import HorillaCompanyManager
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
from base.methods import is_company_leave, is_holiday
from base.models import Company, EmployeeShift, EmployeeShiftDay, WorkType
from employee.models import Employee
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
from horilla.methods import get_horilla_model_class
from horilla.models import HorillaModel
from horilla_audit.models import HorillaAuditInfo, HorillaAuditLog
2023-05-10 15:06:57 +05:30
# to skip the migration issue with the old migrations
_validate_time_in_minutes = validate_time_in_minutes
# Create your models here.
2023-05-10 15:06:57 +05:30
class AttendanceActivity(HorillaModel):
"""
AttendanceActivity model
"""
2023-07-05 11:46:47 +05:30
employee_id = models.ForeignKey(
Employee,
2023-09-20 15:02:36 +05:30
on_delete=models.PROTECT,
related_name="employee_attendance_activities",
2023-08-14 14:44:47 +05:30
verbose_name=_("Employee"),
)
attendance_date = models.DateField(
null=True,
validators=[attendance_date_validate],
verbose_name=_("Attendance Date"),
)
shift_day = models.ForeignKey(
EmployeeShiftDay,
null=True,
on_delete=models.DO_NOTHING,
verbose_name=_("Shift Day"),
)
in_datetime = models.DateTimeField(null=True)
clock_in_date = models.DateField(null=True, verbose_name=_("In Date"))
clock_in = models.TimeField(verbose_name=_("Check In"))
clock_out_date = models.DateField(null=True, verbose_name=_("Out Date"))
out_datetime = models.DateTimeField(null=True)
clock_out = models.TimeField(null=True, verbose_name=_("Check Out"))
2023-12-01 15:36:51 +05:30
objects = HorillaCompanyManager(
related_company_field="employee_id__employee_work_info__company_id"
)
2023-05-10 15:06:57 +05:30
class Meta:
"""
Meta class to add some additional options
"""
2023-07-05 11:46:47 +05:30
ordering = ["-attendance_date", "employee_id__employee_first_name", "clock_in"]
2023-05-10 15:06:57 +05:30
def duration(self):
"""
Duration calc b/w in-out method
"""
if not self.clock_out or not self.clock_out_date:
self.clock_out_date = datetime.today().date()
self.clock_out = datetime.now().time()
clock_in_datetime = datetime.combine(self.clock_in_date, self.clock_in)
clock_out_datetime = datetime.combine(self.clock_out_date, self.clock_out)
time_difference = clock_out_datetime - clock_in_datetime
return time_difference.total_seconds()
def __str__(self):
return f"{self.employee_id} - {self.attendance_date} - {self.clock_in} - {self.clock_out}"
2023-05-10 15:06:57 +05:30
class BatchAttendance(HorillaModel):
"""
Batch attendance model
"""
title = models.CharField(max_length=150, verbose_name=_("Title"))
def __str__(self):
return f"{self.title}-{self.id}"
class Attendance(HorillaModel):
"""
Attendance model
"""
2024-01-20 12:52:31 +05:30
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
2023-07-05 11:46:47 +05:30
status = [
2023-08-14 14:44:47 +05:30
("create_request", _("Create Request")),
("update_request", _("Update Request")),
("revalidate_request", _("Re-validate Request")),
]
2023-05-10 15:06:57 +05:30
employee_id = models.ForeignKey(
Employee,
2023-09-20 15:02:36 +05:30
on_delete=models.PROTECT,
null=True,
related_name="employee_attendances",
2023-08-14 14:44:47 +05:30
verbose_name=_("Employee"),
)
attendance_date = models.DateField(
null=False,
validators=[attendance_date_validate],
verbose_name=_("Attendance date"),
)
2023-05-10 15:06:57 +05:30
shift_id = models.ForeignKey(
EmployeeShift, on_delete=models.SET_NULL, null=True, verbose_name=_("Shift")
)
work_type_id = models.ForeignKey(
WorkType,
null=True,
blank=True,
2025-07-03 10:36:27 +05:30
on_delete=models.SET_NULL, # 796
2023-08-02 14:27:23 +05:30
verbose_name=_("Work Type"),
)
attendance_day = models.ForeignKey(
EmployeeShiftDay,
on_delete=models.DO_NOTHING,
null=True,
verbose_name=_("Attendance day"),
)
2023-08-02 14:27:23 +05:30
attendance_clock_in_date = models.DateField(
2023-10-17 10:20:24 +05:30
null=True, verbose_name=_("Check-In Date")
2023-07-11 12:12:25 +05:30
)
attendance_clock_in = models.TimeField(
2023-10-17 10:20:24 +05:30
null=True, verbose_name=_("Check-In"), help_text=_("First Check-In Time")
2023-07-11 12:12:25 +05:30
)
attendance_clock_out_date = models.DateField(
2023-10-17 10:20:24 +05:30
null=True, verbose_name=_("Check-Out Date")
)
attendance_clock_out = models.TimeField(
2023-10-17 10:20:24 +05:30
null=True, verbose_name=_("Check-Out"), help_text=_("Last Check-Out Time")
)
attendance_worked_hour = models.CharField(
2023-07-11 12:12:25 +05:30
null=True,
default="00:00",
max_length=10,
validators=[validate_time_format],
verbose_name=_("Worked Hours"),
)
minimum_hour = models.CharField(
2023-08-02 14:27:23 +05:30
max_length=10,
default="00:00",
validators=[validate_time_format],
verbose_name=_("Minimum hour"),
)
batch_attendance_id = models.ForeignKey(
BatchAttendance,
null=True,
blank=True,
on_delete=models.PROTECT,
verbose_name=_("Batch Attendance"),
)
attendance_overtime = models.CharField(
2023-07-11 12:12:25 +05:30
default="00:00",
validators=[validate_time_format],
max_length=10,
2023-08-02 14:27:23 +05:30
verbose_name=_("Overtime"),
2023-07-11 12:12:25 +05:30
)
attendance_overtime_approve = models.BooleanField(
default=False, verbose_name=_("Overtime Approve")
)
2023-08-14 14:44:47 +05:30
attendance_validated = models.BooleanField(
default=False, verbose_name=_("Attendance Validate")
2023-08-14 14:44:47 +05:30
)
at_work_second = models.IntegerField(null=True, blank=True)
overtime_second = models.IntegerField(
null=True, blank=True, verbose_name=_("Overtime In Second")
)
2023-05-10 15:06:57 +05:30
approved_overtime_second = models.IntegerField(default=0)
2023-08-14 14:44:47 +05:30
is_validate_request = models.BooleanField(
default=False, verbose_name=_("Is validate request")
)
is_bulk_request = models.BooleanField(default=False, editable=False)
2023-08-14 14:44:47 +05:30
is_validate_request_approved = models.BooleanField(
default=False, verbose_name=_("Is validate request approved")
)
request_description = models.TextField(
null=True, max_length=255, verbose_name=_("Request Description")
)
2023-08-14 14:44:47 +05:30
request_type = models.CharField(
max_length=18, null=True, choices=status, default="update_request"
)
is_holiday = models.BooleanField(default=False)
2023-08-14 14:44:47 +05:30
requested_data = models.JSONField(null=True, editable=False)
2023-12-01 15:36:51 +05:30
objects = HorillaCompanyManager(
related_company_field="employee_id__employee_work_info__company_id"
)
history = HorillaAuditLog(
related_name="history_set",
bases=[
HorillaAuditInfo,
],
)
2023-05-10 15:06:57 +05:30
class Meta:
"""
Meta class to add some additional options
"""
2023-07-05 11:46:47 +05:30
unique_together = ("employee_id", "attendance_date")
permissions = [
("change_validateattendance", "Validate Attendance"),
("change_approveovertime", "Change Approve Overtime"),
]
ordering = [
"-attendance_date",
"employee_id__employee_first_name",
"attendance_clock_in",
]
verbose_name = _("Attendance")
verbose_name_plural = _("Attendances")
2023-05-10 15:06:57 +05:30
def check_min_ot(self):
"""
Method to check the min ot for the attendance
"""
def is_night_shift(self):
"""
check is night shift or not
"""
day = self.attendance_day
if day is None:
return False
schedule = day.day_schedule.filter(shift_id=self.shift_id).first()
if not schedule:
return False
return schedule.is_night_shift
2023-05-10 15:06:57 +05:30
def __str__(self) -> str:
return f"{self.employee_id.employee_first_name} \
{self.employee_id.employee_last_name} - {self.attendance_date}"
2023-05-10 15:06:57 +05:30
def activities(self):
"""
This method is used to return the activites and count of activites comes for an attendance
"""
activities = AttendanceActivity.objects.filter(
attendance_date=self.attendance_date, employee_id=self.employee_id
)
return {"query": activities, "count": activities.count()}
def requested_fields(self):
"""
This method will returns the value difference fields
"""
keys = []
if self.requested_data is not None:
data = json.loads(self.requested_data)
diffs = get_diff_dict(self.serialize(), data)
keys = diffs.keys()
return keys
def get_last_clock_out(self, null_activity=False):
"""
This method is used to get the last attendance activity if exists
"""
activities = AttendanceActivity.objects.filter(
employee_id=self.employee_id,
attendance_date=self.attendance_date,
clock_out__isnull=null_activity,
).order_by("id")
return activities.last()
def get_at_work_from_activities(self):
"""
This method is used to retun the at work calculated from the activities
"""
activities = AttendanceActivity.objects.filter(
attendance_date=self.attendance_date, employee_id=self.employee_id
).order_by("clock_in")
at_work_seconds = 0
now = datetime.now()
for activity in activities:
out_time = activity.clock_out
if out_time is None:
combined_out = datetime.combine(
now, dt.time(hour=now.hour, minute=now.minute, second=now.second)
)
else:
combined_out = datetime.combine(activity.clock_out_date, out_time)
in_time = activity.clock_in
combined_in = datetime.combine(activity.clock_in_date, in_time)
diffs = combined_out - combined_in
at_work_seconds = at_work_seconds + diffs.total_seconds()
return at_work_seconds
def hours_pending(self):
"""
This method will returns difference between minimum_hour and attendance_worked_hour
"""
minimum_hours = strtime_seconds(self.minimum_hour)
worked_hour = strtime_seconds(self.attendance_worked_hour)
pending_seconds = minimum_hours - worked_hour
if pending_seconds < 0:
return "00:00"
pending_hours = format_time(pending_seconds)
return pending_hours
def adjust_minimum_hour(self):
"""
Set minimum_hour to 00:00 if the attendance date falls on a holiday or company leave.
"""
if is_holiday(self.attendance_date) or is_company_leave(self.attendance_date):
self.minimum_hour = "00:00"
self.is_holiday = True
def update_attendance_overtime(self):
"""
Calculate and update attendance overtime and worked seconds.
"""
2023-07-11 12:12:25 +05:30
self.attendance_overtime = format_time(
max(
0,
(
strtime_seconds(self.attendance_worked_hour)
- strtime_seconds(self.minimum_hour)
),
)
2023-07-11 12:12:25 +05:30
)
self.at_work_second = strtime_seconds(self.attendance_worked_hour)
self.overtime_second = strtime_seconds(self.attendance_overtime)
2023-07-11 12:12:25 +05:30
def handle_overtime_conditions(self):
condition = AttendanceValidationCondition.objects.first()
if self.is_validate_request:
self.is_validate_request_approved = self.attendance_validated = False
if condition:
# Handle overtime cutoff
if condition.overtime_cutoff:
cutoff_seconds = strtime_seconds(condition.overtime_cutoff)
if self.overtime_second > cutoff_seconds:
self.overtime_second = cutoff_seconds
self.attendance_overtime = format_time(cutoff_seconds)
# Auto-approve overtime if conditions are met
if condition.auto_approve_ot and self.overtime_second >= strtime_seconds(
condition.minimum_overtime_to_approve
):
self.attendance_overtime_approve = True
def save(self, *args, **kwargs):
self.update_attendance_overtime()
self.attendance_day = EmployeeShiftDay.objects.get(
day=self.attendance_date.strftime("%A").lower()
)
2023-05-10 15:06:57 +05:30
prev_attendance_approved = False
self.adjust_minimum_hour()
# Handle overtime cutoff and auto-approval
self.handle_overtime_conditions()
2024-01-01 11:14:18 +05:30
2023-05-10 15:06:57 +05:30
if self.pk is not None:
# Get the previous values of the boolean field
prev_state = Attendance.objects.get(pk=self.pk)
prev_attendance_approved = prev_state.attendance_overtime_approve
# super().save(*args, **kwargs) #commend this line, it take too much time to complete
employee_ot = self.employee_id.employee_overtime.filter(
month=self.attendance_date.strftime("%B").lower(),
year=self.attendance_date.year,
).first()
if employee_ot:
# Update if exists
self.update_ot(employee_ot)
2023-05-10 15:06:57 +05:30
else:
# Create and update in one call
employee_ot = self.create_ot()
self.update_ot(employee_ot)
2023-05-10 15:06:57 +05:30
approved = self.attendance_overtime_approve
attendance_account = self.employee_id.employee_overtime.filter(
month=self.attendance_date.strftime("%B").lower(),
year=self.attendance_date.year,
).first()
2023-05-10 15:06:57 +05:30
total_ot_seconds = attendance_account.overtime_second
if approved and prev_attendance_approved is False:
self.approved_overtime_second = self.overtime_second
total_ot_seconds = total_ot_seconds + self.approved_overtime_second
elif not approved:
total_ot_seconds = total_ot_seconds - self.approved_overtime_second
self.approved_overtime_second = 0
attendance_account.overtime = format_time(total_ot_seconds)
attendance_account.save()
super().save(*args, **kwargs)
def serialize(self):
"""
Used to serialize attendance instance
"""
# Return a dictionary containing the data you want to store
# strftime("%d %b %Y") date
# strftime("%I:%M %p") time
serialized_data = {
"employee_id": self.employee_id.id,
"attendance_date": str(self.attendance_date),
"attendance_clock_in_date": str(self.attendance_clock_in_date),
"attendance_clock_in": str(self.attendance_clock_in),
"attendance_clock_out": str(self.attendance_clock_out),
"attendance_clock_out_date": str(self.attendance_clock_out_date),
"shift_id": self.shift_id.id if self.shift_id else "",
"work_type_id": self.work_type_id.id if self.work_type_id else "",
"attendance_worked_hour": self.attendance_worked_hour,
2023-08-14 14:44:47 +05:30
"minimum_hour": self.minimum_hour,
"batch_attendance_id": (
self.batch_attendance_id.id if self.batch_attendance_id else ""
),
# Add other fields you want to store
}
return serialized_data
def delete(self, *args, **kwargs):
# Custom delete logic
# Perform additional operations before deleting the object
with contextlib.suppress(Exception):
AttendanceActivity.objects.filter(
attendance_date=self.attendance_date, employee_id=self.employee_id
).delete()
employee_ot = self.employee_id.employee_overtime.filter(
month=self.attendance_date.strftime("%B").lower(),
year=self.attendance_date.strftime("%Y"),
)
if employee_ot.exists():
self.update_ot(employee_ot.first())
# Call the superclass delete() method to delete the object
super().delete(*args, **kwargs)
# Perform additional operations after deleting the object
2023-05-10 15:06:57 +05:30
def create_ot(self):
"""
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.
"""
# Create or fetch the AttendanceOverTime instance
employee_ot, created = AttendanceOverTime.objects.get_or_create(
employee_id=self.employee_id,
month=self.attendance_date.strftime("%B").lower(),
year=self.attendance_date.year,
)
# Update only if the fields are available
2023-05-10 15:06:57 +05:30
if self.attendance_overtime_approve:
employee_ot.overtime = self.attendance_overtime
2023-05-10 15:06:57 +05:30
if self.attendance_validated:
employee_ot.hour_account = self.attendance_worked_hour
2023-05-10 15:06:57 +05:30
employee_ot.save()
return employee_ot
2023-05-10 15:06:57 +05:30
def update_ot(self, employee_ot):
"""
Update the hour account for the given employee.
Args:
employee_ot (obj): AttendanceOverTime instance
"""
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
if apps.is_installed("leave"):
approved_leave_requests = self.employee_id.leaverequest_set.filter(
start_date__lte=self.attendance_date,
end_date__gte=self.attendance_date,
status="approved",
)
else:
approved_leave_requests = []
# Create exclude condition using Q objects
exclude_condition = Q()
if approved_leave_requests:
# Combine multiple conditions for the exclude clause
for leave in approved_leave_requests:
exclude_condition |= Q(
attendance_date__range=(leave.start_date, leave.end_date)
)
# Filter month attendances in a single query
month_attendances = (
Attendance.objects.filter(
employee_id=self.employee_id,
attendance_date__month=self.attendance_date.month,
attendance_date__year=self.attendance_date.year,
attendance_validated=True,
)
.exclude(exclude_condition)
.values("minimum_hour", "at_work_second")
)
# Calculate hour balance and hours pending in a single loop
2023-05-10 15:06:57 +05:30
hour_balance = 0
minimum_hour_second = 0
2023-05-10 15:06:57 +05:30
for attendance in month_attendances:
required_work_second = strtime_seconds(attendance["minimum_hour"])
at_work_second = min(required_work_second, attendance["at_work_second"])
hour_balance += at_work_second
minimum_hour_second += required_work_second
hours_pending = minimum_hour_second - hour_balance
employee_ot.worked_hours = format_time(hour_balance)
employee_ot.pending_hours = format_time(hours_pending)
2023-05-10 15:06:57 +05:30
employee_ot.save()
2023-05-10 15:06:57 +05:30
return employee_ot
2023-07-05 11:46:47 +05:30
def clean(self, *args, **kwargs):
super().clean(*args, **kwargs)
now = datetime.now().time()
today = datetime.today().date()
# Convert to time if it's a string
if isinstance(self.attendance_clock_out, str):
out_time = datetime.strptime(self.attendance_clock_out, "%H:%M:%S").time()
else:
out_time = self.attendance_clock_out
2023-07-05 11:46:47 +05:30
if self.attendance_clock_in_date < self.attendance_date:
raise ValidationError(
{
"attendance_clock_in_date": "Attendance check-in date cannot be earlier than attendance date"
2023-07-05 11:46:47 +05:30
}
)
if (
self.attendance_clock_out_date
and self.attendance_clock_out_date < self.attendance_clock_in_date
):
2023-07-05 11:46:47 +05:30
raise ValidationError(
{
"attendance_clock_out_date": "Attendance check-out date cannot be earlier than check-in date"
2023-07-05 11:46:47 +05:30
}
)
2023-12-08 17:13:06 +05:30
if self.attendance_clock_out_date and self.attendance_clock_out_date >= today:
2023-07-05 11:46:47 +05:30
if out_time > now:
raise ValidationError(
{"attendance_clock_out": "Check-out time cannot be in the future"}
2023-07-05 11:46:47 +05:30
)
class AttendanceRequestFile(HorillaModel):
file = models.FileField(upload_to="attendance/request_files")
class AttendanceRequestComment(HorillaModel):
"""
AttendanceRequestComment Model
"""
request_id = models.ForeignKey(Attendance, on_delete=models.CASCADE)
employee_id = models.ForeignKey(Employee, on_delete=models.CASCADE)
files = models.ManyToManyField(AttendanceRequestFile, blank=True)
comment = models.TextField(null=True, verbose_name=_("Comment"), max_length=255)
def __str__(self) -> str:
return f"{self.comment}"
class AttendanceOverTime(HorillaModel):
"""
AttendanceOverTime model
"""
2023-07-05 11:46:47 +05:30
employee_id = models.ForeignKey(
Employee,
2023-09-20 15:02:36 +05:30
on_delete=models.PROTECT,
related_name="employee_overtime",
2023-08-14 14:44:47 +05:30
verbose_name=_("Employee"),
)
month = models.CharField(
max_length=10,
verbose_name=_("Month"),
)
2023-05-10 15:06:57 +05:30
month_sequence = models.PositiveSmallIntegerField(default=0)
year = models.CharField(
default=datetime.now().strftime("%Y"),
null=True,
max_length=10,
verbose_name=_("Year"),
)
worked_hours = models.CharField(
max_length=10,
default="00:00",
null=True,
validators=[validate_time_format],
verbose_name=_("Worked Hours"),
)
pending_hours = models.CharField(
max_length=10,
default="00:00",
null=True,
validators=[validate_time_format],
verbose_name=_("Pending Hours"),
)
overtime = models.CharField(
max_length=20,
default="00:00",
validators=[validate_time_format],
verbose_name=_("Overtime Hours"),
)
hour_account_second = models.IntegerField(
default=0,
null=True,
verbose_name=_("Worked Seconds"),
)
hour_pending_second = models.IntegerField(
default=0,
null=True,
verbose_name=_("Pending Seconds"),
)
overtime_second = models.IntegerField(
default=0,
null=True,
verbose_name=_("Overtime Seconds"),
)
2023-12-01 15:36:51 +05:30
objects = HorillaCompanyManager(
related_company_field="employee_id__employee_work_info__company_id"
)
2023-05-10 15:06:57 +05:30
class Meta:
"""
Meta class to add some additional options
"""
2023-07-05 11:46:47 +05:30
unique_together = [("employee_id"), ("month"), ("year")]
ordering = ["-year", "-month_sequence"]
verbose_name = _("Hour Account")
verbose_name_plural = _("Hour Accounts")
2023-05-10 15:06:57 +05:30
def clean(self):
try:
year = int(self.year)
if not (1900 <= year <= 2100):
raise ValidationError(
{"year": _("Year must be an integer value between 1900 and 2100")}
)
except (ValueError, TypeError):
raise ValidationError(
{"year": _("Year must be an integer value between 1900 and 2100")}
)
def month_days(self):
"""
this method is used to create new AttendanceOvertime's instance if there
is no existing for a specific month and year
"""
month = self.month_sequence + 1
year = int(self.year)
start_date = date(year, month, 1)
if month == 12:
end_date = date(year + 1, 1, 1) - timedelta(days=1)
else:
end_date = date(year, month + 1, 1) - timedelta(days=1)
return start_date, end_date
def not_validated_hrs(self):
"""
This method will return not validated hours in a month
"""
hrs_to_vlaidate = sum(
list(
Attendance.objects.filter(
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
attendance_date__month=MONTH_MAPPING[self.month],
attendance_date__year=self.year,
employee_id=self.employee_id,
attendance_validated=False,
).values_list("at_work_second", flat=True)
)
)
return format_time(hrs_to_vlaidate)
def not_approved_ot_hrs(self):
"""
This method will return the overtime hours to be approved
"""
hrs_to_approve = sum(
list(
Attendance.objects.filter(
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
attendance_date__month=MONTH_MAPPING[self.month],
attendance_date__year=self.year,
employee_id=self.employee_id,
attendance_validated=True,
attendance_overtime_approve=False,
).values_list("overtime_second", flat=True)
)
)
return format_time(hrs_to_approve)
def get_month_index(self):
"""
This method will return the index of the month
"""
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
return MONTH_MAPPING[self.month]
2023-05-10 15:06:57 +05:30
def save(self, *args, **kwargs):
self.hour_account_second = strtime_seconds(self.worked_hours)
self.hour_pending_second = strtime_seconds(self.pending_hours)
2023-05-10 15:06:57 +05:30
self.overtime_second = strtime_seconds(self.overtime)
month_name = self.month.split("-")[0]
months = [
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
"november",
"december",
]
2023-05-10 15:06:57 +05:30
self.month_sequence = months.index(month_name)
super().save(*args, **kwargs)
2023-05-10 15:06:57 +05:30
class AttendanceLateComeEarlyOut(HorillaModel):
"""
AttendanceLateComeEarlyOut model
"""
2023-07-05 11:46:47 +05:30
2023-05-10 15:06:57 +05:30
choices = [
("late_come", _("Late Come")),
("early_out", _("Early Out")),
2023-05-10 15:06:57 +05:30
]
attendance_id = models.ForeignKey(
Attendance,
on_delete=models.PROTECT,
related_name="late_come_early_out",
verbose_name=_("Attendance"),
)
employee_id = models.ForeignKey(
Employee,
on_delete=models.DO_NOTHING,
null=True,
related_name="late_come_early_out",
2023-08-14 14:44:47 +05:30
verbose_name=_("Employee"),
editable=False,
)
type = models.CharField(max_length=20, choices=choices, verbose_name=_("Type"))
2023-12-01 15:36:51 +05:30
objects = HorillaCompanyManager(
related_company_field="employee_id__employee_work_info__company_id"
)
created_at = models.DateTimeField(auto_now_add=True, null=True)
def get_penalties_count(self):
"""
This method is used to return the total penalties in the late early instance
"""
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
return self.penaltyaccounts_set.count()
def save(self, *args, **kwargs) -> None:
super().save(*args, **kwargs)
self.employee_id = self.attendance_id.employee_id
super().save(*args, **kwargs)
2023-05-10 15:06:57 +05:30
class Meta:
"""
Meta class to add some additional options
"""
2023-07-05 11:46:47 +05:30
unique_together = [("attendance_id"), ("type")]
2024-02-01 13:01:38 +05:30
ordering = ["-attendance_id__attendance_date"]
2023-05-10 15:06:57 +05:30
def __str__(self) -> str:
return f"{self.attendance_id.employee_id.employee_first_name} \
{self.attendance_id.employee_id.employee_last_name} - {self.type}"
2023-05-10 15:06:57 +05:30
class AttendanceValidationCondition(HorillaModel):
"""
AttendanceValidationCondition model
"""
2023-07-05 11:46:47 +05:30
validation_at_work = models.CharField(
max_length=10,
validators=[validate_time_format],
verbose_name=_("Worked Hours Auto Approve Till"),
)
minimum_overtime_to_approve = models.CharField(
blank=True, null=True, max_length=10, validators=[validate_time_format]
)
overtime_cutoff = models.CharField(
blank=True, null=True, max_length=10, validators=[validate_time_format]
)
auto_approve_ot = models.BooleanField(
default=False, verbose_name=_("Auto Approve OT")
)
company_id = models.ManyToManyField(Company, blank=True, verbose_name=_("Company"))
2023-12-01 15:36:51 +05:30
objects = HorillaCompanyManager()
2023-05-10 15:06:57 +05:30
def clean(self):
"""
This method is used to perform some custom validations
"""
2023-05-10 15:06:57 +05:30
super().clean()
if not self.id and AttendanceValidationCondition.objects.exists():
raise ValidationError(_("You cannot add more conditions."))
class GraceTime(HorillaModel):
"""
Model for saving Grace time
"""
allowed_time = models.CharField(
default="00:00:00",
validators=[validate_hh_mm_ss_format],
max_length=10,
verbose_name=_("Allowed Time"),
)
allowed_time_in_secs = models.IntegerField()
allowed_clock_in = models.BooleanField(
default=True,
help_text=_("Allcocate this grace time for Check-In Attendance"),
verbose_name=_("Allowed Clock-In"),
)
allowed_clock_out = models.BooleanField(
default=False,
help_text=_("Allcocate this grace time for Check-Out Attendance"),
verbose_name=_("Allowed Clock-Out"),
)
is_default = models.BooleanField(default=False)
company_id = models.ManyToManyField(Company, blank=True, verbose_name=_("Company"))
objects = HorillaCompanyManager()
def __str__(self) -> str:
return str(f"{self.allowed_time} - Hours")
def clean(self):
"""
This method is used to perform some custom validations
"""
super().clean()
if self.is_default:
if GraceTime.objects.filter(is_default=True).exclude(id=self.id).exists():
raise ValidationError(
_("There is already a default grace time that exists.")
)
allowed_time = self.allowed_time
2024-01-31 12:12:43 +05:30
is_default = self.is_default
exclude_default = not is_default
if (
GraceTime.objects.filter(allowed_time=allowed_time)
2024-01-31 12:12:43 +05:30
.exclude(is_default=exclude_default)
.exclude(id=self.id)
.exists()
):
raise ValidationError(
{
"allowed_time": _(
"There is already an existing grace time with this allowed time."
)
}
)
def save(self, *args, **kwargs):
allowed_time = self.allowed_time
hours, minutes, secs = allowed_time.split(":")
hours_int = int(hours)
minutes_int = int(minutes)
secs_int = int(secs)
hours_str = f"{hours_int:02d}"
minutes_str = f"{minutes_int:02d}"
secs_str = f"{secs_int:02d}"
self.allowed_time = f"{hours_str}:{minutes_str}:{secs_str}"
self.allowed_time_in_secs = hours_int * 3600 + minutes_int * 60 + secs_int
super().save(*args, **kwargs)
class AttendanceGeneralSetting(HorillaModel):
"""
AttendanceGeneralSettings
"""
time_runner = models.BooleanField(default=True)
enable_check_in = models.BooleanField(
default=True,
verbose_name=_("Enable Check in/Check out"),
help_text=_(
"Enabling this feature allows employees to record their attendance using the Check-In/Check-Out button."
),
)
company_id = models.ForeignKey(Company, on_delete=models.CASCADE, null=True)
objects = HorillaCompanyManager()
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
class WorkRecords(models.Model):
"""
WorkRecord Model
"""
choices = [
("FDP", _("Present")),
("HDP", _("Half Day Present")),
("ABS", _("Absent")),
("HD", _("Holiday/Company Leave")),
("CONF", _("Conflict")),
("DFT", _("Draft")),
]
record_name = models.CharField(max_length=250, null=True, blank=True)
work_record_type = models.CharField(max_length=5, null=True, choices=choices)
employee_id = models.ForeignKey(
Employee, on_delete=models.CASCADE, verbose_name=_("Employee")
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
)
date = models.DateField(null=True, blank=True)
at_work = models.CharField(
null=True,
blank=True,
validators=[
validate_time_format,
],
default="00:00",
max_length=5,
)
min_hour = models.CharField(
null=True,
blank=True,
validators=[
validate_time_format,
],
default="00:00",
max_length=5,
)
at_work_second = models.IntegerField(null=True, blank=True, default=0)
min_hour_second = models.IntegerField(null=True, blank=True, default=0)
note = models.TextField(max_length=255)
message = models.CharField(max_length=30, null=True, blank=True)
is_attendance_record = models.BooleanField(default=False)
attendance_id = models.ForeignKey(
Attendance, on_delete=models.SET_NULL, blank=True, null=True
)
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
is_leave_record = models.BooleanField(default=False)
if apps.is_installed("leave"):
leave_request_id = models.ForeignKey(
"leave.LeaveRequest",
on_delete=models.SET_NULL,
blank=True,
null=True,
)
shift_id = models.ForeignKey(
EmployeeShift, on_delete=models.SET_NULL, blank=True, null=True
)
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
day_percentage = models.FloatField(default=0)
last_update = models.DateTimeField(null=True, blank=True)
objects = HorillaCompanyManager("employee_id__employee_work_info__company_id")
def title_message(self):
title_message = self.message
if title_message == "Leave":
if apps.is_installed("leave"):
title_message += f" | {self.leave_request_id.leave_type_id}"
return title_message
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
def save(self, *args, **kwargs):
self.last_update = timezone.now()
super().save(*args, **kwargs)
def clean(self):
super().clean()
if not 0.0 <= self.day_percentage <= 1.0:
raise ValidationError(_("Day percentage must be between 0.0 and 1.0"))
def __str__(self):
return (
self.record_name
if self.record_name is not None
else f"{self.work_record_type}-{self.date}-{self.employee_id}"
[IMP] Remove inter module dependency (#274) This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made: 1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase. 2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation. 3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules. These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code. **NOTE** For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations. - `python3 manage.py makemigrations` - `python3 manage.py migrate base` - `python3 manage.py migrate` * [IMP] ASSET: Asset module dependency removal from other Horilla apps * [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps * [IMP] BASE: Base module dependency removal from other Horilla apps * [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps * [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps * [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps * [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps * [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps * [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps * [IMP] LEAVE: Leave module dependency removal from other Horilla apps * [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps * [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps * [IMP] PMS: PMS module dependency removal from other Horilla apps * [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps * [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps * [IMP] HORILLA: Dependency removal updates * [IMP] TEMPLATES: Dependency removal updates * [IMP] STATIC: Dependency removal updates * [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps * [ADD] HORILLA: methods.py * [UPDT] HORILLA: Settings.py * [FIX] EMPLOYEE: About tab issue * Update horilla_settings.py * Remove dummy db init password
2024-08-05 14:22:44 +05:30
)
class Meta:
verbose_name = _("Work Record")
verbose_name_plural = _("Work Records")
# unique_together = ['date', 'employee_id']