# LFCS Weekly Timesheet

## When to use

Rocky says: "do my timesheet", "weekly timesheet", "send my hours", "Sarah's chasing my timesheet", or `/timesheet`.
Recommended: run every Friday afternoon or Monday morning.

## Procedure

1. **Identify the week.** Default = current week ending last Sunday (Mon 0:00 → Sun 23:59 last week). If Rocky says "last week" or gives a date range, use that.

2. **Pull hours** based on `timesheet.hours_source`:
   - `lfcs-job-tracker`: read each ongoing job's `Job-Tracker.md` Hours table, filter rows where Person is Rocky/Michael McLoughlin and date is in the week. Sum per day.
   - `manual`: ask Rocky day-by-day for his hours (Mon-Sun).
   - `both`: pull from job tracker + ask Rocky to confirm any not captured.

3. **Confirm hours with Rocky** before submitting — show him a 7-row table (Mon-Sun) with hours, ask "confirm or edit any of these".

4. **Compose submission** based on `timesheet.format`:

   **Text/email format:**
   ```
   To: {recipient_email}
   Subject: Timesheet WE [Sun date] — Michael McLoughlin

   Hi [recipient name from email],

   Timesheet for week ending [Sun date]:

   Mon DD: Xh — [project/site]
   Tue DD: Xh — [project/site]
   ...
   Total: XXh

   Regards,
   Michael McLoughlin
   ```

5. **Send via gws** (using opsman.systems@gmail.com → admin@lfcs.com.au or directly per test-phase rules):
   ```
   gws gmail users messages send --params '{"userId":"me"}' --json '{"raw":"<base64>"}'
   ```

6. **Confirm to Rocky**: "Sent. Check Sent folder if you want to verify."

## Output format

When showing the proposed timesheet for Rocky's confirmation:
```
Week ending Sun [date] — preview:

| Day | Hours | Project |
|---|---|---|
| Mon | 8.0 | Hornsby (LFCS PM) |
| Tue | 9.0 | Hornsby (LFCS PM) |
...
| Total | 47.0 | |

Confirm to send, or edit any line.
```

## Pitfalls

- **First-time setup**: if `timesheet.employer` and `recipient_email` aren't configured, ask Rocky once and save to config (don't ask again).
- If hours pull from job-tracker = 0 (e.g., he's not been logging there), default to manual mode and ask day-by-day.
- For Lendlease specifically, format may need to be a specific PDF or web portal — we don't have that wired yet, so produce text/email format and let Rocky paste into the portal.
- Don't auto-send without Rocky's explicit "send" or "confirmed" reply. Always preview first.

## Future improvements (not yet built)

- Auto-pull from Lendlease HammerTech sign-in/out times if API available
- PDF generation matching Lendlease/contractor template
- Browser-using-agent submission to Stonewood/Lendlease web portal

## Verification

After sending:
1. Confirm Sent: `gws gmail users messages list --params '{"userId":"me","q":"in:sent subject:Timesheet WE","maxResults":1}'` — the latest hit must be from today.
2. Total hours in the email body must match what Rocky confirmed in step 3 — sum row-by-row and re-check before send.
3. Recipient address in `To:` must match `timesheet.recipient_email` config exactly. If unset → ABORT with prompt, never default-route to admin@lfcs.com.au unless explicitly configured.
4. After send, reply to Rocky with the message ID for traceability: "Sent. ID: `<message-id>`."
