Skip to main content
Insyrge - Zoho CRM & Business Automation Consulting
← Back to All ArticlesAI & Business Automation

Zoho Books Invoice Automation with Deluge

Create invoices and purchase orders in Zoho Books straight from CRM deals with Deluge, without duplicates or retyping.

•Manav Sharma
Zoho Books Invoice Automation with Deluge

Set up Zoho Books invoice automation with Deluge: create invoices from won deals, map items and taxes, and avoid duplicates. Includes a worked script.

Creating invoices and purchase orders by hand is one of the most common bottlenecks we see in Zoho-based businesses. A deal closes in Zoho CRM, someone copies the details into Zoho Books, adds the line items again, checks the tax, and sends it. Each step is quick, but repeated across a month it adds up, and every retyped figure is a chance for a mistake. Zoho Books invoice automation removes that retyping. This guide covers when the built-in features are enough, when a Deluge function is the better choice, and a worked example that creates an invoice from a won deal safely.

Start with what Zoho Books already does

Before writing any code, check whether a built-in feature covers your case. Zoho Books includes recurring invoices for subscriptions and retainers, and Zoho offers integration between Zoho CRM and Zoho Books for syncing customers and items. Zoho Flow can also connect events across apps without custom code.

Built-in options are usually enough when:

  • You bill the same amount on a fixed schedule
  • One CRM deal becomes one invoice with standard items
  • Your tax setup is straightforward and the same for most customers

When Deluge is the better tool

Custom Deluge functions make sense when billing follows rules that the standard features cannot express. Typical examples from our projects include:

  • Milestone billing, where each stage of a project produces its own invoice
  • Line items built from a CRM subform, with quantities, discounts and custom descriptions
  • Different Books organisations or branches depending on the customer's region
  • Purchase orders raised automatically for each vendor when a sales order is confirmed
  • Invoices that need an approval step before they are sent

Deluge runs inside Zoho, so there is no separate server to host, and it can call Zoho Books through the built-in zoho.books.createRecord task, authorised by a named connection.

Designing a reliable Zoho Books invoice automation

Whichever trigger you use, a few design rules prevent the most common problems.

One trigger, one invoice

The function must never create two invoices for the same event. Store the Books invoice ID back on the CRM record and check it before creating anything. Use the deal ID as the invoice's reference number so finance can trace it.

Map items by ID, not by name

Product names drift. Store the Zoho Books item ID on each CRM product so line items always point to the right item, rate and tax.

Let Zoho Books calculate tax

Pass the tax ID or let item defaults apply rather than calculating tax in Deluge. That keeps GST or VAT logic in one place, maintained by the finance team.

Fail loudly

If Books rejects the request, notify a person with the error message. A silent failure means a customer is never billed.

Worked example: creating a Zoho Books invoice from a won deal

The illustrative function below runs from a Zoho CRM workflow when a deal moves to Closed Won. It reads line items from a deal subform, creates the invoice in Zoho Books and writes the invoice ID back to the deal. Organisation ID, connection name, subform and field API names are placeholders for your own setup. Field names on the Books side follow the Zoho Books invoices API.

// Argument: dealId
booksOrgId = "YOUR_BOOKS_ORG_ID";
deal = zoho.crm.getRecordById("Deals", dealId);

// 1. Never invoice the same deal twice
if(deal.get("Books_Invoice_ID") != null && deal.get("Books_Invoice_ID") != "")
{
    info "Invoice already exists for this deal";
    return;
}

// 2. Find the Books customer linked to the CRM account
account = zoho.crm.getRecordById("Accounts", deal.get("Account_Name").get("id"));
customerId = account.get("Books_Customer_ID");
if(customerId == null || customerId == "")
{
    sendmail
    [
        from: zoho.adminuserid
        to: "[email protected]"
        subject: "No Books customer for " + account.get("Account_Name")
        message: "Deal " + deal.get("Deal_Name") + " is won but the account has no linked Books customer."
    ]
    return;
}

// 3. Build line items from the deal's subform
lineItems = List();
for each row in deal.get("Billing_Lines")
{
    line = Map();
    line.put("item_id", row.get("Books_Item_ID"));
    line.put("description", row.get("Description"));
    line.put("quantity", row.get("Quantity"));
    line.put("rate", row.get("Rate"));
    lineItems.add(line);
}

