Skip to content
NEWError doctor and Watchtower: failed n8n runs explained in plain words, and emailed to you. See what is new

Library / Finance, Invoices & Accounting

Finance, Invoices & Accounting

Reconcile bank payments to invoices and ERP using Postgres and Claude

When an API call/webhook arrives, it processes financial data with Claude using Postgres, Slack.

What it does

## Intelligent Payment Reconciliation Engine Matches bank transactions against open invoices and ERP cash-application records using a layered rules engine, escalates borderline cases to Claude for review, writes every decision to Postgres, and optionally posts confirmed matches back to the ERP. Re-runnable and idempotent: matches are keyed by bank transaction id, human-approved rows are never overwritten, and already-reconciled items are skipped on the next run. ### How it works - Pulls invoices, bank transactions and ERP payments in parallel. - Scores each candidate on reference, amount (exact / tolerance), fuzzy customer name and payment timing. - Handles multi-invoice payments, partial/over-payments, duplicates and ERP conflicts. - Score ≥ 0.90 auto-matches; 0.55–0.90 goes to AI + human review; below is unmatched. - Borderline cases are reviewed by Claude with strict guard rails. - Results are written atomically to Postgres; optional ERP write-back for auto-matches. - Slack alert only when something needs attention. ### Setup 1. Attach a Postgres credential to the three Postgres nodes. 2. Edit the CONFIG object inside Code - Load Config & Rules (source URLs, tokens, field maps, matching thresholds, AI key, Slack webhook). 3. Keep erpWriteBack.enabled = false for the first dry runs. 4. Source APIs are read with a single page (limit 1000). Narrow lookbackDays or add pagination for larger volumes. ### Customization tips - Tune scoring weights, autoMatchScore, reviewScore and amount tolerances. - Disable AI (ai.enabled: false) or change the model. - Adjust legal-suffix list and high-value threshold for exceptions.

The steps

  1. Webhook Trigger
  2. Schedule Trigger
  3. Manual Trigger
  4. Postgres - Ensure Tables
  5. Postgres - Load Reconciled IDs
  6. Code - Load Config & Rules
  7. HTTP - Fetch Invoices
  8. HTTP - Fetch Bank Transactions
  9. HTTP - Fetch ERP Payments
  10. Code - Normalize Invoices
  11. Code - Normalize Bank Transactions
  12. Code - Normalize ERP Payments
  13. Merge - Combine Sources
  14. Code - Combine & Check Sources

33 steps in total.

Similar automations