fix: default total_estimated_cost to zero (#24939)
Co-authored-by: walstanb <walstanb@gmail.com>
This commit is contained in:
parent
d39055785a
commit
78e576ee6a
@ -13,11 +13,21 @@ class TestJobApplicant(unittest.TestCase):
|
|||||||
|
|
||||||
def create_job_applicant(**args):
|
def create_job_applicant(**args):
|
||||||
args = frappe._dict(args)
|
args = frappe._dict(args)
|
||||||
job_applicant = frappe.get_doc({
|
|
||||||
"doctype": "Job Applicant",
|
filters = {
|
||||||
"applicant_name": args.applicant_name or "_Test Applicant",
|
"applicant_name": args.applicant_name or "_Test Applicant",
|
||||||
"email_id": args.email_id or "test_applicant@example.com",
|
"email_id": args.email_id or "test_applicant@example.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
if frappe.db.exists("Job Applicant", filters):
|
||||||
|
return frappe.get_doc("Job Applicant", filters)
|
||||||
|
|
||||||
|
job_applicant = frappe.get_doc({
|
||||||
|
"doctype": "Job Applicant",
|
||||||
"status": args.status or "Open"
|
"status": args.status or "Open"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
job_applicant.update(filters)
|
||||||
job_applicant.save()
|
job_applicant.save()
|
||||||
|
|
||||||
return job_applicant
|
return job_applicant
|
@ -13,14 +13,15 @@ from erpnext.hr.doctype.staffing_plan.test_staffing_plan import make_company
|
|||||||
|
|
||||||
class TestJobOffer(unittest.TestCase):
|
class TestJobOffer(unittest.TestCase):
|
||||||
def test_job_offer_creation_against_vacancies(self):
|
def test_job_offer_creation_against_vacancies(self):
|
||||||
create_staffing_plan(staffing_details=[{
|
frappe.db.set_value("HR Settings", None, "check_vacancies", 1)
|
||||||
"designation": "Designer",
|
job_applicant = create_job_applicant(email_id="test_job_offer@example.com")
|
||||||
|
job_offer = create_job_offer(job_applicant=job_applicant.name, designation="UX Designer")
|
||||||
|
|
||||||
|
create_staffing_plan(name='Test No Vacancies', staffing_details=[{
|
||||||
|
"designation": "UX Designer",
|
||||||
"vacancies": 0,
|
"vacancies": 0,
|
||||||
"estimated_cost_per_position": 5000
|
"estimated_cost_per_position": 5000
|
||||||
}])
|
}])
|
||||||
frappe.db.set_value("HR Settings", None, "check_vacancies", 1)
|
|
||||||
job_applicant = create_job_applicant(email_id="test_job_offer@example.com")
|
|
||||||
job_offer = create_job_offer(job_applicant=job_applicant.name, designation="Researcher")
|
|
||||||
self.assertRaises(frappe.ValidationError, job_offer.submit)
|
self.assertRaises(frappe.ValidationError, job_offer.submit)
|
||||||
|
|
||||||
# test creation of job offer when vacancies are not present
|
# test creation of job offer when vacancies are not present
|
||||||
|
@ -39,6 +39,7 @@ class StaffingPlan(Document):
|
|||||||
detail.current_count = designation_counts['employee_count']
|
detail.current_count = designation_counts['employee_count']
|
||||||
detail.current_openings = designation_counts['job_openings']
|
detail.current_openings = designation_counts['job_openings']
|
||||||
|
|
||||||
|
detail.total_estimated_cost = 0
|
||||||
if detail.number_of_positions > 0:
|
if detail.number_of_positions > 0:
|
||||||
if detail.vacancies > 0 and detail.estimated_cost_per_position:
|
if detail.vacancies > 0 and detail.estimated_cost_per_position:
|
||||||
detail.total_estimated_cost = cint(detail.vacancies) * flt(detail.estimated_cost_per_position)
|
detail.total_estimated_cost = cint(detail.vacancies) * flt(detail.estimated_cost_per_position)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user