How the AI works
LedgerGuard uses Claude for judgement: reading tone, choosing the next step, ranking evidence, turning questions into filters. Anything involving money, thresholds or sending is handled by plain code and by you. The model proposes; code bounds it; you approve.
1. Invoice chaser
- Code enforcesGather context
Amount, due date, days overdue, country, past payment speed, recent client messages.
- Claude decidesChoose the next action
Wait, remind, offer a split, offer Pay Later, or escalate, plus a tone and a suggested fee %.
- Code enforcesApply guardrails
Cap the fee at 1.5% (7+ days only), drop it for split or Pay Later, block escalation before 14 days, compute exact amounts.
- Claude decidesWrite the draft
Claude writes the email using only the figures code gave it.
- You decideApprove or ignore
Approving marks the draft; you copy and send it yourself. Paid invoices cancel pending drafts.
Split example: USD 1,450.00 → USD 725.00 now + USD 725.00 within 14 days, no fee.
2. Dispute defense
- PayPalDispute arrives
CUSTOMER.DISPUTE.CREATED webhook, or Sync reads /v1/customer/disputes.
- Code enforcesSearch evidence
Full-text search over that client's contracts, milestones, delivery notes and messages.
- Claude decidesRank evidence, flag gaps
Claude scores relevance; code keeps only real ids and clamps scores to 0–1.
- Claude decidesDraft the statement
A short factual response that cites evidence ids in brackets.
- You decideApprove & submit
Only this click calls provide-evidence, and a second submission is refused.
3. Ask the ledger
“past-due invoices over $1000”
{"conditions":[
{"field":"status","op":"in","value":["due","overdue_3","overdue_7"]},
{"field":"amount","op":"gt","value":1000},
{"field":"currency","op":"eq","value":"USD"}]}Allow-listed fields and ops only. Rows filtered, totals computed per currency. No SQL is ever generated.
Allowed fields: number, client, country, currency, status, amount, days_overdue, issue_date, due_date, paid_at. Up to 10 conditions.
The guardrails, in plain words
Late fee cap
At most 1.5% of the invoice, and only from 7+ days overdue. The fee amount is computed by code, never written by the model.
No fee with flexibility
If the action is a split payment or Pay Later, any fee is dropped.
Escalation threshold
Escalation is allowed only from 14+ days overdue; earlier it becomes a plain reminder.
Before the due date
No firm tone, no split, Pay Later or escalation; only a friendly reminder.
Exact split math
Two installments: first = amount ÷ 2 rounded to cents, second = amount − first, so they always sum to the total.
Draft check
A draft that mentions a fee the policy removed is replaced with a safe template.
Evidence ids
Ranked evidence must use ids that exist; relevance scores are clamped to 0–1.
Ledger filters
Questions become a JSON filter checked against an allow-list of fields and operators. Never SQL. Invalid output falls back to a rule parser.
Human approval
Reminders stay drafts. Evidence goes to PayPal only after Approve and confirm, and only once.