[UPDT] PAYROLL: Contract initial value update flow and methods
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
forms.py
|
||||
"""
|
||||
from django import forms
|
||||
from django.forms import widgets
|
||||
from django.utils.translation import gettext_lazy as trans
|
||||
from django.template.loader import render_to_string
|
||||
from payroll.models.models import WorkRecord
|
||||
@@ -55,7 +56,12 @@ class ContractForm(ModelForm):
|
||||
"""
|
||||
ContactForm
|
||||
"""
|
||||
|
||||
verbose_name = trans("Contract")
|
||||
contract_start_date = forms.DateField()
|
||||
contract_end_date = forms.DateField()
|
||||
|
||||
|
||||
class Meta:
|
||||
"""
|
||||
Meta class for additional options
|
||||
@@ -69,23 +75,23 @@ class ContractForm(ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["contract_name"].widget.attrs["autocomplete"] = "off"
|
||||
self.fields["contract_start_date"].widget.attrs["autocomplete"] = "off"
|
||||
self.fields["contract_start_date"].widget.attrs["class"] = "oh-input w-100"
|
||||
self.fields["contract_start_date"].widget = forms.TextInput(
|
||||
attrs={"type": "date", "class": "oh-input w-100"}
|
||||
self.fields["employee_id"].widget.attrs.update(
|
||||
{"onchange": "contractInitial(this)"}
|
||||
)
|
||||
self.fields["contract_end_date"].widget.attrs["autocomplete"] = "off"
|
||||
self.fields["contract_end_date"].widget.attrs["class"] = "oh-input w-100"
|
||||
self.fields["contract_end_date"].widget = forms.TextInput(
|
||||
attrs={"type": "date", "class": "oh-input w-100"}
|
||||
self.fields["contract_start_date"].widget = widgets.DateInput(
|
||||
attrs={
|
||||
"type":"date",
|
||||
"class": "oh-input w-100",
|
||||
"placeholder": "Select a date",
|
||||
}
|
||||
)
|
||||
self.fields["contract_end_date"].widget = widgets.DateInput(
|
||||
attrs={
|
||||
"type":"date",
|
||||
"class": "oh-input w-100",
|
||||
"placeholder": "Select a date",
|
||||
}
|
||||
)
|
||||
self.fields["employee_id"].widget.attrs["data-contract-style"] = ""
|
||||
self.fields["department"].widget.attrs["data-contract-style"] = ""
|
||||
self.fields["job_position"].widget.attrs["data-contract-style"] = ""
|
||||
self.fields["job_role"].widget.attrs["data-contract-style"] = ""
|
||||
self.fields["work_type"].widget.attrs["data-contract-style"] = ""
|
||||
self.fields["shift"].widget.attrs["data-contract-style"] = ""
|
||||
|
||||
def as_p(self):
|
||||
"""
|
||||
|
||||
@@ -484,7 +484,9 @@ class OverrideLeaveRequest(LeaveRequest):
|
||||
work_entry.work_record_type = status
|
||||
work_entry.date = date
|
||||
work_entry.message = (
|
||||
"Validated" if status == "ABS" else _("Half day need to validate")
|
||||
"Validated"
|
||||
if status == "ABS"
|
||||
else _("Half day need to validate")
|
||||
)
|
||||
work_entry.save()
|
||||
except:
|
||||
@@ -868,6 +870,16 @@ class Allowance(models.Model):
|
||||
def __str__(self) -> str:
|
||||
return str(self.title)
|
||||
|
||||
def save(self):
|
||||
super().save()
|
||||
if (
|
||||
not self.include_active_employees
|
||||
and not self.specific_employees.first()
|
||||
and not self.is_condition_based
|
||||
):
|
||||
self.include_active_employees = True
|
||||
super().save()
|
||||
|
||||
|
||||
class Deduction(models.Model):
|
||||
"""
|
||||
@@ -1112,6 +1124,16 @@ class Deduction(models.Model):
|
||||
def __str__(self) -> str:
|
||||
return str(self.title)
|
||||
|
||||
def save(self):
|
||||
super().save()
|
||||
if (
|
||||
not self.include_active_employees
|
||||
and not self.specific_employees.first()
|
||||
and not self.is_condition_based
|
||||
):
|
||||
self.include_active_employees = True
|
||||
super().save()
|
||||
|
||||
|
||||
class Payslip(models.Model):
|
||||
"""
|
||||
@@ -1124,7 +1146,7 @@ class Payslip(models.Model):
|
||||
("confirmed", _("Confirmed")),
|
||||
("paid", _("Paid")),
|
||||
]
|
||||
group_name = models.CharField(max_length=50,null=True,blank=True)
|
||||
group_name = models.CharField(max_length=50, null=True, blank=True)
|
||||
reference = models.CharField(max_length=255, unique=False)
|
||||
employee_id = models.ForeignKey(
|
||||
Employee, on_delete=models.PROTECT, verbose_name=_("Employee")
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user