Functional Weave
Code in Rust

payroll.notice-period@1.0.1

impl/typescript.ts

770 bytes · the TypeScript implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

import { lengthOfService } from "./hr_length_of_service.ts";  ← from hr.length-of-service ^1.0.0 · built alongside by fune
import { type StatutoryNotice } from "./payroll_notice_period_types.ts";

/**
 * ERA 1996 s.86 minimum notice. Below one month's service the section does
 * not apply at all, which is different from one week: an employer who
 * dismisses on day 20 owes no statutory notice.
 */
export function statutoryNotice(startDate: string, noticeDate: string): StatutoryNotice {
  const service = lengthOfService(startDate, noticeDate);
  const atLeastOneMonth = service.years > 0 || service.months > 0;
  let employerWeeks = 0;
  if (atLeastOneMonth) employerWeeks = service.years < 2 ? 1 : Math.min(service.years, 12);
  return { serviceYears: service.years, employerWeeks, employeeWeeks: atLeastOneMonth ? 1 : 0 };
}