// 4. Create the invoice in Zoho Books
invoice = Map();
invoice.put("customer_id", customerId);
invoice.put("reference_number", dealId.toString());
invoice.put("line_items", lineItems);
resp = zoho.books.createRecord("Invoices", booksOrgId, invoice, "books_connection");

// 5. Store the result or report the failure
if(resp.get("code") == 0)
{
    inv = resp.get("invoice");
    zoho.crm.updateRecord("Deals", dealId, {"Books_Invoice_ID": inv.get("invoice_id"), "Books_Invoice_Number": inv.get("invoice_number")});
}
else
{
    sendmail
    [
        from: zoho.adminuserid
        to: "[email protected]"
        subject: "Invoice not created for deal " + deal.get("Deal_Name")
        message: resp.toString()
    ]
}

The invoice is created as a draft by default in most setups, which gives finance a chance to review it before sending. If you want invoices sent automatically, add that step only after a period of reviewing drafts.

Automating purchase orders from sales orders

The same pattern works for purchasing. When a sales order is confirmed, a function can group its line items by preferred vendor and create one purchase order per vendor in Zoho Books. The design points are similar:

  • Store the vendor ID on each item, so grouping is reliable
  • Write each purchase order ID back to the sales order, so a re-run does not duplicate it
  • Raise purchase orders as drafts for a buyer to approve
  • Check the module name and required fields for purchase orders in the Zoho Books API documentation before building

For products you keep in stock, reorder points in Zoho Inventory may suit better than order-driven purchase orders. The right choice depends on whether you buy to order or buy to stock.

Testing before going live

Run every billing automation against a test organisation or a copy of your data before it touches real customers. Our test checklist includes:

  • A deal with one line item, several line items, and a discount
  • A customer with no linked Books record, to confirm the alert fires
  • The same deal triggered twice, to confirm no duplicate invoice
  • Customers in different tax situations, such as intra-state and inter-state GST
  • Very large quantities or amounts, to check rounding

Every call to Zoho Books from Deluge counts against your plan's external call limits, as Zoho's documentation for the task notes, so keep loops efficient and avoid calling Books for records that have not changed.

Who should own billing automations

Billing automations sit between sales and finance, which means it is easy for nobody to own them. We recommend naming one owner on the finance side who approves changes to invoice logic, and one technical owner who maintains the functions. Keep a short document listing each automation, its trigger, the Books organisation it writes to and who to contact when it fails. When tax rules, price lists or payment terms change, that document tells you exactly which functions need updating, instead of discovering the problem from a customer's complaint.

Common mistakes we fix

  • Creating invoices from a workflow that fires on every edit, not just on the stage change
  • Matching customers by name, which creates duplicates when spelling differs
  • Hard-coding tax percentages in the script
  • Losing the link between the CRM deal and the Books invoice, so nobody can trace a payment back to a sale

Invoicing is usually one step in a longer chain from quote to payment. Our guide to building an automated quote-to-cash workflow shows how the pieces fit together, and if your accounting runs in an ERP rather than Zoho Books, see Zoho CRM to ERP integration with automated ledger reconciliation.

Frequently Asked Questions

Can Zoho Books create invoices automatically from Zoho CRM?

Yes. Simple cases can use Zoho's built-in CRM and Books integration or Zoho Flow. For custom line items, milestone billing or approval steps, a Deluge function triggered by a CRM workflow gives full control.

Will Deluge-created invoices include the right GST?

They will if items carry the correct tax settings in Zoho Books and the customer's tax details are complete. We recommend letting Books apply tax rather than calculating it in the script.

How do we stop duplicate invoices?

Store the Books invoice ID on the CRM record and check it before creating a new invoice. Trigger the workflow only on the specific stage change, not on every edit.

Can purchase orders be automated in the same way?

Yes. A function can create purchase orders in Zoho Books from confirmed sales orders, grouped by vendor, and store each purchase order ID back on the source record.

Automate your billing with us

We build Zoho Books and Zoho CRM automations that create invoices and purchase orders reliably, with tracing and alerts built in. See our Zoho CRM automation services, or talk to us about automating your invoicing.

About the Author

Manav Sharma is the founder of Insyrge and a CRM solutions architect. He works across Zoho, Salesforce, HubSpot, Odoo and more, designing the CRM setups, integrations and automations that keep sales and operations teams working from the same data.

Need Help Implementing This in Your Business?

Our certified Zoho consultants and automation experts can help you design and deploy custom workflows tailored to your operations.

Book Free Consultation