offer_Format1

Offer_Email_Format_1
ahmed.mujtaba 2026-09-16 16:40:40 +05:00
parent 9c11e8a104
commit 5254bdb964
2 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,95 @@
from html import escape
def _text(value):
"""Escape user-entered text and keep its line breaks ("Maymar Office\\nOr\\nHead Office")."""
if value in (None, ""):
return ""
return "<br>".join(escape(line.strip()) for line in str(value).splitlines())
def _salary(value):
if value in (None, ""):
return ""
try:
amount = float(str(value).replace(",", ""))
return f"PKR {amount:,.0f}"
except (TypeError, ValueError):
return _text(value)
def _recruiter_names(recruiter_names):
names = [str(n).strip() for n in (recruiter_names or []) if n and str(n).strip()]
if not names:
return ""
if len(names) == 1:
return escape(names[0])
if len(names) == 2:
return f"{escape(names[0])} &amp; {escape(names[1])}"
return ", ".join(escape(n) for n in names[:-1]) + f" &amp; {escape(names[-1])}"
def _package_row(label, value, bold=False):
cell = "border:1px solid #000000;padding:4px 8px;vertical-align:top;"
shown = f"<strong>{value}</strong>" if bold else value
return (
"<tr>"
f'<td width="174" style="width:174px;{cell}">{label}</td>'
f'<td width="449" style="width:449px;{cell}">{shown}</td>'
"</tr>"
)
def render_offer_email_body(
candidate_name,
offered_position,
cadre,
company_name,
monthly_gross_salary,
subsidized_services,
probation_period,
notice_period,
location,
timings,
recruiter_names,
):
"""Annexure J - Offer Email Format as an Outlook-safe HTML body: inline styles
and a bordered table only, no <style> block or classes (Outlook strips them).
Times New Roman 11pt and the bold runs match the .docx. recruiter_names is a
list, joined as "A", "A & B" or "A, B & C"."""
font = "font-family:'Times New Roman',Times,serif;font-size:11pt;color:#000000;"
paragraph = "margin:0 0 11pt 0;"
first_name = (str(candidate_name or "").strip().split() or [""])[0]
rows = (
_package_row("Monthly Gross Salary", _salary(monthly_gross_salary), bold=True)
+ _package_row("Subsidized Services", _text(subsidized_services))
+ _package_row("Probation Period", _text(probation_period))
+ _package_row("Notice Period", _text(notice_period))
+ _package_row("Location", _text(location))
+ _package_row("Timings", _text(timings))
)
return (
f'<div style="{font}">'
f'<p style="{paragraph}">Dear {escape(first_name)},</p>'
f'<p style="{paragraph}">Hope this email finds you well.</p>'
f'<p style="{paragraph}">Subsequent to your interviews and pursuant to our discussion, '
"we are pleased to offer you the role of "
f"<strong>{_text(offered_position)} in {_text(cadre)} Cadre</strong> "
f"with <strong>{_text(company_name)}</strong>, based at the Head Office in Karachi.</p>"
f'<p style="{paragraph}">As discussed, the details of the remuneration package are as follows:</p>'
'<table cellpadding="0" cellspacing="0" border="1" width="623" '
f'style="width:623px;border-collapse:collapse;border:1px solid #000000;{font}margin:0 0 11pt 0;">'
f"{rows}"
"</table>"
f'<p style="{paragraph}">You will also be eligible for all the benefits at your grade '
"as per the Company&rsquo;s policy.</p>"
f'<p style="{paragraph}">We look forward to the opportunity to work with you in an atmosphere '
"that is mutually challenging and rewarding. Please confirm your acceptance of the Offer by "
"replying to this e-mail within <strong>24 hours,</strong> mentioning your "
"<strong>suggested date for joining.</strong></p>"
'<p style="margin:0;"><strong>Regards,</strong></p>'
f'<p style="margin:0;"><strong>{_recruiter_names(recruiter_names)}</strong></p>'
"</div>"
)