// Termination letter: ends an employee's employment. It states the
// reason and the history behind it (the warnings, the show-cause notice
// and the hearing), the last working day and notice, what the full and
// final settlement includes and when it is paid, what the employee must
// return, what continues after they leave, and how to appeal. The
// employee signs to acknowledge receipt. Signed by Paras Deshpande,
// Managing Director & CEO, who signs HR and legal documents.
//
// The employee and the history below are examples: replace each one. Have
// counsel review every termination before it is issued. Never issue one
// without the warnings, show-cause notice and hearing it refers to.
//
// Statutory assumptions, for the company's CA and lawyer to confirm (the
// kit's reading, not verified law):
//   - Process: if the employee is a "worker" under the Industrial
//     Relations Code, 2020 (not managerial, or supervisory above its wage
//     limit), a dismissal for misconduct may need a domestic inquiry under
//     the company's disciplinary rules. Termination as disciplinary action
//     is not retrenchment, so no retrenchment compensation is assumed;
//     counsel confirms both.
//   - Settlement: the Code on Wages, 2019 has it paid within two working
//     days of the employment ending. settle-by: auto counts Monday to
//     Friday only; check it against holidays.
//   - Gratuity: due after five years' continuous service (one year for a
//     fixed-term employee under the Code on Social Security, 2020); some
//     courts count four years and 240 days as five. The letter says "due"
//     only from five completed years.
//   - Leave: unused earned leave is paid in the settlement, under the leave
//     policy and the Maharashtra Shops and Establishments Act, 2017.
//   - Statutory bonus: owed for the year so far only to employees whose
//     wages are within the bonus law's limit (₹21,000 a month under the
//     old Payment of Bonus Act).

#import "../rivant.typ": *

// ---------------------------------------------------------------- data

#let data = (
  // Reference: the next number in the termination letters register
  // (none = blank).
  seq: 1,
  date: "2026-11-16",
  // Terminations are personal: "Private and confidential", marked on
  // every page.
  confidential: true,
  watermark: "confidential",
  employee: (
    name: "Kunal Mehta",
    id: "RM-0017",
    address: ("Flat 5, Gulmohar Apartments, Sector 21", "Nerul, Navi Mumbai, Maharashtra 400706"),
  ),
  salutation: "Dear Kunal,",
  designation: "Account Executive",
  department: "Client Servicing",
  joined: "2025-06-02",
  // The appointment letter, as its reference is printed, and the clause on
  // notice the company relies on (9.1 in the kit's appointment letter).
  appointment: (reference: "APT/2025-26/0004", date: "2025-06-02", clause: "9.1"),
  // Warnings issued before this letter: (reference, date, stage).
  warnings: (
    ("WRN/2026-27/0002", "2026-09-12", "First written warning"),
    ("WRN/2026-27/0004", "2026-10-19", "Final written warning"),
  ),
  // The reason, as facts with dates.
  reason: "Since the final warning, three client deliverables have gone out late without notice, and you were absent without approval on 2 and 9 November 2026.",
  // The show-cause notice that set out the reason and asked why the
  // employment should not end: its reference and date, and the date of
  // the employee's written reply (none if no reply came).
  show-cause: (reference: "NTC/2026-27/0015", date: "2026-11-10", replied: "2026-11-12"),
  // The meeting where the employee was heard before the decision.
  hearing: "2026-11-13",
  last-day: "2026-11-16",
  // Notice under the appointment letter, in days, and whether it is paid
  // in lieu (true) or worked (false).
  notice: (days: 60, in-lieu: true),
  // Earned leave not taken, in days, encashed in the settlement.
  leave-balance: 7,
  // true if the statutory bonus is owed (see the assumptions above).
  statutory-bonus: false,
  // The day the settlement is paid. auto is two working days (Monday to
  // Friday) after the last working day; check it against holidays.
  settle-by: auto,
  // What to return, and to whom, by the last working day.
  property: ("your laptop and charger", "your ID and access cards", "any client files and material, on paper or on your own devices"),
  return-to: "Arnuv Amburle",
  // Days the employee has to appeal in writing.
  appeal-days: 7,
  signatory: (name: "Paras Deshpande", title: "Managing Director & CEO"),
)

// -------------------------------------------------------------- layout

#let k = document-kinds.at("termination-letter")
#let e = data.employee
#let sc = data.show-cause
#let last = to-date(data.last-day)

