order_to_cash_agent/
Order to Cash
From the credit decision on an order to cash landing against the invoice: who can buy, what gets billed, who gets chased, and how receipts and short-payments are cleared.
Process
- Compute days paid late = average days-to-pay minus terms (floored at 0, capped at 60).
- Score 0–100: 40 pts bureau score (300–850 scaled), 35 pts payment timeliness, 25 pts company size (log of revenue, capped at $500M).
- Bucket into risk class: below 45 High, 45–65 Medium, 65–80 Low, 80+ Minimal.
- Recommended limit = annual revenue × 0.2% × score / 100, rounded to the nearest $1k.
- Order decision: if open AR + pending order fits within the limit → Release; otherwise High risk → Hold for credit review, anything else → Release with approval.
- Inputs
- Customer master: annual revenue, average days-to-pay, payment terms, bureau score, current limit, open AR, pending order value.
- Outputs
- Scored customer table with recommended limit and order decision; count of holds and limit changes.
- Human checkpoint
- Credit manager approves holds and limit changes.
- Claude writes
- Credit review memo for the weakest customer.
- Run
python -m order_to_cash_agent.credit.agent
Process
- Check mandatory fields: buyer tax ID, PO number, line total, tax rate.
- Recompute tax (line total × rate) and flag a mismatch above 1 cent.
- Flag zero-rated non-US invoices that need an exemption code.
- Mark each invoice Ready or Blocked with its list of errors.
- Pick the channel by country: DE Peppol, FR Chorus Pro / PDP, IN GST IRP (IRN + QR), IT SdI, US customer AP portal or email PDF.
- Build a UBL-style JSON payload for Ready invoices.
- Inputs
- Outgoing invoices: customer, country, buyer tax ID, PO number, line total, tax rate, tax amount.
- Outputs
- Invoice list with status, channel and errors; ready vs blocked counts.
- Human checkpoint
- Billing fixes blocked invoices before resubmission.
- Run
python -m order_to_cash_agent.einvoicing.agent
Process
- Keep open invoices and compute days past due.
- Roll up per customer: open AR, past-due amount, max days past due, number of open invoices.
- Risk score = 0.5 × past-due share (vs worst customer) + 0.4 × max days past due (normalised) + 0.1 × invoice count (normalised).
- Pick a strategy from max days past due: over 60 escalate (call + credit-hold review), over 30 collector call, over 0 friendly email, otherwise pre-due courtesy note.
- Sort the worklist by risk score and draft a dunning email for the top customer.
- Inputs
- Open invoices: customer, due date, open amount.
- Outputs
- Collector worklist with risk score and strategy; total open AR, total past due, % past due.
- Human checkpoint
- Collector reviews and sends the email, works the list.
- Claude writes
- Dunning email for the highest-risk customer.
- Run
python -m order_to_cash_agent.collections.agent
Process
- Reference match: if the remittance cites invoice IDs, apply to those invoices.
- Otherwise identify the customer by fuzzy match of payer name to the customer list.
- Amount match: look for one, two or three of that customer's open invoices that sum to the receipt (within $0.01).
- Remove matched invoices from the open pool so they can't be applied twice.
- Anything still unmatched is a short-pay or unknown payment → exception queue for Deductions.
- Inputs
- Open invoices; bank receipts with payer name, amount and remittance reference.
- Outputs
- Receipt-to-invoice matches with method and confidence; auto-match rate; exception count.
- Human checkpoint
- Cash app analyst works the exception queue.
- Run
python -m order_to_cash_agent.cash_application.agent
Process
- Classify the memo by keyword into promo, pricing, shortage, damage, freight, compliance or unknown.
- Promo: valid if a promo agreement exists, otherwise invalid.
- Shortage or damage: invalid if the POD was signed clean, otherwise valid.
- Compliance fines (late delivery, ASN, labels): dispute and request retailer backup.
- Anything else under $100: auto write-off. Otherwise route to an analyst for research.
- Map each decision to the next action: clear against accrual, send dispute with POD/contract, request backup, route, or write off.
- Inputs
- Deductions with memo text and amount; whether a promo agreement exists; whether proof of delivery was signed clean.
- Outputs
- Coded deductions with decision and next action; count and value by decision.
- Human checkpoint
- Analyst researches open items and approves disputes.
- Claude writes
- Dispute letter for an invalid deduction, citing the evidence.
- Run
python -m order_to_cash_agent.deductions.agent
accounts_payable_agent/
Accounts Payable
From a supplier joining, to their invoice being matched, to the cash leaving: onboarding risk, three-way match and an optimised payment run.
Process
- Pull the invoice number out of each supplier question and look up its status and payment date.
- Answer the supplier in one or two sentences.
- Screen onboarding: sanctions-list hit → Block.
- Bank details changed in the last 30 days and the email domain doesn't match → Hold for call-back verification.
- Missing tax form → Hold. No flags → Approve.
- Inputs
- AP ledger (invoice, status, pay date); supplier questions; onboarding records (tax form, recent bank change, email domain match).
- Outputs
- Answered queries; onboarding decisions with risk flags.
- Human checkpoint
- AP verifies held suppliers by phone before approval.
- Claude writes
- Help-desk answers to supplier questions.
- Run
python -m accounts_payable_agent.supplier_portal.agent
Process
- Extract vendor, invoice number, PO, quantity and unit price from invoice text (regex stand-in for OCR or LLM extraction).
- Join each invoice to its PO and goods receipt.
- Repeat vendor + invoice number → Reject as duplicate.
- Price more than 2% off the PO → Exception: price variance.
- Billed quantity above quantity received → Exception: qty > received.
- Otherwise Matched → post, with the GL account taken from the vendor's default coding.
- Inputs
- Invoice text; purchase orders (quantity, unit price); goods receipts (quantity received).
- Outputs
- Invoice table with GL account, price variance and status; touchless %, exceptions, duplicates.
- Human checkpoint
- Buyer resolves price and quantity exceptions.
- Claude writes
- Exception summary for the AP manager with next steps.
- Run
python -m accounts_payable_agent.ap_automation.agent
Process
- Annualise each discount: rate / (1 − rate) × 365 / days paid early.
- Capture the discount if it beats the 8% cost of cash and the discount date hasn't passed.
- Include invoices due within the next 7 days; defer everything else.
- Choose the rail: international → wire, card-accepting vendors → virtual card (rebate), otherwise ACH.
- Order discounts first (highest return first), then due items, and add to the run until available cash runs out.
- Inputs
- Approved invoices with due date and early-pay discount terms; cash available for the run.
- Outputs
- Payment run with amount, reason, rail and in-run flag; discounts captured, rail mix, items deferred for cash.
- Human checkpoint
- Treasury or the controller approves the run before release.
- Run
python -m accounts_payable_agent.vendor_payments.agent
close_reconciliation_agent/
Close & Reconciliation
Month-end orchestration plus the reconciliations that feed it, from daily revenue to balance-sheet sign-off and intercompany.
Process
- Expected net = gross orders × (1 − contracted fee rate).
- Fee variance = settlement net − expected net; deposit gap = bank deposit − settlement net.
- No settlement file → Missing settlement file.
- No deposit → Deposit not received (likely timing).
- Fee variance above $50 → Fee / chargeback variance. Otherwise Matched.
- Inputs
- Per day and processor: gross orders, contracted fee rate, settlement net, bank deposit.
- Outputs
- Exception lines only; match rate, gross revenue, unexplained fee variance.
- Human checkpoint
- Revenue accountant chases missing files and disputes fees.
- Run
python -m close_reconciliation_agent.daily_revenue_reconciliation.agent
Process
- Variance = supporting balance − GL balance.
- Subtract known reconciling items to get the unexplained variance.
- Risk-rate accounts: cash, intercompany and deferred revenue High; balances over $1M Medium; else Low.
- Zero variance and not High → Auto-certified. Zero variance and High → reviewer sign-off.
- Unexplained under $1,000 → reviewer sign-off. $1,000 or more → Exception: investigate.
- Inputs
- GL balance and supporting balance (sub-ledger, bank, external) per account; open reconciling items.
- Outputs
- Reconciliation table with explained/unexplained variance, risk and status.
- Human checkpoint
- Reviewer signs off; accountant books adjusting entries for exceptions.
- Claude writes
- Explanation of exceptions and suggested adjusting entries.
- Run
python -m close_reconciliation_agent.balance_sheet_reconciliation.agent
Process
- Translate every balance to USD.
- Pair each creditor's AR with the debtor's AP for the same entity pair.
- Status: missing AP booking, missing AR booking, matched (difference under $100) or amount mismatch.
- Net each entity's receivables against its payables.
- Positive net → receive from the netting centre; negative → pay the netting centre.
- Inputs
- Intercompany AR and AP by entity pair in local currency.
- Outputs
- Pair-level match table; netting positions; gross vs net settlement and % reduction.
- Human checkpoint
- Entity accountants fix unmatched bookings before eliminations.
- Run
python -m close_reconciliation_agent.intercompany.agent
Process
- Compute each task's planned finish day from its dependencies and duration.
- Flag tasks as late if their planned finish has passed and they aren't done.
- List what is blocking each task (unfinished dependencies).
- Walk back from the last-finishing task to get the critical path and projected close day.
- Turn GRNI into an accrual journal: debit the expense GL, credit 2100 Accrued Liabilities.
- Inputs
- Close tasks with dependencies, duration and status; received-not-invoiced (GRNI) items; current close day.
- Outputs
- Task table with planned finish, blockers and late flag; critical path; accrual journal.
- Human checkpoint
- Controller unblocks tasks and approves the accrual journal.
- Claude writes
- Close status update for the Controller.
- Run
python -m close_reconciliation_agent.financial_close.agent
consolidation_reporting_agent/
Consolidation & Reporting
Rolls entity books into one set of group numbers, then explains them.
Process
- Translate balance-sheet accounts at the closing rate and P&L accounts at the average rate.
- Plug each entity's translation difference to CTA in OCI.
- Aggregate all entities in USD.
- Eliminate IC receivable / payable and IC revenue / COGS; send any elimination difference to P&L.
- Compute non-controlling interest on partly owned entities (IN01, 80% owned).
- Check the consolidated TB balances to zero.
- Inputs
- Trial balances per entity in local currency; closing and average FX rates; ownership %.
- Outputs
- Consolidated TB by entity with eliminations; IC difference, NCI share, consolidated net income.
- Human checkpoint
- Group reporting reviews eliminations and the IC difference.
- Run
python -m consolidation_reporting_agent.financial_consolidation.agent
Process
- Compute variance to budget (amount and %) and to prior month.
- Flag a line only if both thresholds break: more than 3% and more than $50k.
- Mark favourable or unfavourable.
- Draft commentary for flagged lines; unknown drivers are written as 'driver TBC with owner'.
- Inputs
- P&L lines: actual, budget, prior month.
- Outputs
- Flux table with flags; revenue vs budget %, EBITDA margin; draft commentary.
- Human checkpoint
- Line owners confirm drivers before the CFO pack goes out.
- Claude writes
- CFO-pack commentary, told not to invent business drivers.
- Run
python -m consolidation_reporting_agent.financial_reporting.agent
treasury_risk_agent/
Treasury & Risk
Where the cash is today, where it will be in 13 weeks, and whether today's outgoing payments are safe to release.
Process
- Translate balances to USD for the global position.
- Within each entity and currency, sweep any excess over target from non-header accounts to the header account.
- Fund any account below its minimum from the header account.
- Idle cash = global cash − buffer − sum of account targets.
- Propose idle cash for money-market fund or T-bill placement.
- Inputs
- Bank accounts per entity with balance, target and minimum (minimum = 50% of target); header account flag; group buffer ($5M).
- Outputs
- Proposed transfers; cash by entity; idle cash to invest.
- Human checkpoint
- Treasurer approves transfers and investments.
- Claude writes
- Morning cash brief for the Treasurer.
- Run
python -m treasury_risk_agent.cash_management.agent
Process
- Per category, forecast = the same week one season (26 weeks) earlier × a trend factor.
- Trend = mean of the last 26 weeks / prior 26, clipped to 0.8–1.2 (1.0 if the sign flipped).
- Back-test: hold out the last 13 weeks, forecast them, report MAPE per category.
- Forecast the next 13 weeks, sum net flow, roll closing cash from the opening balance.
- Find the low point (week and balance).
- Inputs
- 52 weeks of cash flows by category (AR receipts, other inflows, payroll, AP, rent, tax); opening cash.
- Outputs
- 13-week forecast by category with net flow and closing cash; low point; back-test MAPE.
- Human checkpoint
- Treasury reviews the low point and any category with poor accuracy.
- Claude writes
- Four-bullet CFO summary of the forecast.
- Run
python -m treasury_risk_agent.cash_forecasting.agent
Process
- Score each payment against the beneficiary's history (z-score of log amount).
- Watchlist hit → BLOCK.
- Same beneficiary and amount twice in the batch → HOLD: duplicate.
- Bank details changed → HOLD for call-back. |z| above 3 → HOLD: amount anomaly. Otherwise Clear.
- Approvers: up to $50k analyst; up to $500k analyst + manager; above that manager + CFO.
- Generate an ISO 20022 pain.001-style file for cleared payments.
- Inputs
- Payment batch (beneficiary, amount, bank-detail change flag); payment history per beneficiary; watchlist.
- Outputs
- Screened batch with anomaly score, decision and approvers; release value; pain.001 payload.
- Human checkpoint
- Named approvers release; holds are investigated first.
- Run
python -m treasury_risk_agent.treasury_payments.agent
b2b_payments_agent/
B2B Payments
Accepting customer payments at the lowest cost: routing, surcharging and interchange qualification.
Process
- Keep routes that support the currency and amount and match the customer's preferred method.
- Drop ACH for urgent payments.
- Pick the route with the lowest expected cost per successful payment = fee / auth rate (fallback: wire).
- Set a retry plan from the decline code: insufficient funds → retry in 3 days; issuer unavailable → retry in 1h on another processor; do not honor → don't retry, ask for ACH.
- Inputs
- Payments with amount, currency, preferred method, urgency, last decline code; processor fee, auth-rate and limit table.
- Outputs
- Route, method, fee and retry plan per payment; savings vs sending everything by card.
- Human checkpoint
- Payments ops reviews the routing rules and retries.
- Run
python -m b2b_payments_agent.payment_gateway.agent
Process
- Debit or prepaid card → no surcharge.
- State where surcharging is prohibited → no surcharge (the state list is illustrative).
- Otherwise surcharge = the lower of the 3% network cap and the actual cost of acceptance.
- Generate customer-facing disclosure text.
- Inputs
- Card payments with amount, card type, US state and cost of acceptance.
- Outputs
- Surcharge % and amount with reason; fees incurred vs recovered.
- Human checkpoint
- Legal confirms current state rules before go-live.
- Run
python -m b2b_payments_agent.surcharge_management.agent
Process
- Classify current data level: tax + PO + line items = L3; tax + PO = L2; else L1.
- Where the invoice is available, enrich the missing fields to reach L3.
- Price before and after at illustrative rates (L1 2.70%, L2 2.25%, L3 1.90%).
- Inputs
- Card transactions with flags for tax amount, PO and line items; whether the matching invoice is available.
- Outputs
- Level before and after, fees and saving per transaction; total saving in $ and bps.
- Human checkpoint
- Payments ops reviews the enrichment mapping.
- Run
python -m b2b_payments_agent.interchange_fee_optimizer.agent
running it
Try an agent
ai-cfo
# from the repo root
pip install -r requirements.txt
# run one agent on synthetic data, offline (template text, no API call)
AGENT_OFFLINE=1 python -m order_to_cash_agent.collections.agent
# let Claude write the narrative
export ANTHROPIC_API_KEY=…
python -m treasury_risk_agent.cash_forecasting.agent
These are proofs of concept on synthetic data. Fee rates, FX rates, thresholds and the surcharge state list are illustrative. Confirm them, and swap in real ERP and bank feeds, before relying on any output.
← Back to AI