Skip to content

Commit

Permalink
fix: Pluralize year text instead of optional bracket (backport #31210) (
Browse files Browse the repository at this point in the history
#31212)

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
Co-authored-by: Mohammad Hussain Nagaria <34810212+NagariaHussain@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 1, 2022
1 parent 3a718c7 commit b31709c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions erpnext/hr/doctype/employee/employee_reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit b31709c

Please sign in to comment.