From 227489193bd11fd8a2f3f8566e59651f1dc39d94 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 21 Jun 2018 11:35:51 +0530 Subject: [PATCH] Test case fixes --- .../employee_transfer/employee_transfer.py | 4 +- .../test_employee_transfer.py | 2 +- .../salary_component/test_records.json | 39 ++++++++++++++----- .../salary_component/test_salary_component.py | 13 +++++++ 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/erpnext/hr/doctype/employee_transfer/employee_transfer.py b/erpnext/hr/doctype/employee_transfer/employee_transfer.py index 99e7ad65de..c730e022a5 100644 --- a/erpnext/hr/doctype/employee_transfer/employee_transfer.py +++ b/erpnext/hr/doctype/employee_transfer/employee_transfer.py @@ -26,7 +26,7 @@ class EmployeeTransfer(Document): new_employee.name = None new_employee.employee_number = None new_employee = update_employee(new_employee, self.transfer_details, date=self.transfer_date) - if self.company != self.new_company: + if self.new_company and self.company != self.new_company: new_employee.internal_work_history = [] new_employee.date_of_joining = self.transfer_date new_employee.company = self.new_company @@ -41,7 +41,7 @@ class EmployeeTransfer(Document): employee.db_set("status", "Left") else: employee = update_employee(employee, self.transfer_details, date=self.transfer_date) - if self.company != self.new_company: + if self.new_company and self.company != self.new_company: employee.company = self.new_company employee.date_of_joining = self.transfer_date employee.save() diff --git a/erpnext/hr/doctype/employee_transfer/test_employee_transfer.py b/erpnext/hr/doctype/employee_transfer/test_employee_transfer.py index 3dae1a9840..93fc7a2705 100644 --- a/erpnext/hr/doctype/employee_transfer/test_employee_transfer.py +++ b/erpnext/hr/doctype/employee_transfer/test_employee_transfer.py @@ -6,7 +6,7 @@ from __future__ import unicode_literals import frappe import unittest from frappe.utils import getdate, add_days -from erpnext.hr.doctype.salary_structure.test_salary_structure import make_employee +from erpnext.hr.doctype.employee.test_employee import make_employee class TestEmployeeTransfer(unittest.TestCase): def setUp(self): diff --git a/erpnext/hr/doctype/salary_component/test_records.json b/erpnext/hr/doctype/salary_component/test_records.json index bd3a7d489f..69491bed99 100644 --- a/erpnext/hr/doctype/salary_component/test_records.json +++ b/erpnext/hr/doctype/salary_component/test_records.json @@ -1,22 +1,41 @@ [ { - "doctype": "Salary Component", - "salary_component": "_Test Basic Salary" + "doctype": "Salary Component", + "salary_component": "_Test Basic Salary", + "type": "Earning", + "is_payable": 1, + "is_tax_applicable": 1 }, { - "doctype": "Salary Component", - "salary_component": "_Test Allowance" + "doctype": "Salary Component", + "salary_component": "_Test Allowance", + "type": "Earning", + "is_payable": 1, + "is_tax_applicable": 1 }, { - "doctype": "Salary Component", - "salary_component": "_Test Professional Tax" + "doctype": "Salary Component", + "salary_component": "_Test Professional Tax", + "type": "Deduction" }, { - "doctype": "Salary Component", - "salary_component": "_Test TDS" + "doctype": "Salary Component", + "salary_component": "_Test TDS", + "type": "Deduction" }, { - "doctype": "Salary Component", - "salary_component": "Basic" + "doctype": "Salary Component", + "salary_component": "Basic", + "type": "Earning", + "is_payable": 1, + "is_tax_applicable": 1 + }, + { + "doctype": "Salary Component", + "salary_component": "Leave Encashment", + "type": "Earning", + "is_payable": 1, + "is_tax_applicable": 1, + "is_additional_component": 1 } ] \ No newline at end of file diff --git a/erpnext/hr/doctype/salary_component/test_salary_component.py b/erpnext/hr/doctype/salary_component/test_salary_component.py index 599bc6a527..c13843aca7 100644 --- a/erpnext/hr/doctype/salary_component/test_salary_component.py +++ b/erpnext/hr/doctype/salary_component/test_salary_component.py @@ -10,3 +10,16 @@ import unittest class TestSalaryComponent(unittest.TestCase): pass + + +def create_salary_component(component_name, **args): + if not frappe.db.exists("Salary Component", component_name): + frappe.get_doc({ + "doctype": "Salary Component", + "salary_component": component_name, + "type": args.get("type") or "Earning", + "is_payable": args.get("is_payable") or 1, + "is_tax_applicable": args.get("is_tax_applicable") or 1, + "is_additional_component": args.get("is_additional_component") or 1 + }).insert() + \ No newline at end of file