def validate_block_days(employee, company, from_date, to_date, status): block_dates = get_applicable_block_dates(from_date, to_date, employee, company) if block_dates and status == "Approved": return "You are not authorized to approve leaves on Block Dates" return ""
def validate_block_days(self): block_dates = get_applicable_block_dates( self.from_date, self.to_date, self.employee, self.company ) if block_dates and self.status == "Approved": frappe.throw(_("You are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError)
def show_block_day_warning(self): block_dates = get_applicable_block_dates(self.from_date, self.to_date, self.employee, self.company, all_lists=True) if block_dates: frappe.msgprint(_("Warning: Leave application contains following block dates") + ":") for d in block_dates: frappe.msgprint(formatdate(d.block_date) + ": " + d.reason)
def show_block_day_warning(self): block_dates = get_applicable_block_dates(self.from_date, self.to_date, self.employee, self.company, all_lists=True) if block_dates: frappe.msgprint(_("Warning: Leave application contains following block dates") + ":") for d in block_dates: frappe.msgprint(formatdate(d.block_date) + ": " + d.reason)
def test_get_applicable_block_dates_for_allowed_user(self): frappe.set_user("*****@*****.**") frappe.db.set_value("Department", "_Test Department 1", "leave_block_list", "_Test Leave Block List") self.assertEquals([], [ d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03") ])
def test_get_applicable_block_dates_all_lists(self): frappe.set_user("*****@*****.**") frappe.db.set_value("Department", "_Test Department 1", "leave_block_list", "_Test Leave Block List") self.assertTrue("2013-01-02" in [ d.block_date for d in get_applicable_block_dates( "2013-01-01", "2013-01-03", all_lists=True) ])
def show_block_day_warning(employee,company,from_date, to_date): block_dates = get_applicable_block_dates(from_date, to_date, employee, company, all_lists=True) if block_dates: warning = "Warning: Leave application contains following block dates\n" for d in block_dates: warning += formatdate(d.block_date) + ": " + d.reason return warning return ""
def test_get_applicable_block_dates(self): frappe.set_user("*****@*****.**") frappe.db.set_value("Department", "_Test Department - _TC", "leave_block_list", "_Test Leave Block List") self.assertTrue( getdate("2013-01-02") in [ d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03") ])
def validate_block_days(self): from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates block_dates = get_applicable_block_dates(self.from_date, self.to_date, self.employee, self.company) if block_dates: if self.status == "Approved": frappe.throw(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError)
def validate_block_days(self): from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates block_dates = get_applicable_block_dates(self.from_date, self.to_date, self.employee, self.company) if block_dates: if self.status == "Approved": frappe.throw(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError)
def add_block_dates(events, start, end, employee, company): # block days from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates cnt = 0 block_dates = get_applicable_block_dates(start, end, employee, company, all_lists=True) for block_date in block_dates: events.append({ "doctype": "Leave Block List Date", "from_date": block_date.block_date, "title": _("Leave Blocked") + ": " + block_date.reason, "name": "_" + str(cnt), }) cnt+=1
def add_block_dates(events, start, end, employee, company): # block days from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates cnt = 0 block_dates = get_applicable_block_dates(start, end, employee, company, all_lists=True) for block_date in block_dates: events.append({ "doctype": "Leave Block List Date", "from_date": block_date.block_date, "title": _("Leave Blocked") + ": " + block_date.reason, "name": "_" + str(cnt), }) cnt+=1
def show_block_day_warning(self): from erpnext.hr.doctype.leave_block_list.leave_block_list import get_applicable_block_dates block_dates = get_applicable_block_dates(self.doc.from_date, self.doc.to_date, self.doc.employee, self.doc.company, all_lists=True) if block_dates: frappe.msgprint( _("Warning: Leave application contains following block dates") + ":") for d in block_dates: frappe.msgprint(formatdate(d.block_date) + ": " + d.reason)
def validate_block_days(self): block_dates = get_applicable_block_dates(self.from_date, self.to_date, self.employee, self.company) if block_dates and self.status == "Approved": frappe.throw(_("You are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError)
def test_get_applicable_block_dates_all_lists(self): frappe.set_user("*****@*****.**") frappe.db.set_value("Department", "_Test Department 1", "leave_block_list", "_Test Leave Block List") self.assertTrue(getdate("2013-01-02") in [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03", all_lists=True)])
def test_get_applicable_block_dates_for_allowed_user(self): frappe.set_user("*****@*****.**") frappe.db.set_value("Department", "_Test Department 1", "leave_block_list", "_Test Leave Block List") self.assertEquals([], [d.block_date for d in get_applicable_block_dates("2013-01-01", "2013-01-03")])