mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 03:01:22 +00:00
[Tests] Employee Onboarding & Separation (#14606)
* Set query on department * Add test for Employee Onboarding * Add fetch for Employee Separation fields * Add test for Employee Separation * Fix Staffing Plan test case
This commit is contained in:
@@ -8,6 +8,7 @@ from frappe import _
|
|||||||
from erpnext.hr.utils import EmployeeBoardingController
|
from erpnext.hr.utils import EmployeeBoardingController
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
|
|
||||||
|
class IncompleteTaskError(frappe.ValidationError): pass
|
||||||
|
|
||||||
class EmployeeOnboarding(EmployeeBoardingController):
|
class EmployeeOnboarding(EmployeeBoardingController):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@@ -23,7 +24,7 @@ class EmployeeOnboarding(EmployeeBoardingController):
|
|||||||
else:
|
else:
|
||||||
task_status = frappe.db.get_value("Task", activity.task, "status")
|
task_status = frappe.db.get_value("Task", activity.task, "status")
|
||||||
if task_status not in ["Closed", "Cancelled"]:
|
if task_status not in ["Closed", "Cancelled"]:
|
||||||
frappe.throw(_("All the mandatory Task for employee creation hasn't been done yet."))
|
frappe.throw(_("All the mandatory Task for employee creation hasn't been done yet."), IncompleteTaskError)
|
||||||
|
|
||||||
def on_submit(self):
|
def on_submit(self):
|
||||||
super(EmployeeOnboarding, self).on_submit()
|
super(EmployeeOnboarding, self).on_submit()
|
||||||
|
|||||||
@@ -5,6 +5,61 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
from frappe.utils import nowdate
|
||||||
|
from erpnext.hr.doctype.employee_onboarding.employee_onboarding import make_employee
|
||||||
|
from erpnext.hr.doctype.employee_onboarding.employee_onboarding import IncompleteTaskError
|
||||||
|
|
||||||
class TestEmployeeOnboarding(unittest.TestCase):
|
class TestEmployeeOnboarding(unittest.TestCase):
|
||||||
pass
|
def test_employee_onboarding_incomplete_task(self):
|
||||||
|
if frappe.db.exists('Employee Onboarding', {'employee_name': 'Test Applicant'}):
|
||||||
|
return frappe.get_doc('Employee Onboarding', {'employee_name': 'Test Applicant'})
|
||||||
|
_set_up()
|
||||||
|
applicant = get_job_applicant()
|
||||||
|
onboarding = frappe.new_doc('Employee Onboarding')
|
||||||
|
onboarding.job_applicant = applicant.name
|
||||||
|
onboarding.employee_name = 'Test Applicant'
|
||||||
|
onboarding.company = '_Test Company'
|
||||||
|
onboarding.designation = 'Researcher'
|
||||||
|
onboarding.append('activities', {
|
||||||
|
'activity_name': 'Assign ID Card',
|
||||||
|
'role': 'HR User',
|
||||||
|
'required_for_employee_creation': 1
|
||||||
|
})
|
||||||
|
onboarding.append('activities', {
|
||||||
|
'activity_name': 'Assign a laptop',
|
||||||
|
'role': 'HR User'
|
||||||
|
})
|
||||||
|
onboarding.status = 'Pending'
|
||||||
|
onboarding.insert()
|
||||||
|
onboarding.submit()
|
||||||
|
self.assertEqual(onboarding.project, 'Employee Onboarding : Test Researcher - test@researcher.com')
|
||||||
|
self.assertRaises(IncompleteTaskError, make_employee, onboarding.name)
|
||||||
|
return onboarding
|
||||||
|
|
||||||
|
def test_employee_onboarding_completed_task(self):
|
||||||
|
doc = self.test_employee_onboarding_incomplete_task()
|
||||||
|
project = frappe.get_doc('Project', doc.project)
|
||||||
|
project.tasks[0].status = 'Closed'
|
||||||
|
project.save()
|
||||||
|
doc.reload()
|
||||||
|
employee = make_employee(doc.name)
|
||||||
|
employee.date_of_joining = nowdate()
|
||||||
|
employee.date_of_birth = '1990-05-08'
|
||||||
|
employee.gender = 'Female'
|
||||||
|
employee.insert()
|
||||||
|
self.assertEqual(employee.employee_name, 'Test Applicant')
|
||||||
|
|
||||||
|
def get_job_applicant():
|
||||||
|
if frappe.db.exists('Job Applicant', 'Test Researcher - test@researcher.com'):
|
||||||
|
return frappe.get_doc('Job Applicant', 'Test Researcher - test@researcher.com')
|
||||||
|
applicant = frappe.new_doc('Job Applicant')
|
||||||
|
applicant.applicant_name = 'Test Researcher'
|
||||||
|
applicant.email_id = 'test@researcher.com'
|
||||||
|
applicant.status = 'Open'
|
||||||
|
applicant.cover_letter = 'I am a great Researcher.'
|
||||||
|
applicant.insert()
|
||||||
|
return applicant
|
||||||
|
|
||||||
|
def _set_up():
|
||||||
|
for doctype in ["Employee Onboarding"]:
|
||||||
|
frappe.db.sql("delete from `tab{doctype}`".format(doctype=doctype))
|
||||||
@@ -2,7 +2,13 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Employee Onboarding Template', {
|
frappe.ui.form.on('Employee Onboarding Template', {
|
||||||
refresh: function(frm) {
|
setup: function(frm) {
|
||||||
|
frm.set_query("department", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
company: frm.doc.company
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -42,16 +43,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fetch_from": "employee.employee_name",
|
"fetch_from": "employee.employee_name",
|
||||||
"fieldname": "employee_name",
|
"fieldname": "employee_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -75,15 +77,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_from": "employee.resignation_letter_date",
|
||||||
"fieldname": "resignation_letter_date",
|
"fieldname": "resignation_letter_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -106,11 +110,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -138,11 +143,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -170,11 +176,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -200,11 +207,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -232,15 +240,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_from": "employee.company",
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -264,15 +274,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_from": "employee.department",
|
||||||
"fieldname": "department",
|
"fieldname": "department",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -296,15 +308,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_from": "employee.designation",
|
||||||
"fieldname": "designation",
|
"fieldname": "designation",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -328,15 +342,17 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_from": "employee.grade",
|
||||||
"fieldname": "employee_grade",
|
"fieldname": "employee_grade",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -360,11 +376,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -391,11 +408,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -423,11 +441,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -453,11 +472,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -484,11 +504,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -515,7 +536,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -529,7 +550,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-05-16 22:42:46.734328",
|
"modified": "2018-06-20 14:21:54.707831",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Employee Separation",
|
"name": "Employee Separation",
|
||||||
|
|||||||
@@ -6,5 +6,24 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
test_dependencies = ["Employee Onboarding"]
|
||||||
|
|
||||||
class TestEmployeeSeparation(unittest.TestCase):
|
class TestEmployeeSeparation(unittest.TestCase):
|
||||||
pass
|
def test_employee_separation(self):
|
||||||
|
employee = get_employee()
|
||||||
|
separation = frappe.new_doc('Employee Separation')
|
||||||
|
separation.employee = employee.name
|
||||||
|
separation.company = '_Test Company'
|
||||||
|
separation.append('activities', {
|
||||||
|
'activity_name': 'Deactivate Employee',
|
||||||
|
'role': 'HR User'
|
||||||
|
})
|
||||||
|
separation.status = 'Pending'
|
||||||
|
separation.insert()
|
||||||
|
separation.submit()
|
||||||
|
self.assertEqual(separation.docstatus, 1)
|
||||||
|
separation.cancel()
|
||||||
|
self.assertEqual(separation.project, "")
|
||||||
|
|
||||||
|
def get_employee():
|
||||||
|
return frappe.get_doc('Employee', {'employee_name': 'Test Applicant'})
|
||||||
@@ -15,8 +15,6 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
def test_staffing_plan(self):
|
def test_staffing_plan(self):
|
||||||
_set_up()
|
_set_up()
|
||||||
frappe.db.set_value("Company", "_Test Company", "is_group", 1)
|
frappe.db.set_value("Company", "_Test Company", "is_group", 1)
|
||||||
make_company()
|
|
||||||
set_employees()
|
|
||||||
if frappe.db.exists("Staffing Plan", "Test"):
|
if frappe.db.exists("Staffing Plan", "Test"):
|
||||||
return
|
return
|
||||||
staffing_plan = frappe.new_doc("Staffing Plan")
|
staffing_plan = frappe.new_doc("Staffing Plan")
|
||||||
@@ -25,15 +23,16 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
staffing_plan.from_date = nowdate()
|
staffing_plan.from_date = nowdate()
|
||||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||||
staffing_plan.append("staffing_details", {
|
staffing_plan.append("staffing_details", {
|
||||||
"designation": "Researcher",
|
"designation": "Designer",
|
||||||
"number_of_positions": 6,
|
"number_of_positions": 6,
|
||||||
"estimated_cost_per_position": 50000
|
"estimated_cost_per_position": 50000
|
||||||
})
|
})
|
||||||
staffing_plan.insert()
|
staffing_plan.insert()
|
||||||
staffing_plan.submit()
|
staffing_plan.submit()
|
||||||
self.assertEqual(staffing_plan.total_estimated_budget, 250000.00)
|
self.assertEqual(staffing_plan.total_estimated_budget, 300000.00)
|
||||||
|
|
||||||
def test_staffing_plan_subsidiary_company(self):
|
def test_staffing_plan_subsidiary_company(self):
|
||||||
|
self.test_staffing_plan()
|
||||||
if frappe.db.exists("Staffing Plan", "Test 1"):
|
if frappe.db.exists("Staffing Plan", "Test 1"):
|
||||||
return
|
return
|
||||||
staffing_plan = frappe.new_doc("Staffing Plan")
|
staffing_plan = frappe.new_doc("Staffing Plan")
|
||||||
@@ -42,7 +41,7 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
staffing_plan.from_date = nowdate()
|
staffing_plan.from_date = nowdate()
|
||||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||||
staffing_plan.append("staffing_details", {
|
staffing_plan.append("staffing_details", {
|
||||||
"designation": "Researcher",
|
"designation": "Designer",
|
||||||
"number_of_positions": 3,
|
"number_of_positions": 3,
|
||||||
"estimated_cost_per_position": 45000
|
"estimated_cost_per_position": 45000
|
||||||
})
|
})
|
||||||
@@ -58,13 +57,13 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
staffing_plan.from_date = nowdate()
|
staffing_plan.from_date = nowdate()
|
||||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||||
staffing_plan.append("staffing_details", {
|
staffing_plan.append("staffing_details", {
|
||||||
"designation": "Researcher",
|
"designation": "Designer",
|
||||||
"number_of_positions": 7,
|
"number_of_positions": 7,
|
||||||
"estimated_cost_per_position": 50000
|
"estimated_cost_per_position": 50000
|
||||||
})
|
})
|
||||||
staffing_plan.insert()
|
staffing_plan.insert()
|
||||||
staffing_plan.submit()
|
staffing_plan.submit()
|
||||||
self.assertEqual(staffing_plan.total_estimated_budget, 250000.00)
|
self.assertEqual(staffing_plan.total_estimated_budget, 350000.00)
|
||||||
if frappe.db.exists("Staffing Plan", "Test 1"):
|
if frappe.db.exists("Staffing Plan", "Test 1"):
|
||||||
return
|
return
|
||||||
staffing_plan = frappe.new_doc("Staffing Plan")
|
staffing_plan = frappe.new_doc("Staffing Plan")
|
||||||
@@ -73,7 +72,7 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
staffing_plan.from_date = nowdate()
|
staffing_plan.from_date = nowdate()
|
||||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||||
staffing_plan.append("staffing_details", {
|
staffing_plan.append("staffing_details", {
|
||||||
"designation": "Researcher",
|
"designation": "Designer",
|
||||||
"number_of_positions": 7,
|
"number_of_positions": 7,
|
||||||
"estimated_cost_per_position": 60000
|
"estimated_cost_per_position": 60000
|
||||||
})
|
})
|
||||||
@@ -83,6 +82,7 @@ class TestStaffingPlan(unittest.TestCase):
|
|||||||
def _set_up():
|
def _set_up():
|
||||||
for doctype in ["Staffing Plan", "Staffing Plan Detail"]:
|
for doctype in ["Staffing Plan", "Staffing Plan Detail"]:
|
||||||
frappe.db.sql("delete from `tab{doctype}`".format(doctype=doctype))
|
frappe.db.sql("delete from `tab{doctype}`".format(doctype=doctype))
|
||||||
|
make_company()
|
||||||
|
|
||||||
def make_company():
|
def make_company():
|
||||||
if frappe.db.exists("Company", "_Test Company 3"):
|
if frappe.db.exists("Company", "_Test Company 3"):
|
||||||
@@ -94,9 +94,3 @@ def make_company():
|
|||||||
company.default_currency = "INR"
|
company.default_currency = "INR"
|
||||||
company.country = "India"
|
company.country = "India"
|
||||||
company.insert()
|
company.insert()
|
||||||
|
|
||||||
def set_employees():
|
|
||||||
frappe.db.set_value("Employee", "_T-Employee-00001", "designation", "Researcher")
|
|
||||||
frappe.db.set_value("Employee", "_T-Employee-00001", "company", "_Test Company")
|
|
||||||
frappe.db.set_value("Employee", "_T-Employee-00002", "designation", "Researcher")
|
|
||||||
frappe.db.set_value("Employee", "_T-Employee-00002", "company", "_Test Company 3")
|
|
||||||
|
|||||||
Reference in New Issue
Block a user