Skip to content

Commit

Permalink
feat(util): add provision to get holidays except weekly offs from hol…
Browse files Browse the repository at this point in the history
…iday list (#1011)

(cherry picked from commit e64a5e5)
  • Loading branch information
ruchamahabal authored and mergify[bot] committed Nov 2, 2023
1 parent 70817e0 commit 7c18d4b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hrms/utils/holiday_list.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import frappe


def get_holiday_dates_between(holiday_list: str, start_date: str, end_date: str) -> list:
def get_holiday_dates_between(
holiday_list: str,
start_date: str,
end_date: str,
skip_weekly_offs: bool = False,
) -> list:
Holiday = frappe.qb.DocType("Holiday")
return (
query = (
frappe.qb.from_(Holiday)
.select(Holiday.holiday_date)
.where((Holiday.parent == holiday_list) & (Holiday.holiday_date.between(start_date, end_date)))
.orderby(Holiday.holiday_date)
).run(pluck=True)
)

if skip_weekly_offs:
query = query.where(Holiday.weekly_off == 0)

return query.run(pluck=True)


def invalidate_cache(doc, method=None):
Expand Down

0 comments on commit 7c18d4b

Please sign in to comment.