def create_salary_slip(employee): if not frappe.db.exists("Salary Slip", {"employee": employee}): posting_date = get_first_day(add_months(getdate(), -1)) salary_slip = make_employee_salary_slip(employee, "Monthly", "Test Gratuity", posting_date=posting_date) salary_slip.start_date = posting_date salary_slip.end_date = None salary_slip.submit() salary_slip = salary_slip.name else: salary_slip = get_last_salary_slip(employee) return salary_slip
def create_employee_and_get_last_salary_slip(): employee = make_employee("*****@*****.**", company='_Test Company') frappe.db.set_value("Employee", employee, "relieving_date", getdate()) frappe.db.set_value("Employee", employee, "date_of_joining", add_days(getdate(), - (6*365))) if not frappe.db.exists("Salary Slip", {"employee":employee}): salary_slip = make_employee_salary_slip("*****@*****.**", "Monthly") salary_slip.submit() salary_slip = salary_slip.name else: salary_slip = get_last_salary_slip(employee) if not frappe.db.get_value("Employee", "*****@*****.**", "holiday_list"): from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list make_holiday_list() frappe.db.set_value("Company", '_Test Company', "default_holiday_list", "Salary Slip Test Holiday List") return employee, salary_slip
def test_get_last_salary_slip_should_return_none_for_new_employee(self): new_employee = make_employee("*****@*****.**", company="_Test Company") salary_slip = get_last_salary_slip(new_employee) self.assertIsNone(salary_slip)
def test_get_last_salary_slip_should_return_none_for_new_employee(self): new_employee = make_employee("*****@*****.**", company='_Test Company') salary_slip = get_last_salary_slip(new_employee) assert salary_slip is None