use super::funejson::Value; use super::hr_length_of_service::length_of_service; /// 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. /// /// # Panics /// Panics on a malformed date or a notice date before the start date. pub fn statutory_notice(start_date: &str, notice_date: &str) -> StatutoryNotice { let service = length_of_service(start_date, notice_date); let at_least_one_month = service.years > 0 || service.months > 0; let employer_weeks = if !at_least_one_month { 0 } else if service.years < 2 { 1 } else { service.years.min(12) }; StatutoryNotice { service_years: service.years, employer_weeks, employee_weeks: if at_least_one_month { 1 } else { 0 }, } } pub fn fune_vector(args: &[Value]) -> Value { let n = statutory_notice(args[0].as_str(), args[1].as_str()); Value::obj(vec![ ("serviceYears", Value::Int(n.service_years)), ("employerWeeks", Value::Int(n.employer_weeks)), ("employeeWeeks", Value::Int(n.employee_weeks)), ]) }