Innovation Engine — automation

Invoice Aging Sentinel

June 11, 2026

Watches the bys-website invoice ledger (which just gained a record-payment endpoint) and catches unpaid invoices before they go stale. When an invoice crosses 14 days unpaid, it stages a polite, client-ready nudge email as a Gmail draft on the bys account and pings you via pm-notify — so collections become a one-click review instead of a thing you remember at month-end.

bys-website invoicinggws Gmail (bys account)pm-notify/Telegram

Create ~/bin/invoice-aging-sentinel (bash, ~80 lines): (1) query the bys-website invoice store — hit the same API surface the new record-payment endpoint lives on (GET invoices where status != 'paid'), or fall back to its DB directly; (2) compute age from issue date, filter >= 14 days; (3) skip anything already nudged via a state file at ~/.local/state/invoice-aging/nudged.json (keyed by invoice id + age bucket, so it can re-fire at 30/45 days); (4) for each hit, stage a draft via the gws CLI (env GOOGLE_WORKSPACE_CLI_CONFIG_DIR=/home/ethan/.config/gws-bys, gmail_create_draft — draft, not send, so bounded-email rules stay intact) with client name, invoice number, amount due, and days outstanding; (5) fire pm-notify + notify-focus with a one-line summary ('Invoice #1042 — DeBoer — $2,400 — 21 days, draft staged'). Install via the safe-append crontab pattern at 8am daily. Add invoice-aging-sentinel.test.bats with a mocked API response asserting the 14-day filter, the state-file dedupe, and that paid invoices never trigger.

Needs Review
Build timed out after 5 minutes
Active Projects
russ-telegram, innovation-engine, joyos-lab-staging, joyos-labs-monitor, jekelinspections
Category
automation