Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct date handling for get_weekday in shift schedule assignment #2567

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import frappe
from frappe.model.document import Document
from frappe.utils import add_days, get_weekday, nowdate
from frappe.utils import add_days, get_weekday, getdate, nowdate

from hrms.hr.doctype.shift_assignment_tool.shift_assignment_tool import create_shift_assignment

Expand All @@ -20,14 +20,14 @@ def create_shifts(self, start_date: str, end_date: str | None = None) -> None:

date = start_date
individual_assignment_start = None
week_end_day = get_weekday(add_days(start_date, -1))
week_end_day = get_weekday(getdate(add_days(start_date, -1)))
repeat_on_days = [day.day for day in shift_schedule.repeat_on_days]

if not end_date:
end_date = add_days(start_date, 90)

while date <= end_date:
weekday = get_weekday(date)
weekday = get_weekday(getdate(date))
if weekday in repeat_on_days:
if not individual_assignment_start:
individual_assignment_start = date
Expand Down