mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-13 01:34:10 +00:00
Merge pull request #50538 from asmitahase/holiday-list-assignment
This commit is contained in:
@@ -254,7 +254,11 @@ def get_employee_email(employee_doc):
|
||||
)
|
||||
|
||||
|
||||
def get_holiday_list_for_employee(employee, raise_exception=True):
|
||||
def get_holiday_list_for_employee(employee, raise_exception=True, as_on=None):
|
||||
hrms_override = frappe.get_hooks("employee_holiday_list")
|
||||
|
||||
if hrms_override:
|
||||
return frappe.get_attr(hrms_override[-1])(employee, raise_exception, as_on)
|
||||
if employee:
|
||||
holiday_list, company = frappe.get_cached_value("Employee", employee, ["holiday_list", "company"])
|
||||
else:
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
"column_break_2",
|
||||
"weekly_off",
|
||||
"section_break_4",
|
||||
"description"
|
||||
"description",
|
||||
"is_half_day"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"columns": 2,
|
||||
"fieldname": "holiday_date",
|
||||
"fieldtype": "Date",
|
||||
"in_list_view": 1,
|
||||
@@ -23,6 +25,7 @@
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"columns": 3,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor",
|
||||
"in_list_view": 1,
|
||||
@@ -32,6 +35,7 @@
|
||||
"width": "300px"
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
"default": "0",
|
||||
"fieldname": "weekly_off",
|
||||
"fieldtype": "Check",
|
||||
@@ -44,18 +48,28 @@
|
||||
{
|
||||
"fieldname": "section_break_4",
|
||||
"fieldtype": "Section Break"
|
||||
},
|
||||
{
|
||||
"columns": 2,
|
||||
"default": "0",
|
||||
"fieldname": "is_half_day",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"in_preview": 1,
|
||||
"label": "Is Half Day"
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:09:49.810408",
|
||||
"modified": "2025-08-28 15:15:44.177181",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Holiday",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "ASC",
|
||||
"states": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ class Holiday(Document):
|
||||
|
||||
description: DF.TextEditor
|
||||
holiday_date: DF.Date
|
||||
is_half_day: DF.Check
|
||||
parent: DF.Data
|
||||
parentfield: DF.Data
|
||||
parenttype: DF.Data
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
"add_weekly_holidays",
|
||||
"weekly_off",
|
||||
"get_weekly_off_dates",
|
||||
"column_break_euok",
|
||||
"is_half_day",
|
||||
"add_local_holidays",
|
||||
"country",
|
||||
"subdivision",
|
||||
@@ -136,12 +138,22 @@
|
||||
"fieldtype": "Button",
|
||||
"label": "Add to Holidays",
|
||||
"options": "get_local_holidays"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_euok",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_half_day",
|
||||
"fieldtype": "Check",
|
||||
"label": "Is Half Day"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-calendar",
|
||||
"idx": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:09:49.920245",
|
||||
"modified": "2025-08-28 15:17:05.313383",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Setup",
|
||||
"name": "Holiday List",
|
||||
@@ -160,7 +172,8 @@
|
||||
"write": 1
|
||||
}
|
||||
],
|
||||
"row_format": "Dynamic",
|
||||
"sort_field": "creation",
|
||||
"sort_order": "DESC",
|
||||
"states": []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class HolidayList(Document):
|
||||
from_date: DF.Date
|
||||
holiday_list_name: DF.Data
|
||||
holidays: DF.Table[Holiday]
|
||||
is_half_day: DF.Check
|
||||
subdivision: DF.Autocomplete | None
|
||||
to_date: DF.Date
|
||||
total_holidays: DF.Int
|
||||
@@ -56,7 +57,15 @@ class HolidayList(Document):
|
||||
if d in existing_holidays:
|
||||
continue
|
||||
|
||||
self.append("holidays", {"description": _(self.weekly_off), "holiday_date": d, "weekly_off": 1})
|
||||
self.append(
|
||||
"holidays",
|
||||
{
|
||||
"description": _(self.weekly_off),
|
||||
"holiday_date": d,
|
||||
"weekly_off": 1,
|
||||
"is_half_day": self.is_half_day,
|
||||
},
|
||||
)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_supported_countries(self):
|
||||
@@ -194,7 +203,25 @@ def is_holiday(holiday_list, date=None):
|
||||
if date is None:
|
||||
date = today()
|
||||
if holiday_list:
|
||||
return bool(frappe.db.exists("Holiday", {"parent": holiday_list, "holiday_date": date}, cache=True))
|
||||
return bool(
|
||||
frappe.db.exists(
|
||||
"Holiday", {"parent": holiday_list, "holiday_date": date, "is_half_day": 0}, cache=True
|
||||
)
|
||||
)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def is_half_holiday(holiday_list, date=None):
|
||||
"""Returns true if the given date is a half holiday in the given holiday list"""
|
||||
if date is None:
|
||||
date = today()
|
||||
if holiday_list:
|
||||
return bool(
|
||||
frappe.db.exists(
|
||||
"Holiday", {"parent": holiday_list, "holiday_date": date, "is_half_day": 1}, cache=True
|
||||
)
|
||||
)
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user