Skip to content

Domain deep dive — Finance, AR & integrations

Single D1 narrative for engineers working on accounts receivable, payment capture, and Xero / Stripe sync. It ties together:

In scopeOut of scope (link instead)
Xero OAuth, tenants, invoice/contact sync, webhooksFull ERPNext accounting curriculum
Stripe Payment Links, webhooks, Sales Invoice settlementStripe Connect marketplace features
Debt / collection DocTypes and Xero debt tablesLegal collections process (ops playbook)
Sales Invoice extensions, billing notes, invoice line bridgesPayrollPayroll & HR / payroll-hr

All custom tables grouped under finance-ar-integrations share one sidebar folder — use the category index as a map, not as runtime architecture.

Sub-themeExamples (see generated pages for fields)
Xero corexero_api_settings, xero_tenants, xero_organization, xero_invoice, xero_contact*, xero_invoice_sync
Stripestripe_settings, default_stipe_gateway, gateway selection vs company
AR / debtdebt_management, debt_collection, debt_call_notification, xero_debt_management_table
Bridgessales_invoice_billing_note, company_billing_note, invoice_services_list, sync_data
LayerPrimary locations
HTTP / webhooksleekimerp/api/xero.py, leekimerp/api/stripe.py, leekimerp/api/stripe_webhook.py
Routeshooks.pywebsite_route_rules for Stripe short paths (Stripe); Xero whitelist entries
Hookshooks.py doc_events — cross-check Doc events when changing AR documents
Desk / reportslee_kim_alliance_erp/report/ — AR, Xero, tax-related reports (Reports catalog)

Money and invoice truth can arrive from Desk, Stripe webhooks, or Xero webhooks — order depends on deployment. This diagram is logical, not a single guaranteed pipeline.

State

Capture

Sales Invoice

Stripe webhook

Xero webhook

xero_invoice / sync tables

debt_*

For a Billing-centric walkthrough (emails and Application), use Tutorial: Billing → Xero and Billing flow.

Use this table when extending docs/doctype-overlays/overlays.json (see docs/doctype-overlays/README.md in the repository for schema and workflow). Keys are DocType folder names (snake_case).

PriorityDocType keysRationale
P1 — Overlays presentxero_api_settings, xero_invoice, debt_management, billing (see incorporation category), stripe_settings, xero_tenants, sync_dataOAuth, invoice truth, debt, payment comms, Stripe company keys, tenant routing, Sync Data caveat
P2xero_contact, xero_invoice_sync, default_stipe_gateway, sales_invoice_billing_note, company_billing_noteReconciliation and SI bridges
P3Narrow list / child tables (xero_invoice_items, ccbcc_accounts, …)Field tables + parent link; overlay only if support tickets repeat

After editing overlays, run npm run generate:doctypes from docs/ and commit generated doctype-reference/** if your team tracks them.

SymptomFirst checks
Xero OAuth / token errorsXero API Settings, api/xero.py token helpers, clock skew
Webhook 401/403Signature secrets vs dashboard; allow_guest handlers — Security checklist
Stripe paid but SI stalestripe_webhook.py, Payment Entry, company keys in Stripe Settings
Debt workflow stuckDebt Management doc state, Xero debt tables, Debt management
Wrong tenant / companyXero Tenants, Company links, xero_tenants vs Customer mapping

Logs: Frappe Error Log, application server logs for Python tracebacks, provider dashboards (Xero/Stripe) for delivery and HTTP status.