Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add anniversary leave reset #508

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b85020b
Update docker-compose.yaml
JVKeller Dec 2, 2024
effa0ed
Update Dockerfile
JVKeller Dec 2, 2024
a5093b0
Update docker-compose.yaml
JVKeller Dec 3, 2024
2a48df6
Update entrypoint.sh
JVKeller Dec 3, 2024
819d7cd
Merge branch 'horilla-opensource:master' into master
JVKeller Dec 11, 2024
31eb8c1
Merge branch 'horilla-opensource:master' into master
JVKeller Dec 12, 2024
dd8f9ff
Merge branch 'horilla-opensource:master' into master
JVKeller Dec 18, 2024
a305038
Merge branch 'horilla-opensource:master' into master
JVKeller Dec 20, 2024
cbf0e2a
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 3, 2025
919191c
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 6, 2025
71c0e91
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 7, 2025
bdae3c9
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 9, 2025
834983e
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 10, 2025
b8fba25
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 13, 2025
a65a0dc
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 14, 2025
af0bfc2
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 16, 2025
6bc6b6a
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 20, 2025
6dff435
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 22, 2025
68cec60
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 23, 2025
4f9c207
Merge branch 'horilla-opensource:master' into master
JVKeller Jan 24, 2025
b6fca4f
Added anniversary-based leave reset functionality
Jan 27, 2025
9af7387
Added anniversary-based leave reset functionality and employee annive…
JVKeller Jan 27, 2025
510de89
Adding Anniversary Reset
JVKeller Jan 27, 2025
6bcded8
Anniversary Reset
JVKeller Jan 28, 2025
2200f2e
Anniversary Reset
JVKeller Jan 28, 2025
da0bd9c
fix table names
JVKeller Jan 29, 2025
05d5ebf
Merge branch 'horilla-opensource:master' into anniversary
JVKeller Jan 31, 2025
ce5d9e8
regenerate static files
JVKeller Jan 31, 2025
769a21a
Merge branch 'anniversary' of https://github.com/JVKeller/horilla int…
JVKeller Jan 31, 2025
ae9ec46
Fix typos
JVKeller Jan 31, 2025
884181b
Leave cancled after new leave was assigned was incorrectly adding to …
JVKeller Jan 31, 2025
547d4db
Merge branch 'horilla-opensource:master' into anniversary
JVKeller Feb 3, 2025
2b3eb8d
Fixing reset functions
JVKeller Feb 17, 2025
9efa15d
Reverting to master
JVKeller Feb 17, 2025
e1671ec
Removing extra files
JVKeller Feb 17, 2025
51b07f5
Syncing Files
JVKeller Feb 17, 2025
fe24317
Sync
JVKeller Feb 17, 2025
1063c22
Sync
JVKeller Feb 17, 2025
95c8114
Sync
JVKeller Feb 17, 2025
7b9cd62
Merge branch 'horilla-opensource:master' into add_anniversary_leave_r…
JVKeller Feb 17, 2025
d68e55d
Reverting Files
JVKeller Feb 17, 2025
ef5dee0
Merge branch 'add_anniversary_leave_reset' of https://github.com/JVKe…
JVKeller Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ DB_PORT=5432
# Microsoft SQL Server: ``mssql://``
# PyODBC: ``pyodbc://``
# Amazon Redshift: ``redshift://``
# LDAP: ``ldap://``
# LDAP: ``ldap://``
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ services:
retries: 5

volumes:
horilla-data:
horilla-data:
2 changes: 2 additions & 0 deletions employee/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class Meta:
"email",
"mobile",
"date_joining",
"anniversary_date",
"contract_end_date",
"tags",
"basic_salary",
Expand All @@ -295,6 +296,7 @@ class Meta:
widgets = {
"date_joining": DateInput(attrs={"type": "date"}),
"contract_end_date": DateInput(attrs={"type": "date"}),
"anniversary_date": DateInput(attrs={"type": "date", "class": "oh-input w-100", "placeholder": _("Select Anniversary Date"),}),
}

