Automated Invoice Generation from 'Closed-Won' CRM Deals to Xero (Zapier)

Streamline the quote-to-cash cycle by automatically syncing customer data and invoices to Xero.

Tools: CRMXero

Platform: Zapier

Short Answer

As soon as a deal status reaches 'Closed-Won' in your CRM, Zapier automatically finds or creates the contact in Xero and generates a draft invoice with correct line items, tax mapping, and billing details.

The Problem

Manual data entry between a CRM and Xero causes delayed invoicing, transcription errors, and fragmented customer records. Sales teams often forget to notify finance when a deal is won, leading to cash flow bottlenecks.

The Outcome

As soon as a deal status reaches 'Closed-Won' in your CRM, Zapier automatically finds or creates the contact in Xero and generates a draft invoice with correct line items, tax mapping, and billing details.

Step-by-Step Guide

1. **Create the Zap**: Log in to Zapier and click 'Create Zap'. Name it 'CRM Deal to Xero Invoice'. 2. **Set up Trigger**: Search for your CRM (e.g., Pipedrive, HubSpot). Choose the event 'Updated Deal Stage' or 'New Won Deal'. Connect your CRM account using OAuth or API Key. 3. **Add Filter by Zapier**: Add a step and select 'Filter'. Set the criteria so the Zap only continues IF the Deal Stage matches your 'Closed-Won' identifier. 4. **Format Data (Date/Time)**: Add 'Formatter by Zapier' -> 'Date/Time'. Convert the CRM deal close date into `YYYY-MM-DD` format to ensure Xero accepts the invoice date. 5. **Format Data (Text)**: If your CRM uses a single 'Name' field, use 'Formatter by Zapier' -> 'Text' -> 'Split Text' to separate First and Last names for Xero's contact fields. 6. **Find or Create Contact in Xero**: Add a 'Xero' step. Choose 'Find Contact'. Map the CRM Email field to the 'Search' criteria. Check the box 'Create Xero Contact if it doesn't exist yet' and map the CRM Company Name and Address fields. 7. **Map the Invoice Line Items**: Add a 'Xero' step. Choose 'Create Sales Invoice'. Use the ID from the previous 'Find/Create Contact' step in the 'Contact' field. Map Deal Title to 'Description', Amount to 'Unit Amount', and set 'Status' to 'Draft'. 8. **Standardize Account Codes**: Hardcode the 'Account Code' (e.g., 200 for Sales) or use a 'Lookup Table' in Formatter to map CRM Product Categories to Xero Chart of Accounts. 9. **Update CRM (Optional)**: Add a final step to your CRM to 'Update Deal'. Paste the 'Invoice Number' or 'Xero Link' from the Xero step into a custom field in the CRM for visibility. 10. **Enable Error Handling**: Click the '...' on the Xero step and select 'Add Error Handler' to use Zapier Manager to alert you via Slack/Email if the sync fails.

Data Mapping

| CRM Source Field | Xero Destination Field | Format/Transformation | Required | | :--- | :--- | :--- | :--- | | Deal/Amount | Line Items: Unit Amount | Use `{{amount}}` (Clean Decimals) | Yes | | Product/Label | Line Items: Description | Hardcode or Map Name | Yes | | Close Date | Date | Formatter: `YYYY-MM-DD` | Yes | | Account Name | Contact Name | Text Splitter (if needed) | Yes | | Billing Email | Contact Email | Direct Mapping | Yes | | N/A | Account Code | Hardcode (e.g., 200) | Yes | | Tax Status | Tax Type | Lookup Table (Exempt/Taxable) | No |

Gotchas & Failure Modes

* **Rate Limiting**: Xero API has a limit of 60 requests per minute. If you batch-update 100 deals, use 'Delay by Zapier' to stagger them. * **Reference Number Conflicts**: Xero requires unique Invoice Numbers if you provide them. It is safer to leave 'Invoice Number' blank so Xero generates it automatically. * **Contact Duplication**: Always use the 'Find Contact' step with an Email Address search. Searching by Name only can result in duplicates if there are slight spelling variances. * **Test Mode**: Xero does not provide a 'Sandbox' for standard users. When testing, set the Invoice Status to 'Draft' so it doesn't affect your actual books or trigger automated emails to clients.

Verification Checklist

- [ ] **Trigger Check**: Does the Zap trigger only when the 'Won' stage is reached? (Check History) - [ ] **Data Formatting**: Does the Formatter step correctly handle dates (no 'illegal date' errors in Xero)? - [ ] **Contact Logic**: Did the Zap find an existing contact in Xero instead of creating a duplicate? - [ ] **Line Item Accuracy**: Is the Unit Price and Quantity correctly multiplied in the Xero Draft Invoice? - [ ] **Account Code**: Is the revenue being mapped to the correct Chart of Account (e.g., 200 - Sales)?

Ready to Automate?

Build this automation with Zapier in minutes.