fix: Pluralize year text instead of optional bracket (#31210)
Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
This commit is contained in:
parent
536f1dfc4b
commit
37433aad48
@ -230,7 +230,7 @@ def get_work_anniversary_reminder_text_and_message(anniversary_persons):
|
|||||||
persons_name = anniversary_person
|
persons_name = anniversary_person
|
||||||
# Number of years completed at the company
|
# Number of years completed at the company
|
||||||
completed_years = getdate().year - anniversary_persons[0]["date_of_joining"].year
|
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:
|
else:
|
||||||
person_names_with_years = []
|
person_names_with_years = []
|
||||||
names = []
|
names = []
|
||||||
@ -239,7 +239,7 @@ def get_work_anniversary_reminder_text_and_message(anniversary_persons):
|
|||||||
names.append(person_text)
|
names.append(person_text)
|
||||||
# Number of years completed at the company
|
# Number of years completed at the company
|
||||||
completed_years = getdate().year - person["date_of_joining"].year
|
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)
|
person_names_with_years.append(person_text)
|
||||||
|
|
||||||
# converts ["Jim", "Rim", "Dim"] to Jim, Rim & Dim
|
# 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
|
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):
|
def send_work_anniversary_reminder(recipients, reminder_text, anniversary_persons, message):
|
||||||
frappe.sendmail(
|
frappe.sendmail(
|
||||||
recipients=recipients,
|
recipients=recipients,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user