// n working days after a date, skipping Saturdays and Sundays.
#let working-days-after(d, n) = {
  let x = d
  let left = n
  while left > 0 {
    x = x + duration(days: 1)
    if x.weekday() <= 5 { left -= 1 }
  }
  x
}
#let settle-by = if data.settle-by == auto { working-days-after(last, 2) } else { to-date(data.settle-by) }
#let appeal-by = to-date(data.date) + duration(days: data.appeal-days)

// Completed years of service, for gratuity (due after five).
#let service-years = {
  let a = to-date(data.joined)
  let years = last.year() - a.year()
  let before = last.month() < a.month() or (last.month() == a.month() and last.day() < a.day())
  if before { years - 1 } else { years }
}

#show: rivant-document.with(
  kind: k.name,
  title: k.name,
  title-light: if data.notice.in-lieu { "with notice pay" } else { "with " + str(data.notice.days) + " days’ notice" },
  reference: ref-no(k.code, data.seq, date: data.date),
  date: data.date,
  meta: (("Employee ID", e.id), ("Last working day", long-date(data.last-day))),
  letterhead: k.letterhead,
  confidential: data.confidential,
  watermark: data.watermark,
)

#party(none, (name: e.name, address: e.address, extra: (("Role", data.designation + ", " + data.department),)))

#subject-line[Termination of your employment]

#data.salutation

This letter confirms the company's decision to end your employment as
#data.designation, under clause #data.appointment.clause of your
appointment letter #data.appointment.reference of
#long-date(data.appointment.date).

= Why

Before this letter, you received these written warnings.

#data-table(
  columns: (46mm, 26mm, 1fr),
  header: ("Warning", "Date", "Stage"),
  align: (left, left, left),
  rows: data.warnings.map(((r, d, stage)) => (r, short-date(d), stage)),
)

#data.reason On #long-date(sc.date) we wrote to you (#box[show-cause] notice
#or-blank(sc.reference, "Notice reference")), setting this out and asking
you to explain why your employment should not end.
#if sc.replied != none [
  You replied in writing on #long-date(sc.replied), and we met on
  #long-date(data.hearing), where you were heard. Having considered your
  reply and what you said,
] else [
  You did not reply in writing. We met on #long-date(data.hearing), where
  you were heard. Having considered what you said,
]
the company has decided to end your employment.

#callout(title: "Your last working day")[
  #text(size: sizes.lead, weight: 600, long-date(data.last-day)).
  #if data.notice.in-lieu [
    You will be paid #data.notice.days days' salary in lieu of notice, and
    are not required to work the notice period.
  ] else [
    This gives you the #data.notice.days days' notice your appointment
    letter provides.
  ]
]

= Full and final settlement

#data-table(
  columns: (52mm, 1fr),
  header: ("Included", "Basis"),
  align: (left, left),
  rows: (
    ([Salary for days worked], [To #long-date(data.last-day)]),
    ..if data.notice.in-lieu { (([Pay in lieu of notice], [#data.notice.days days' gross salary]),) } else { () },
    ([Earned leave not taken], [#data.leave-balance days, under the leave policy]),
    ..if data.statutory-bonus { (([Statutory bonus], [For this financial year to #long-date(data.last-day)]),) } else { () },
    ([Gratuity], if service-years >= 5 [Due: #service-years years of service] else [Not due: under five years of service]),
    ([Less deductions], [Provident fund, professional tax and TDS as they apply, and recoveries the law allows, such as a salary advance]),
  ),
)

It is paid into your salary account by #long-date(settle-by), within two
working days of your last working day as the Code on Wages, 2019 requires,
with a statement of the amounts.

= Leaving

Please return #data.property.join(", ", last: " and ") to
#data.return-to by the end of your last working day, when your access to
the company's systems ends. Your relieving and experience letters follow
the handover. Your provident fund stays in your account with the EPFO
under your UAN. Your duties of confidentiality and on the company's
intellectual property continue after you leave.

= Appeal

If you wish to appeal this decision, write to #company.legal-email by
#long-date(appeal-by), giving your reasons. We will hear the appeal and
reply in writing within 14 days of receiving it.

// The closing stays with the signatures, so a page never ends on "Yours
// sincerely".
#block(breakable: false, {
  [Yours sincerely,]
  signatures(
    signature-block(name: data.signatory.name, title: data.signatory.title, date: data.date),
    acceptance-block(heading: "Received by the employee", party: e.name, company: false),
  )
  v(3mm)
  small[The employee signs to acknowledge receiving this letter. Signing does not mean agreeing with it.]
})

#copy-to[Accounts, for the settlement][Personnel file]
