diff --git a/hrms/hr/doctype/job_applicant/job_applicant.py b/hrms/hr/doctype/job_applicant/job_applicant.py index 43b1d495e73..994ec44db3e 100644 --- a/hrms/hr/doctype/job_applicant/job_applicant.py +++ b/hrms/hr/doctype/job_applicant/job_applicant.py @@ -50,9 +50,9 @@ class JobApplicant(Document): # end: auto-generated types def onload(self): - job_offer = frappe.get_all("Job Offer", filters={"job_applicant": self.name}) + job_offer = frappe.get_all("Job Offer", filters={"job_applicant": self.name, "docstatus": ["!=", 2]}) if job_offer: - self.get("__onload").job_offer = job_offer[0].name + self.set_onload("job_offer", job_offer[0].name) employee = frappe.db.get_value("Employee", {"job_applicant": self.name}, "name") or "" self.set_onload("employee", employee) diff --git a/hrms/hr/doctype/job_applicant/test_job_applicant.py b/hrms/hr/doctype/job_applicant/test_job_applicant.py index 65fb4404d51..496c84b395e 100644 --- a/hrms/hr/doctype/job_applicant/test_job_applicant.py +++ b/hrms/hr/doctype/job_applicant/test_job_applicant.py @@ -14,6 +14,24 @@ class TestJobApplicant(HRMSTestSuite): + def test_onload_filters_out_cancelled_job_offer(self): + applicant = create_job_applicant() + job_offer = create_job_offer(job_applicant=applicant.name) + job_offer.submit() + job_offer.cancel() + + applicant.onload() + onload = applicant.get("__onload") or {} + self.assertNotIn("job_offer", onload) + + # positive case: active job offer should be loaded + active_job_offer = create_job_offer(job_applicant=applicant.name) + active_job_offer.submit() + + applicant.onload() + onload = applicant.get("__onload") or {} + self.assertEqual(onload.get("job_offer"), active_job_offer.name) + def test_job_applicant_naming(self): applicant = frappe.get_doc( { diff --git a/hrms/hr/print_format/job_offer/job_offer.json b/hrms/hr/print_format/job_offer/job_offer.json index 0a922306b46..42e2d018c98 100644 --- a/hrms/hr/print_format/job_offer/job_offer.json +++ b/hrms/hr/print_format/job_offer/job_offer.json @@ -9,12 +9,13 @@ "html": "{% set terms_exist = doc.terms and (doc.terms|striptags).strip() or \"\" %}\n\n{% if letter_head and not no_letterhead -%}\n
\n\n\nDate: {{ doc.offer_date }}\n
\n\nDear {{ doc.applicant_name }}, \n\n
\n\nWe are pleased to appoint you in the services of {{ doc.company }} on the terms and conditions detailed in this letter.\n\n
\n\nYour designation shall be {{ doc.designation }}.\n\n
\n\n\n\n{%- if doc.offer_terms -%}\n {%- for row in doc.offer_terms -%}\n {{ row.offer_term }}: {{ row.value }}\n\n
\n {%- endfor -%}\n{%- endif -%}\n\n
\n\n\n\n\nPlease read the detailed terms as below. If you have any queries, feel free to get in touch with us.\nWe look forward to your long and fruitful career association with our organisation.\nIf you decide to join us, 'Welcome to {{ doc.company }} !'\n\n
\n\n
\n\nYours truly,\n\n
\n\nAuthorized Signatory\n\n
\n\n{{ doc.company }}\n\n\n\n