From e655589e9a911cbbe4a8486ca5262ee32033540d Mon Sep 17 00:00:00 2001 From: Horilla Date: Fri, 13 Dec 2024 15:34:38 +0530 Subject: [PATCH] [UPDT] PAYROLL: Add condition in contract creation signals --- employee/methods/methods.py | 4 +++- payroll/models/models.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/employee/methods/methods.py b/employee/methods/methods.py index 1b804cd04..6d3ef852e 100644 --- a/employee/methods/methods.py +++ b/employee/methods/methods.py @@ -392,7 +392,9 @@ def create_contracts_in_thread(new_work_info_list, update_work_info_list): Contract( contract_name=f"{work_info.employee_id}'s Contract", employee_id=work_info.employee_id, - contract_start_date=datetime.today(), + contract_start_date=( + work_info.date_joining if work_info.date_joining else datetime.today() + ), department=get_or_none(work_info.department_id), job_position=get_or_none(work_info.job_position_id), job_role=get_or_none(work_info.job_role_id), diff --git a/payroll/models/models.py b/payroll/models/models.py index 1dc0e1544..380149cea 100644 --- a/payroll/models/models.py +++ b/payroll/models/models.py @@ -633,7 +633,9 @@ class OverrideWorkInfo(EmployeeWorkInformation): contract = Contract() contract.contract_name = f"{active_employee}'s Contract" contract.employee_id = active_employee - contract.contract_start_date = datetime.today() + contract.contract_start_date = ( + instance.date_joining if instance.date_joining else datetime.today() + ) contract.wage = ( instance.basic_salary if instance.basic_salary is not None else 0 )