Xero integration
Purpose
Section titled “Purpose”Synchronize Xero invoices and contacts with ERPNext / custom flows, and receive webhooks from Xero.
Scope in codebase
Section titled “Scope in codebase”leekimerp/leekimerp/api/xero.py(primary)
Key DocTypes / concepts
Section titled “Key DocTypes / concepts”- Xero tenant and invoice mapping (see DocTypes under
lee_kim_alliance_erprelated to Xero — e.g. tenant tables, invoice linkage)
Webhook and sync flow
Section titled “Webhook and sync flow”sequenceDiagram participant Xero as Xero Cloud participant WH as Webhook handler participant API as xero.py handlers participant ERP as ERPNext Sales Invoice / Custom Xero->>WH: Invoice created/updated WH->>API: Verify signature, parse payload API->>ERP: Map line items, contacts API->>ERP: create_lk_erp_invoice / updateRepresentative functions (internal + exposed): xero_webhook_connection, handle_xero_call, handle_created_invoice, handle_updated_invoice, create_lk_erp_invoice, update_lk_erp_invoice, create_erpnext_sales_flow, sync_xero_invoices, get_xero_invoices.
Entry points
Section titled “Entry points”| Type | Function | Notes |
|---|---|---|
| API (GET) | get_app_webhook_secret | allow_guest=True — review exposure |
| API (POST) | xero_webhook_connection | Webhook payload |
| API | sync_contact_with_tenant, create_contact, update_sync_status | Contact sync |
| API (GET) | get_xero_invoices, sync_xero_invoices | Fetch/sync |
| API | make_new_item, get_total_amount_due_by_contact, get_officers | Business helpers |
Exact signatures and return shapes: read api/xero.py.
Dependencies
Section titled “Dependencies”- OAuth token storage (
obtain_xero_oauth2_token,store_xero_oauth2_token) - ERPNext Sales Invoice, Customer, Item as applicable
Configuration
Section titled “Configuration”- Xero app credentials and tenant records in Frappe (DocTypes as defined in the project)
Operational notes
Section titled “Operational notes”- Webhook signature verification:
xero_webhook_verification - Use test_mode flags where present (
invoice_fetcher,get_xero_invoices) during UAT
Known gaps
Section titled “Known gaps”- Maintain parity with Xero API version changes; regression-test webhook and polling paths after upgrades.