Session log: CLAUDE.md optimization + python3/py fix
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -64,23 +64,19 @@ API_KEY=$(sops -d D:/vault/msp-tools/syncro.sops.yaml | py -c "import sys,yaml;
|
||||
- `contact_id` (customer contact)
|
||||
- `ticket_type_id` (ticket category)
|
||||
|
||||
#### Comments (with optional time entry)
|
||||
#### Comments
|
||||
|
||||
| Operation | Method | Endpoint | Body |
|
||||
|---|---|---|---|
|
||||
| Add comment | POST | `/tickets/<id>/comment` | `{"subject": "Update", "body": "...", "hidden": false, "do_not_email": false}` |
|
||||
| Add comment + time | POST | `/tickets/<id>/comment` | Same as above, PLUS: `"product_id": N, "minutes_spent": 60, "bill_time_now": false` |
|
||||
|
||||
**Comment fields:**
|
||||
- `subject` — comment header (e.g., "Update", "Resolution", "Internal Note")
|
||||
- `body` — comment text (HTML supported)
|
||||
- `hidden` — if true, internal-only (customer can't see)
|
||||
- `do_not_email` — if true, don't email customer about this comment
|
||||
- `product_id` — labor product ID (see labor products table below). Adds billable time to the ticket.
|
||||
- `minutes_spent` — integer, minutes of work (60 = 1hr minimum in most cases)
|
||||
- `bill_time_now` — if true, immediately creates a charge (equivalent to "Charge now" checkbox in GUI)
|
||||
|
||||
**This is the primary way to log time.** Comment + time in one call mirrors the GUI workflow exactly. Timer entries (`/tickets/{id}/timer_entry`) exist but are rarely used.
|
||||
**WARNING:** The comment endpoint accepts but silently ignores `product_id`, `minutes_spent`, and `bill_time_now` fields — they are not saved. Verified 2026-04-20. Always use the timer_entry endpoint to log time.
|
||||
|
||||
#### Customers
|
||||
|
||||
@@ -144,17 +140,35 @@ When showing ticket detail, include:
|
||||
|
||||
### Billing workflow
|
||||
|
||||
**ALWAYS ask the user for minutes and labor type before logging any time entry. Never assume a default.**
|
||||
**ALWAYS show a preview of the ticket comment/notes to the user before posting. Wait for confirmation.**
|
||||
|
||||
When `/syncro bill <number>` is called:
|
||||
1. Get ticket details
|
||||
2. Ask: "How many minutes + labor type?" (default: 60 min, Labor - Remote Business)
|
||||
3. Add comment with time: `POST /tickets/{id}/comment` with `product_id`, `minutes_spent`, `bill_time_now: false`, and work notes as body
|
||||
4. Then create invoice: `POST /invoices` with `{"ticket_id": N, "customer_id": N, "category": "Standard"}`
|
||||
5. Update ticket status to "Invoiced"
|
||||
2. Ask: "How many minutes should I bill, and what labor type? (remote / onsite / emergency / project / internal)"
|
||||
3. Draft the comment body and show it to the user for review before posting
|
||||
3. Add comment: `POST /tickets/{id}/comment` with work notes as body (no time fields — they are broken)
|
||||
4. Add timer entry: `POST /tickets/{id}/timer_entry` with `start_at`, `end_at`, `billable: true`, `product_id`, `notes`
|
||||
5. Create invoice: `POST /invoices` with `{"ticket_id": N, "customer_id": N, "category": "Standard"}`
|
||||
6. Update ticket status to "Invoiced"
|
||||
|
||||
**The flow mirrors the GUI: add comment with time attached → Make Invoice.**
|
||||
**Correct two-call pattern for comment + time:**
|
||||
```bash
|
||||
# Step 1: comment (notes only)
|
||||
curl -X POST "${BASE}/tickets/${ID}/comment?api_key=${API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"subject": "Resolution", "body": "...", "hidden": false, "do_not_email": true}'
|
||||
|
||||
# Step 2: timer entry (billable time) — compute start_at as end_at minus minutes
|
||||
NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
||||
START=$(date -u -d "60 minutes ago" +"%Y-%m-%dT%H:%M:%SZ")
|
||||
curl -X POST "${BASE}/tickets/${ID}/timer_entry?api_key=${API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"start_at\": \"${START}\", \"end_at\": \"${NOW}\", \"notes\": \"...\", \"billable\": true, \"product_id\": 1190473}"
|
||||
```
|
||||
|
||||
When `/syncro comment <number> <text> --time 60 --labor remote` is called:
|
||||
- Post the comment with time in one API call
|
||||
- Post the comment first, then post a separate timer_entry
|
||||
- `--labor` maps to product IDs: `remote` → 1190473, `onsite` → 26118, `emergency` → 26184, `project` → 9269129, `internal` → 9269124, `travel` → 26117, `website` → 68055
|
||||
|
||||
### Error handling
|
||||
|
||||
Reference in New Issue
Block a user