Skip to main content

PHASE_DEADLINES — the legally-anchored deadline catalogue

src/lib/workflow-config.ts declares deadline rules per phase. Each rule is type, label, days, kind (CALENDAR_DAYS | WORKING_DAYS), base (NOW | CASE_FIELD), baseField, and source (legal | internal). computeDueAt (date-utils.ts) turns a rule + case record into a due date; a missing base field skips the deadline silently (logged to console only).

PhaseRuleDaysKindAnchored toSource
PRELIMINARY_INQUIRYStart Inquérito Prévio30calendarsuspicion_datelegal
PRELIMINARY_INQUIRYNotify Nota de Culpa after IP30calendarip_concluded_atlegal
RESPONSE_WINDOWEmployee response window10workingcharges_delivered_atlegal
FINAL_REPORTInternal decision deadline30calendarlast_evidence_act_atlegal
BODIES_OPINIONInternal opinion deadline (configurable)10calendarNOWinternal

The base-date columns (suspicion_date, ip_concluded_at, charges_delivered_at, last_evidence_act_at, plus knowledge_date, ip_first_diligence_at) exist on cases.

What to verify

Every source: "legal" figure is asserted in code without a statute citation. Confirm each against the Código do Trabalho — especially the 10 working days for the employee's response and the day-kind of each 30-day window (the code mixes calendar and working days deliberately, so the distinction is load-bearing). Note the separate, undocumented 60-day prescrição from knowledge of the infraction — is it modelled anywhere? (knowledge_date exists but no deadline rule uses it.)

Gotchas

  • Deadlines are computed and stored client-side during a transition; a missing base field skips the deadline with only a console.warn.
  • computeDueAt's working-day math ignores Portuguese holidays (naive deadline math).
  • The BODIES_OPINION 5-working-day CT/Sindicato wait is enforced by a separate, hand-rolled calc inside useWorkflow — a second source of truth (bodies opinion).

Rebuild implication

Model deadlines as first-class, server-computed, statute-cited rules with an explicit day-kind and a holiday-aware calculator. One calculator, not three.