# Command: run-weekly-ar-aging-review

Analyze open invoices, categorize by age, and escalate overdue accounts for collection action.

## Inputs

**ledger_date** — Report as-of date; defaults to today.
**overdue_threshold_days** — Invoices past this many days trigger escalation; default 30.
**email_recipients** — Internal accounting team addresses (comma-separated); defaults to ops@newx.app.
**min_amount** — Only escalate invoices above this threshold (USD); default 500.

## Steps

1. Query the ledger for all open invoices dated before the ledger_date.
2. Calculate age in days for each invoice; bucket by category (current, 1-30, 31-60, 61-90, 90+).
3. Generate a summary table showing invoice count and total amount per bucket.
4. For each invoice exceeding both overdue_threshold_days and min_amount, draft an outbound task titled "APPROVAL: Collection Follow-up — [Customer] $[Amount]".
5. Attach invoice details (due date, amount, contact) to each task; set priority to urgent.
6. Email the aging summary and task count to email_recipients.

## Constraints

- Read-only on the ledger; never modify balances or record payments.
- Each escalation creates a staged human-review task; no automatic payment or journal entry.
- Do not recommend specific collection tactics or legal actions.

Done when: aging summary is emailed, overdue invoices have corresponding open approval tasks, and internal team can act on them.