Functional Weave
Code in Python

payroll.notice-period@1.0.1

impl/python.py

810 bytes · the Python 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.

from .hr_length_of_service import length_of_service  ← from hr.length-of-service ^1.0.0 · built alongside by fune
from .payroll_notice_period_types import StatutoryNotice


def statutory_notice(start_date: str, notice_date: str) -> StatutoryNotice:
    """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.
    """
    service = length_of_service(start_date, notice_date)
    at_least_one_month = service.years > 0 or service.months > 0
    employer_weeks = 0
    if at_least_one_month:
        employer_weeks = 1 if service.years < 2 else min(service.years, 12)
    return StatutoryNotice(
        service_years=service.years,
        employer_weeks=employer_weeks,
        employee_weeks=1 if at_least_one_month else 0,
    )