Includes: API (Express/TypeScript), Astro site, Python workers, document generators, FCC compliance tools, Canada CRTC formation, Ansible infrastructure, and deployment scripts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
126 lines
4.8 KiB
Python
126 lines
4.8 KiB
Python
"""FLSA Compliance Audit handler (LLM-based).
|
|
|
|
Generates a Fair Labor Standards Act compliance audit report including
|
|
employee classification analysis, overtime review, recordkeeping assessment,
|
|
and a prioritized remediation plan.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from .base_handler import BaseServiceHandler
|
|
|
|
SERVICE_SYSTEM_PROMPT = """You are a compliance analyst at Performance West Inc.
|
|
generating a Fair Labor Standards Act (FLSA) compliance audit report.
|
|
|
|
RULES:
|
|
- Write in professional, clear business English
|
|
- Cite specific FLSA regulations (29 CFR § 541, etc.)
|
|
- Never provide legal advice — use "we recommend" not "you must"
|
|
- For each finding: what was found, regulation, risk level (Low/Medium/High/Critical), remediation
|
|
- Structure with clear headings and bullet points
|
|
- Include specific section references from the Fair Labor Standards Act
|
|
- Reference DOL Fact Sheets where applicable
|
|
- Note state-specific requirements where the client operates
|
|
"""
|
|
|
|
SECTIONS = [
|
|
{
|
|
"name": "executive_summary",
|
|
"prompt": (
|
|
"Write a 200-word executive summary of the FLSA audit findings. "
|
|
"Include the scope of the audit, number of positions reviewed, "
|
|
"overall compliance posture, and highest-priority findings."
|
|
),
|
|
},
|
|
{
|
|
"name": "classification_analysis",
|
|
"prompt": (
|
|
"Analyze each employee classification (exempt vs non-exempt) "
|
|
"against the duties tests under 29 CFR § 541. For each role: "
|
|
"state the current classification, whether it meets the salary "
|
|
"basis test ($684/week), whether it passes the duties test for "
|
|
"the claimed exemption (executive, administrative, professional, "
|
|
"computer, outside sales), and the risk if misclassified."
|
|
),
|
|
},
|
|
{
|
|
"name": "overtime_analysis",
|
|
"prompt": (
|
|
"Analyze overtime calculation methods and identify any violations. "
|
|
"Review the regular rate of pay calculations, treatment of bonuses "
|
|
"and commissions in overtime, comp time practices, fluctuating "
|
|
"workweek usage, and any off-the-clock work risks."
|
|
),
|
|
},
|
|
{
|
|
"name": "recordkeeping_review",
|
|
"prompt": (
|
|
"Review timekeeping and recordkeeping compliance under 29 CFR § 516. "
|
|
"Assess: accuracy of time records, retention periods, required data "
|
|
"fields, break/meal period documentation, and any gaps that could "
|
|
"expose the organization in a wage-hour investigation."
|
|
),
|
|
},
|
|
{
|
|
"name": "youth_employment",
|
|
"prompt": (
|
|
"Review compliance with child labor provisions under FLSA § 212-213. "
|
|
"If the client employs any workers under 18: permitted occupations, "
|
|
"hour restrictions, hazardous occupation orders, and required "
|
|
"documentation. If not applicable, state so briefly."
|
|
),
|
|
},
|
|
{
|
|
"name": "remediation_plan",
|
|
"prompt": (
|
|
"Provide a prioritized remediation plan for all findings. "
|
|
"For each item: finding reference, risk level, recommended action, "
|
|
"responsible party, and suggested timeline. Group by priority "
|
|
"(Critical → High → Medium → Low)."
|
|
),
|
|
},
|
|
]
|
|
|
|
|
|
class FLSAAuditHandler(BaseServiceHandler):
|
|
SERVICE_SLUG = "flsa-audit"
|
|
SERVICE_NAME = "FLSA Compliance Audit"
|
|
TEMPLATE_NAME = "flsa_audit_template.docx"
|
|
REQUIRES_LLM = True
|
|
|
|
async def process(self, order_data: dict) -> list[str]:
|
|
work_dir = self._make_work_dir()
|
|
order_number = order_data["name"]
|
|
context = self._extract_order_context(order_data)
|
|
|
|
# 1. Load template and fill basic variables
|
|
template_path = self._get_template_path()
|
|
docx_filename = self._output_filename(order_number, "docx")
|
|
docx_path = os.path.join(work_dir, docx_filename)
|
|
|
|
variables = {
|
|
"order_number": order_number,
|
|
"customer_name": order_data.get("customer_name", ""),
|
|
"date": __import__("datetime").datetime.now().strftime("%B %d, %Y"),
|
|
"service_name": self.SERVICE_NAME,
|
|
"company_size": order_data.get("custom_company_size", "N/A"),
|
|
"industry": order_data.get("custom_industry", "N/A"),
|
|
"state": order_data.get("custom_state", "N/A"),
|
|
}
|
|
self._fill_template(template_path, variables, docx_path)
|
|
|
|
# 2. Generate LLM sections
|
|
sections = await self._generate_sections(
|
|
SERVICE_SYSTEM_PROMPT, SECTIONS, context
|
|
)
|
|
|
|
# 3. Append sections to the document
|
|
self._add_sections_to_doc(docx_path, sections)
|
|
|
|
# 4. Convert to PDF
|
|
pdf_path = self._convert_to_pdf(docx_path)
|
|
|
|
return [docx_path, pdf_path]
|