def __init__(self, *args, disable=False, **kwargs):
Expand Down
25 changes: 25 additions & 0 deletions employee/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,12 @@ class EmployeeWorkInformation(models.Model):
)
additional_info = models.JSONField(null=True, blank=True)
experience = models.FloatField(null=True, blank=True, default=0)
anniversary_date = models.DateField(
null=True,
blank=True,
verbose_name=_("Anniversary Date"),
help_text=_("Date used for anniversary-based leave resets")
)
history = HorillaAuditLog(
related_name="history_set",
bases=[
Expand Down Expand Up @@ -684,6 +690,25 @@ def experience_calculator(self):
self.save()
return self

def clean(self):
super().clean()
if self.anniversary_date:
# Ensure anniversary date isn't in the future
if self.anniversary_date > timezone.now().date():
raise ValidationError({
'anniversary_date': _('Anniversary date cannot be in the future')
})

# Check if employee has anniversary-based leave types
has_anniversary_leaves = self.employee_id.available_leave.filter(
leave_type_id__reset_based='anniversary'
).exists()

if has_anniversary_leaves and not self.anniversary_date:
raise ValidationError({
'anniversary_date': _('Anniversary date is required for employees with anniversary-based leave types')
})


class EmployeeBankDetails(HorillaModel):
"""
Expand Down
8 changes: 7 additions & 1 deletion employee/templates/employee/profile/work_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@
</div>
</div>
</div>

<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-lg-6">
<div class="oh-input-group">
<label class="oh-label" for="endDate">{% trans "Contract End Date" %}</label>
{{work_form.anniversary_date}}
</div>
</div>

</form>
</div>
Expand Down
24 changes: 21 additions & 3 deletions employee/templates/tabs/personal_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,20 @@
class="oh-profile__info-value dateformat_changer">{{employee.employee_work_info.date_joining|default:_("None")}}</span>
</li>

<li class="oh-profile__card-info-item">
<span class="oh-profile__info-label mb-1">
<ion-icon name="calendar-outline"></ion-icon>
<span>{% trans "Anniversary Date" %}</span>
</span>
{% if employee.employee_work_info.anniversary_date %}
<span
class="oh-profile__info-value dateformat_changer">{{ employee.employee_work_info.anniversary_date }}</span>
{% else %}
<span class="oh-profile__info-value">{% trans "None" %}</span>
{% endif %}

</li>

<li class="oh-profile__card-info-item">
<span class="oh-profile__info-label mb-1">
<ion-icon name="business-outline"></ion-icon>
Expand All @@ -273,9 +287,13 @@
{% if employee.employee_work_info.tags.all %}
{% for i in employee.employee_work_info.tags.all %}
{% with tag_width=i.title|length %}
<span class="oh-profile__info-value mt-1 mb-1 mr-1"
style="background-color: {{ i.color }};
font-size: .8rem; padding: 4px 10px; border-radius: 18px; font-weight: 600; width: {{ tag_width }}em;">{{ i.title }}</span>
<span
id="dynamicSpan"
class="oh-profile__info-value mt-1 mb-1 mr-1"
style="font-size: .8rem; padding: 4px 10px; border-radius: 18px; font-weight: 600;"
>
{{ i.title }}
</span>
{% endwith %}
{% endfor %}
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ python3 manage.py makemigrations
python3 manage.py migrate
python3 manage.py collectstatic --noinput
python3 manage.py createhorillauser --first_name admin --last_name admin --username admin --password admin --email [email protected] --phone 1234567890
gunicorn --bind 0.0.0.0:8000 horilla.wsgi:application
gunicorn --bind 0.0.0.0:8000 horilla.wsgi:application
4 changes: 2 additions & 2 deletions horilla/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@

LANGUAGE_CODE = "en-us"

# Timezone settings
TIME_ZONE = env("TIME_ZONE", default="Asia/Kolkata")
USE_TZ = True

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Production settings
if not DEBUG:
SECURE_BROWSER_XSS_FILTER = True
Expand Down
19 changes: 15 additions & 4 deletions leave/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@ def clean(self):
cleaned_data["reset_month"] = "1"
cleaned_data["reset_day"] = "1"

reset = cleaned_data.get('reset')
reset_based = cleaned_data.get('reset_based')
reset_month = cleaned_data.get('reset_month')
reset_day = cleaned_data.get('reset_day')

if reset and reset_based != 'anniversary':
if not reset_month:
raise ValidationError(_('Reset month is required when reset is enabled'))
if not reset_day:
raise ValidationError(_('Reset day is required when reset is enabled'))

return cleaned_data

def save(self, *args, **kwargs):
Expand Down Expand Up @@ -388,7 +399,7 @@ def clean(self):
if f"{today.month}-{today.year}" in unique_dates:
unique_dates.remove(f"{today.strftime('%m')}-{today.year}")

forcated_days = available_leave.forcasted_leaves(start_date)
forcasted_days = available_leave.forcasted_leaves(start_date)
total_leave_days = (
available_leave.leave_type_id.carryforward_max
if available_leave.leave_type_id.carryforward_type
Expand All @@ -401,7 +412,7 @@ def clean(self):
and available_leave.carryforward_days
):
total_leave_days = total_leave_days - available_leave.carryforward_days
total_leave_days += forcated_days
total_leave_days += forcasted_days

if not effective_requested_days <= total_leave_days:
raise forms.ValidationError(_("Employee doesn't have enough leave days.."))
Expand Down Expand Up @@ -516,7 +527,7 @@ def clean(self):
if f"{today.month}-{today.year}" in unique_dates:
unique_dates.remove(f"{today.strftime('%m')}-{today.year}")

forcated_days = available_leave.forcasted_leaves(start_date)
forcasted_days = available_leave.forcasted_leaves(start_date)
total_leave_days = (
available_leave.leave_type_id.carryforward_max
if available_leave.leave_type_id.carryforward_type
Expand All @@ -529,7 +540,7 @@ def clean(self):
and available_leave.carryforward_days
):
total_leave_days = total_leave_days - available_leave.carryforward_days
total_leave_days += forcated_days
total_leave_days += forcasted_days

if not effective_requested_days <= total_leave_days:
raise forms.ValidationError(_("Employee doesn't have enough leave days.."))
Expand Down
Loading