From 857c4795403473af13525bf4d032c3f2b7ca66cd Mon Sep 17 00:00:00 2001 From: Mohammad Hussain Nagaria <34810212+NagariaHussain@users.noreply.github.com> Date: Wed, 1 Jun 2022 16:29:20 +0530 Subject: [PATCH] fix: Pluralize year text instead of optional bracket (#31210) Co-authored-by: Rucha Mahabal (cherry picked from commit 37433aad48ce9a6b22fb3b20accef95eaea2c540) --- erpnext/hr/doctype/employee/employee_reminders.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/erpnext/hr/doctype/employee/employee_reminders.py b/erpnext/hr/doctype/employee/employee_reminders.py index 1829bc4f2fca..f09d7ff75a73 100644 --- a/erpnext/hr/doctype/employee/employee_reminders.py +++ b/erpnext/hr/doctype/employee/employee_reminders.py @@ -230,7 +230,7 @@ def get_work_anniversary_reminder_text_and_message(anniversary_persons): persons_name = anniversary_person # Number of years completed at the company completed_years = getdate().year - anniversary_persons[0]["date_of_joining"].year - anniversary_person += f" completed {completed_years} year(s)" + anniversary_person += f" completed {get_pluralized_years(completed_years)}" else: person_names_with_years = [] names = [] @@ -239,7 +239,7 @@ def get_work_anniversary_reminder_text_and_message(anniversary_persons): names.append(person_text) # Number of years completed at the company completed_years = getdate().year - person["date_of_joining"].year - person_text += f" completed {completed_years} year(s)" + person_text += f" completed {get_pluralized_years(completed_years)}" person_names_with_years.append(person_text) # converts ["Jim", "Rim", "Dim"] to Jim, Rim & Dim @@ -254,6 +254,12 @@ def get_work_anniversary_reminder_text_and_message(anniversary_persons): return reminder_text, message +def get_pluralized_years(years): + if years == 1: + return "1 year" + return f"{years} years" + + def send_work_anniversary_reminder(recipients, reminder_text, anniversary_persons, message): frappe.sendmail( recipients=recipients,