101 lines
4.8 KiB
Python
101 lines
4.8 KiB
Python
# DONOT REMOVE THIS ( OFFER LETTER JUST CREATE TEMPLATE FOR NOW)
|
|
from datetime import date, datetime
|
|
from html import escape
|
|
|
|
from offer_email_template.template import _package_row, _salary, _text
|
|
|
|
|
|
def _letter_date(value):
|
|
"""<Month, DD, YYYY> -> "September 16, 2026". Accepts date/datetime or an ISO string."""
|
|
if value in (None, ""):
|
|
return ""
|
|
if isinstance(value, date):
|
|
return value.strftime("%B %d, %Y")
|
|
try:
|
|
return datetime.fromisoformat(str(value)).strftime("%B %d, %Y")
|
|
except ValueError:
|
|
return _text(value)
|
|
|
|
|
|
def render_offer_letter_body(
|
|
candidate_full_name,
|
|
candidate_cnic,
|
|
address_line,
|
|
city_country,
|
|
candidate_first_name,
|
|
job_title,
|
|
department_name,
|
|
cadre,
|
|
work_location,
|
|
monthly_gross_salary,
|
|
probation_period,
|
|
performance_bonus,
|
|
health_insurance,
|
|
life_insurance,
|
|
leave_entitlement,
|
|
letter_date,
|
|
):
|
|
"""Offer Letter Format as an Outlook-safe HTML body: inline styles and a
|
|
bordered table only, no <style> block or classes (Outlook strips them).
|
|
Arial 10pt, bold / underline runs and the two equal table columns match the
|
|
.docx; the acceptance blanks stay blank for the candidate to fill in."""
|
|
font = "font-family:Arial,Helvetica,sans-serif;font-size:10pt;color:#000000;"
|
|
heading = "font-family:Calibri,Arial,sans-serif;font-size:10pt;font-weight:bold;margin:0 0 11pt 0;"
|
|
paragraph = "margin:0 0 8pt 0;"
|
|
tight = "margin:0;"
|
|
widths = (234, 234)
|
|
header_cell = "border:1px solid #000000;padding:4px 8px;text-align:center;font-weight:bold;"
|
|
|
|
salary = _salary(monthly_gross_salary)
|
|
if salary and not salary.endswith("/-"):
|
|
salary = f"{salary}/-"
|
|
|
|
rows = (
|
|
"<tr>"
|
|
f'<td width="{widths[0]}" style="width:{widths[0]}px;{header_cell}">Component</td>'
|
|
f'<td width="{widths[1]}" style="width:{widths[1]}px;{header_cell}">Details</td>'
|
|
"</tr>"
|
|
+ _package_row("Monthly Gross Salary", salary, bold=True, widths=widths, bold_label=True)
|
|
+ _package_row("Probation Period", _text(probation_period), widths=widths)
|
|
+ _package_row("Performance Bonus", _text(performance_bonus), widths=widths)
|
|
+ _package_row("Health Insurance", _text(health_insurance), widths=widths)
|
|
+ _package_row("Life Insurance", _text(life_insurance), widths=widths)
|
|
+ _package_row("Leave Entitlement", _text(leave_entitlement), widths=widths)
|
|
)
|
|
|
|
return (
|
|
f'<div style="{font}">'
|
|
f'<p style="{paragraph}text-align:right;color:#1A1A1A;">'
|
|
f"<strong>Date: {_letter_date(letter_date)}</strong></p>"
|
|
f'<p style="{tight}">{_text(candidate_full_name)}</p>'
|
|
f'<p style="{tight}">{_text(candidate_cnic)}</p>'
|
|
f'<p style="{tight}">{_text(address_line)},</p>'
|
|
f'<p style="{paragraph}">{_text(city_country)}</p>'
|
|
f'<p style="{paragraph}text-align:center;"><strong><u>OFFER LETTER</u></strong></p>'
|
|
f'<p style="{tight}">Dear <strong>{escape(str(candidate_first_name or "").strip())}</strong>,</p>'
|
|
f'<p style="{paragraph}">We are pleased to offer you the position of <strong>{_text(job_title)}</strong> '
|
|
f"in the <strong>{_text(department_name)}</strong> department at <strong>Utopia Brands</strong> "
|
|
f"in <strong>{_text(cadre)} cadre</strong>, based in <strong>{_text(work_location)}</strong>. "
|
|
"Your employment is expected to commence, subject to the completion of onboarding "
|
|
"formalities and satisfactory reference checks.</p>"
|
|
f'<p style="{heading}">COMPENSATION & BENEFITS</p>'
|
|
'<table align="center" cellpadding="0" cellspacing="0" border="1" width="468" '
|
|
f'style="width:468px;border-collapse:collapse;border:1px solid #000000;{font}margin:0 auto 11pt auto;">'
|
|
f"{rows}"
|
|
"</table>"
|
|
f'<p style="{paragraph}">We look forward to welcoming you to Utopia Brands. Kindly confirm your '
|
|
"acceptance by signing and returning this letter; a formal Letter of Appointment will follow "
|
|
"upon joining. Congratulations, and welcome to the team.</p>"
|
|
'<p style="margin:0 0 30pt 0;">Best Regards,</p>'
|
|
f'<p style="{tight}"><strong>Human Resources</strong></p>'
|
|
f'<p style="{paragraph}"><strong>Utopia Brands</strong></p>'
|
|
f'<p style="{heading}">ACCEPTANCE OF OFFER</p>'
|
|
f'<p style="{tight}">I, <strong>____________________</strong>, accept the terms and conditions '
|
|
"of employment outlined in this offer letter.</p>"
|
|
f'<p style="{paragraph}">My date of joining will be</p>'
|
|
'<p style="margin:0 0 30pt 0;color:#1A1A1A;"><strong>_____________________</strong></p>'
|
|
f'<p style="{tight}">Signature: ___________________________'
|
|
" Date: __________________</p>"
|
|
"</div>"
|
|
)
|