mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-24 07:29:22 +00:00
Test case fixes
This commit is contained in:
@@ -66,12 +66,12 @@ class Employee(NestedSet):
|
|||||||
|
|
||||||
def update_user_permissions(self):
|
def update_user_permissions(self):
|
||||||
if not self.create_user_permission: return
|
if not self.create_user_permission: return
|
||||||
if has_user_permission_for_employee(self.user_id, self.name) \
|
if not has_permission('User Permission', ptype='write'): return
|
||||||
or not has_permission('User Permission', ptype='write'):
|
|
||||||
return
|
|
||||||
|
|
||||||
add_user_permission("Employee", self.name, self.user_id)
|
if has_user_permission_for_employee(self.user_id, self.name):
|
||||||
set_user_permission_if_allowed("Company", self.company, self.user_id)
|
add_user_permission("Employee", self.name, self.user_id)
|
||||||
|
if has_user_permission_for_employee(self.user_id, self.company):
|
||||||
|
set_user_permission_if_allowed("Company", self.company, self.user_id)
|
||||||
|
|
||||||
def update_user(self):
|
def update_user(self):
|
||||||
# add employee role if missing
|
# add employee role if missing
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ from erpnext.hr.doctype.salary_slip.test_salary_slip import get_salary_component
|
|||||||
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
|
from erpnext.hr.doctype.salary_structure.test_salary_structure import make_salary_structure
|
||||||
from erpnext.hr.doctype.loan.test_loan import create_loan
|
from erpnext.hr.doctype.loan.test_loan import create_loan
|
||||||
|
|
||||||
|
|
||||||
class TestPayrollEntry(unittest.TestCase):
|
class TestPayrollEntry(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
for dt in ["Salary Slip", "Salary Component", "Salary Component Account", "Payroll Entry", "Loan"]:
|
for dt in ["Salary Slip", "Salary Component", "Salary Component Account", "Payroll Entry", "Loan"]:
|
||||||
@@ -23,12 +22,14 @@ class TestPayrollEntry(unittest.TestCase):
|
|||||||
make_deduction_salary_component(["Professional Tax", "TDS"])
|
make_deduction_salary_component(["Professional Tax", "TDS"])
|
||||||
|
|
||||||
def test_payroll_entry(self): # pylint: disable=no-self-use
|
def test_payroll_entry(self): # pylint: disable=no-self-use
|
||||||
|
company = erpnext.get_default_company()
|
||||||
for data in frappe.get_all('Salary Component', fields = ["name"]):
|
for data in frappe.get_all('Salary Component', fields = ["name"]):
|
||||||
if not frappe.db.get_value('Salary Component Account',
|
if not frappe.db.get_value('Salary Component Account',
|
||||||
{'parent': data.name, 'company': erpnext.get_default_company()}, 'name'):
|
{'parent': data.name, 'company': company}, 'name'):
|
||||||
get_salary_component_account(data.name)
|
get_salary_component_account(data.name)
|
||||||
|
|
||||||
|
employee = frappe.db.get_value("Employee", {'company': company})
|
||||||
|
make_salary_structure("_Test Salary Structure", "Monthly", employee)
|
||||||
dates = get_start_end_dates('Monthly', nowdate())
|
dates = get_start_end_dates('Monthly', nowdate())
|
||||||
if not frappe.db.get_value("Salary Slip", {"start_date": dates.start_date, "end_date": dates.end_date}):
|
if not frappe.db.get_value("Salary Slip", {"start_date": dates.start_date, "end_date": dates.end_date}):
|
||||||
make_payroll_entry(start_date=dates.start_date, end_date=dates.end_date)
|
make_payroll_entry(start_date=dates.start_date, end_date=dates.end_date)
|
||||||
@@ -99,7 +100,7 @@ def make_payroll_entry(**args):
|
|||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
|
|
||||||
payroll_entry = frappe.new_doc("Payroll Entry")
|
payroll_entry = frappe.new_doc("Payroll Entry")
|
||||||
payroll_entry.company = erpnext.get_default_company()
|
payroll_entry.company = args.company or erpnext.get_default_company()
|
||||||
payroll_entry.start_date = args.start_date or "2016-11-01"
|
payroll_entry.start_date = args.start_date or "2016-11-01"
|
||||||
payroll_entry.end_date = args.end_date or "2016-11-30"
|
payroll_entry.end_date = args.end_date or "2016-11-30"
|
||||||
payroll_entry.payment_account = get_payment_account()
|
payroll_entry.payment_account = get_payment_account()
|
||||||
|
|||||||
@@ -84,11 +84,11 @@ def make_salary_structure(salary_structure, payroll_frequency, employee=None):
|
|||||||
"payroll_frequency": payroll_frequency,
|
"payroll_frequency": payroll_frequency,
|
||||||
"payment_account": get_random("Account")
|
"payment_account": get_random("Account")
|
||||||
}).insert()
|
}).insert()
|
||||||
if employee:
|
salary_structure_doc.submit()
|
||||||
create_salary_structure_assignment(employee, salary_structure)
|
|
||||||
|
|
||||||
elif employee and not frappe.db.get_value("Salary Structure Assignment",{'salary_structure':salary_structure, 'employee':employee},'name'):
|
if employee and not frappe.db.get_value("Salary Structure Assignment",
|
||||||
create_salary_structure_assignment(employee, salary_structure)
|
{'employee':employee, 'docstatus': 1}):
|
||||||
|
create_salary_structure_assignment(employee, salary_structure)
|
||||||
return salary_structure
|
return salary_structure
|
||||||
|
|
||||||
def create_salary_structure_assignment(employee, salary_structure):
|
def create_salary_structure_assignment(employee, salary_structure):
|
||||||
|
|||||||
Reference in New Issue
Block a user