Example #1
0
 def test_get_applicable_block_dates_all_lists(self):
     webnotes.session.user = "******"
     webnotes.conn.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)
     ])
Example #2
0
 def test_get_applicable_block_dates_for_allowed_user(self):
     webnotes.session.user = "******"
     webnotes.conn.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 validate_block_days(self):
		from 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)
			
		if block_dates:
			if self.doc.status == "Approved":
				webnotes.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates."))
				raise LeaveDayBlockedError
	def show_block_day_warning(self):
		from 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:
			webnotes.msgprint(_("Warning: Leave application contains following block dates") + ":")
			for d in block_dates:
				webnotes.msgprint(formatdate(d.block_date) + ": " + d.reason)
Example #5
0
	def validate_block_days(self):
		from 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)
			
		if block_dates:
			if self.doc.status == "Approved":
				webnotes.msgprint(_("Cannot approve leave as you are not authorized to approve leaves on Block Dates."))
				raise LeaveDayBlockedError
Example #6
0
	def show_block_day_warning(self):
		from 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:
			webnotes.msgprint(_("Warning: Leave application contains following block dates") + ":")
			for d in block_dates:
				webnotes.msgprint(formatdate(d.block_date) + ": " + d.reason)
Example #7
0
	def validate_block_days(self):
		from 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)
			
		if block_dates:
			webnotes.msgprint(_("Following dates are blocked for Leave") + ":")
			for d in block_dates:
				webnotes.msgprint(formatdate(d.block_date) + ": " + d.reason)
				
			if self.doc.status == "Approved":
				raise LeaveDayBlockedError
def add_block_dates(events, start, end, employee, company):
	# block days
	from 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
Example #9
0
def add_block_dates(events, start, end, employee, company):
	# block days
	from 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 test_get_applicable_block_dates(self):
		webnotes.session.user = "******"
		webnotes.conn.set_value("Department", "_Test Department", "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")])
	def test_get_applicable_block_dates_for_allowed_user(self):
		webnotes.session.user = "******"
		webnotes.conn.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")])