|
|
@ -7,7 +7,7 @@ import frappe |
|
|
|
import erpnext |
|
|
|
import unittest |
|
|
|
import frappe.utils |
|
|
|
from erpnext.hr.doctype.employee.employee import EmployeeLeftValidationError |
|
|
|
from erpnext.hr.doctype.employee.employee import InactiveEmployeeStatusError |
|
|
|
|
|
|
|
test_records = frappe.get_test_records('Employee') |
|
|
|
|
|
|
@ -45,10 +45,33 @@ class TestEmployee(unittest.TestCase): |
|
|
|
employee2_doc.save() |
|
|
|
employee1_doc.reload() |
|
|
|
employee1_doc.status = 'Left' |
|
|
|
self.assertRaises(EmployeeLeftValidationError, employee1_doc.save) |
|
|
|
self.assertRaises(InactiveEmployeeStatusError, employee1_doc.save) |
|
|
|
|
|
|
|
def test_employee_status_inactive(self): |
|
|
|
from erpnext.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure |
|
|
|
from erpnext.payroll.doctype.salary_structure.salary_structure import make_salary_slip |
|
|
|
from erpnext.payroll.doctype.salary_slip.test_salary_slip import make_holiday_list |
|
|
|
|
|
|
|
employee = make_employee("test_employee_status@company.com") |
|
|
|
employee_doc = frappe.get_doc("Employee", employee) |
|
|
|
employee_doc.status = "Inactive" |
|
|
|
employee_doc.save() |
|
|
|
employee_doc.reload() |
|
|
|
|
|
|
|
make_holiday_list() |
|
|
|
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List") |
|
|
|
|
|
|
|
frappe.db.sql("""delete from `tabSalary Structure` where name='Test Inactive Employee Salary Slip'""") |
|
|
|
salary_structure = make_salary_structure("Test Inactive Employee Salary Slip", "Monthly", |
|
|
|
employee=employee_doc.name, company=employee_doc.company) |
|
|
|
salary_slip = make_salary_slip(salary_structure.name, employee=employee_doc.name) |
|
|
|
|
|
|
|
self.assertRaises(InactiveEmployeeStatusError, salary_slip.save) |
|
|
|
|
|
|
|
def tearDown(self): |
|
|
|
frappe.db.rollback() |
|
|
|
|
|
|
|
def make_employee(user, company=None, **kwargs): |
|
|
|
"" |
|
|
|
if not frappe.db.get_value("User", user): |
|
|
|
frappe.get_doc({ |
|
|
|
"doctype": "User", |
|
|
@ -80,4 +103,5 @@ def make_employee(user, company=None, **kwargs): |
|
|
|
employee.insert() |
|
|
|
return employee.name |
|
|
|
else: |
|
|
|
frappe.db.set_value("Employee", {"employee_name":user}, "status", "Active") |
|
|
|
return frappe.get_value("Employee", {"employee_name":user}, "name") |
|
|
|