# LFCS Docket Check

## When to use

Rocky says: "docket check", "did I sign the docket", "is today's docket in", or `/lfcs-docket-check`.
Also fires automatically from the EOD cron at 17:00 if there are dayworks or hybrid jobs ongoing.

## Procedure

1. Identify the active job. Read its `00-brief.md` to confirm `type:` is dayworks or hybrid (no docket needed for pure price work).

2. Check `<job>/07 - Site Documents/07a - Dockets/` for a file matching `YYYY-MM-DD-signed.*` for today's date using `ls <docket-dir>/YYYY-MM-DD-signed.*` (glob must expand — zero results means missing).

   **Two distinct missing cases (different root causes):**
   - Exit code 2 (directory does not exist): docket folder was never created — scaffold incomplete. Report: "Docket folder missing — no signed docket = no invoice line."
   - Exit code 0 (directory exists, empty): docket not yet photographed today. Report: "Docket missing — no signed docket = no invoice line."

3. Reply with one of:
   - **Found** → "✅ Docket signed today (07a/YYYY-MM-DD-signed.*). Day billable." (only one line)
   - **Missing AND folder doesn't exist (exit 2)** → "⚠️ Docket folder missing for this job. No signed docket = no invoice line. Escalate to admin."
   - **Missing AND folder exists but no signed file (exit 0)** → "⚠️ Docket not yet photographed today. Get signed before leaving site or revenue at risk."

## How "today" is decided

Use Australia/Sydney timezone. Date format: YYYY-MM-DD.

## Output format

ONE line on the happy path. Two lines max if missing. Don't pad.

## Pitfalls

- **Empty folder (exit 0) ≠ no activity day.** If `ls <docket-dir>/YYYY-MM-DD-signed.*` returns exit 0 with zero files, the docket folder exists but is empty today. This is a missing docket — report it as such, not as "folder not found." The two failure modes have different escalation paths.
- Don't false-positive on filenames that have today's date but aren't dockets. Match strict `YYYY-MM-DD-signed.*` glob pattern only — not just any file with today's date.
- Job folder paths on VPS have spaces: `"01-2275 - HPE Field of Play Hornsby"` and `"Ongoing Jobs"` both need quoting in every shell command. A bare path will silently fail or mis-route.
- If type is `price` (not hybrid/dayworks) and there's no dockets folder → reply: "n/a — price contract, no docket needed."

## Verification

After replying:
1. Re-read `<job>/07 - Site Documents/07a - Dockets/` and confirm the file count/match aligns with what was reported.
2. If a Telegram alert was sent (missing case), confirm the alert went to Rocky via gateway log (`/root/.hermes/logs/`), not to a group.
3. Date used in match must be Australia/Sydney TZ — sanity-check by comparing against `TZ=Australia/Sydney date +%Y-%m-%d`.
