Can't assign Leave type for employee

Hello my friends…!
So I am trying to assign Annual Leave for each employees using control panel and I get this error.

here is the entire error log

Traceback with variables (most recent call last):
File “apps/hrms/hrms/hr/doctype/leave_control_panel/leave_control_panel.py”, line 94, in create_leave_policy_assignments
assignment.submit()
self = <LeaveControlPanel: Leave Control Panel>
employees = [‘HR-EMP-00015’, ‘HR-EMP-00020’, ‘HR-EMP-00027’, ‘HR-EMP-00007’, ‘HR-EMP-00014’]
from_date = None
to_date = ‘2024-12-31’
assignment_based_on = ‘Joining Date’
failure = [‘HR-EMP-00015’, ‘HR-EMP-00020’]
success =
savepoint = ‘before_assignment_submission’
employee = ‘HR-EMP-00027’
assignment = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
File “apps/frappe/frappe/utils/typing_validations.py”, line 31, in wrapper
return func(*args, **kwargs)
args = (<LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>,)
kwargs = {}
apply_condition = <function whitelist..innerfn.. at 0x7a83dc0f09d0>
func = <function Document.submit at 0x7a83dc0f0940>
File “apps/frappe/frappe/model/document.py”, line 1048, in submit
return self._submit()
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
File “apps/frappe/frappe/model/document.py”, line 1031, in _submit
return self.save()
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
File “apps/frappe/frappe/model/document.py”, line 337, in save
return self._save(*args, **kwargs)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
args = ()
kwargs = {}
File “apps/frappe/frappe/model/document.py”, line 390, in _save
self.run_post_save_methods()
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
ignore_permissions = None
ignore_version = None
File “apps/frappe/frappe/model/document.py”, line 1131, in run_post_save_methods
self.run_method(“on_submit”)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
File “apps/frappe/frappe/model/document.py”, line 962, in run_method
out = Document.hook(fn)(self, *args, **kwargs)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
args = ()
kwargs = {}
fn = <function Document.run_method..fn at 0x7a83d8903ac0>
method = ‘on_submit’
File “apps/frappe/frappe/model/document.py”, line 1322, in composer
return composed(self, method, args, **kwargs)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
args = ()
kwargs = {}
hooks = []
method = ‘on_submit’
doc_events = {'
': {‘on_update’: [‘frappe.desk.notifications.clear_doctype_notifications’, ‘frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions’, ‘frappe.core.doctype.file.utils.attach_files_to_document’, ‘frappe.automation.doctype.assignment_rule.assignment_rule.apply’, ‘frappe.automation.doctype.assignment_rule.assignment_rule.update_due_date’, ‘frappe.core.doctype.user_type.user_type.apply_permissions_for_non_standard_user_type’], ‘after_rename’: [‘frappe.desk.notifications.clear_doctype_notifications’], ‘on_cancel’: [‘frappe.desk.notifications.clear_doctype_notifications’, ‘frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions’, ‘frappe.automation.doctype.assignment_rule.assignment_rule.apply’], ‘on_trash’: [‘frappe.desk.notifications.clear_doctype_notifications’, ‘frappe.workflow.doctype.workflow_action.workflow_action.process_workflow_actions’], ‘on_update_after_submit’: ['frappe.workflow.doctype.workflow_action.workflow_action.process_w…
composed = <function Document.hook..compose..runner at 0x7a83d80677f0>
compose = <function Document.hook..compose at 0x7a83d8903be0>
f = <function Document.run_method..fn at 0x7a83d8903ac0>
File “apps/frappe/frappe/model/document.py”, line 1304, in runner
add_to_return_value(self, fn(self, *args, **kwargs))
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
method = ‘on_submit’
args = ()
kwargs = {}
add_to_return_value = <function Document.hook..add_to_return_value at 0x7a83d8903a30>
fn = <function Document.run_method..fn at 0x7a83d8903ac0>
hooks = ()
File “apps/frappe/frappe/model/document.py”, line 959, in fn
return method_object(*args, **kwargs)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
args = ()
kwargs = {}
method_object = <bound method LeavePolicyAssignment.on_submit of <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>>
method = ‘on_submit’
File “apps/hrms/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py”, line 32, in on_submit
self.grant_leave_alloc_for_employee()
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
File “apps/hrms/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py”, line 95, in grant_leave_alloc_for_employee
leave_allocation, new_leaves_allocated = self.create_leave_allocation(
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
leave_allocations = {}
leave_type_details = {‘Sick’: {‘name’: ‘Sick’, ‘is_lwp’: 0, ‘is_earned_leave’: 1, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Last Day’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}, ‘Unpaid leave’: {‘name’: ‘Unpaid leave’, ‘is_lwp’: 0, ‘is_earned_leave’: 0, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Last Day’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}, ‘Compensation’: {‘name’: ‘Compensation’, ‘is_lwp’: 0, ‘is_earned_leave’: 0, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Last Day’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}, ‘Annual’: {‘name’: ‘Annual’, ‘is_lwp’: 0, ‘is_earned_leave’: 1, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Date of Joining’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}}
leave_policy = <LeavePolicy: HR-LPOL-2024-00001 docstatus=1>
date_of_joining = datetime.date(2024, 9, 1)
leave_policy_detail = <LeavePolicyDetail: q1ca3evfpg docstatus=1 parent=HR-LPOL-2024-00001>
leave_details = {‘name’: ‘Annual’, ‘is_lwp’: 0, ‘is_earned_leave’: 1, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Date of Joining’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}
File “apps/hrms/hrms/hr/doctype/leave_policy_assignment/leave_policy_assignment.py”, line 129, in create_leave_allocation
allocation.save(ignore_permissions=True)
self = <LeavePolicyAssignment: HR-LPOL-ASSGN-00024 docstatus=1>
annual_allocation = 20.0
leave_details = {‘name’: ‘Annual’, ‘is_lwp’: 0, ‘is_earned_leave’: 1, ‘is_compensatory’: 0, ‘allocate_on_day’: ‘Date of Joining’, ‘is_carry_forward’: 0, ‘expire_carry_forwarded_leaves_after_days’: 0, ‘earned_leave_frequency’: ‘Monthly’, ‘rounding’: ‘’}
date_of_joining = datetime.date(2024, 9, 1)
carry_forward = 0
new_leaves_allocated = 3.333
allocation = <LeaveAllocation: unsaved>
File “apps/frappe/frappe/model/document.py”, line 337, in save
return self._save(*args, **kwargs)
self = <LeaveAllocation: unsaved>
args = ()
kwargs = {‘ignore_permissions’: True}
File “apps/frappe/frappe/model/document.py”, line 359, in _save
return self.insert()
self = <LeaveAllocation: unsaved>
ignore_permissions = True
ignore_version = None
File “apps/frappe/frappe/model/document.py”, line 283, in insert
self._validate_links()
self = <LeaveAllocation: unsaved>
ignore_permissions = None
ignore_links = None
ignore_if_duplicate = False
ignore_mandatory = None
set_name = None
set_child_names = True
File “apps/frappe/frappe/model/document.py”, line 930, in validate_links
frappe.throw(
(“Could not find {0}”).format(msg), frappe.LinkValidationError)
self = <LeaveAllocation: unsaved>
invalid_links = [(‘department’, ‘Administrative - JE’, ‘Department: Administrative - JE’)]
cancelled_links =
msg = ‘Department: Administrative - JE’
File “apps/frappe/frappe/init.py”, line 652, in throw
msgprint(
msg = ‘Could not find Department: Administrative - JE’
exc = <class ‘frappe.exceptions.LinkValidationError’>
title = None
is_minimizable = False
wide = False
as_list = False
primary_action = None
File “apps/frappe/frappe/init.py”, line 617, in msgprint
_raise_exception()
title = None
as_table = False
as_list = False
indicator = ‘red’
alert = False
primary_action = None
is_minimizable = False
wide = False
realtime = False
sys = <module ‘sys’ (built-in)>
_raise_exception = <function msgprint.._raise_exception at 0x7a83d8066c20>
inspect = <module ‘inspect’ from ‘/usr/lib/python3.10/inspect.py’>
msg = ‘Could not find Department: Administrative - JE’
out = {‘message’: ‘Could not find Department: Administrative - JE’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘20d2113ffb0cd18abb5614125f2849d05d36c798de107b8a0744aade’}
raise_exception = <class ‘frappe.exceptions.LinkValidationError’>
File “apps/frappe/frappe/init.py”, line 568, in _raise_exception
raise exc
exc = LinkValidationError(‘Could not find Department: Administrative - JE’)
inspect = <module ‘inspect’ from ‘/usr/lib/python3.10/inspect.py’>
msg = ‘Could not find Department: Administrative - JE’
out = {‘message’: ‘Could not find Department: Administrative - JE’, ‘title’: ‘Message’, ‘indicator’: ‘red’, ‘raise_exception’: 1, ‘__frappe_exc_id’: ‘20d2113ffb0cd18abb5614125f2849d05d36c798de107b8a0744aade’}
raise_exception = <class ‘frappe.exceptions.LinkValidationError’>
frappe.exceptions.LinkValidationError: Could not find Department: Administrative - JE