Overview
Hub accountants use Xero for bookkeeping. Manually re-entering every invoice and payment into Xero is time-consuming and error-prone. Auto-syncing ManageHub invoices and payments to Xero eliminates this.
Context
InvoicesModule: backend/src/invoices/ — source of invoice data
PaymentsModule: backend/src/payments/ — source of payment data
- Package:
xero-node (Xero's official Node.js SDK)
@nestjs/schedule: for nightly reconciliation cron job
Tasks
Files to Modify / Create
- New:
backend/src/integrations/xero/ (module, entity, controller, service)
backend/src/app.module.ts
Overview
Hub accountants use Xero for bookkeeping. Manually re-entering every invoice and payment into Xero is time-consuming and error-prone. Auto-syncing ManageHub invoices and payments to Xero eliminates this.
Context
InvoicesModule:backend/src/invoices/— source of invoice dataPaymentsModule:backend/src/payments/— source of payment dataxero-node(Xero's official Node.js SDK)@nestjs/schedule: for nightly reconciliation cron jobTasks
XeroConnectionentity:id,hubId(singleton — one per hub),accessToken(encrypted),refreshToken(encrypted),tenantId,connectedAt,expiresAtGET /integrations/xero/connect— initiate Xero OAuth 2.0 PKCE flow (admin only)GET /integrations/xero/callback— exchange code for tokens; store inXeroConnectionDELETE /integrations/xero— disconnect and deleteXeroConnection(admin only)GET /integrations/xero/status— returns connection status (admin only)PAIDevent: create a matching Xero Invoice via Xero Accounting APISUCCESSevent: create a Xero Payment record linked to the Xero Invoice@Cron('0 4 * * *')reconciliation job: sync last 24 hours of invoices/payments; log discrepanciesFiles to Modify / Create
backend/src/integrations/xero/(module, entity, controller, service)backend/src/app.module.ts