For Zoho services only


I'm currently part of a wider delivery team at Ascent Business Solutions, recognised as a leading Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions support organisations with everything from targeted technical fixes through to full Zoho CRM implementations and long-term platform adoption. Working as a team rather than a one-person consultancy allows projects to move forward consistently, with access to the right skills at each stage.

The team I manage specialises in API integrations between Zoho and third-party finance and commerce platforms such as Xero, Shopify, WooCommerce, and eBay. Much of our work involves solving integration challenges that fall outside standard documentation, supporting new ideas, new sectors, and evolving business models.

Success is measured through practical outcomes and return on investment, ranging from scaling small operations into high-turnover businesses to delivering rapid gains through online payments, automation, and streamlined digital workflows.

If you are looking for structured Zoho expertise backed by an established consultancy, you can contact Ascent Business Solutions on 0121 392 8140 (UK), email info@ascentbusiness.co.uk, or visit https://www.ascentbusiness.co.uk.
Zoho Books: Get Invoice Payment Terms via API

Zoho Books: Get Invoice Payment Terms via API

What?
A quick article on getting the payment terms in Zoho Books along with their IDs.

Why?
I often need to send through an automatic payment term on the creation of an invoice but lots of my clients set their due dates differently.

How?
The following snippet of code will query the metadata api in Zoho Books and return a JSON of what the payment terms are.

copyraw
void fn_ReturnCurrentPaymentTerms()
{
	v_BooksOrgID = "12345678901";
	r_PaymentTerms = invokeurl
	[
		url :"https://www.zohoapis.com/books/v3/settings/paymentterms?organization_id=" + v_BooksOrgID
		type :GET
		connection:"zbooks"
	];
	info r_PaymentTerms;
}
  1.  void fn_ReturnCurrentPaymentTerms() 
  2.  { 
  3.      v_BooksOrgID = "12345678901"
  4.      r_PaymentTerms = invokeurl 
  5.      [ 
  6.          url :"https://www.zohoapis.com/books/v3/settings/paymentterms?organization_id=" + v_BooksOrgID 
  7.          type :GET 
  8.          connection:"zbooks" 
  9.      ]
  10.      info r_PaymentTerms; 
  11.  } 
Deprecated pre domain change:
copyraw
void fn_ReturnCurrentPaymentTerms()
{
	v_BooksOrgID = "12345678901";
	r_PaymentTerms = invokeurl
	[
		url :"https://books.zoho.com/api/v3/settings/paymentterms?organization_id=" + v_BooksOrgID
		type :GET
		connection:"zbooks"
	];
	info r_PaymentTerms;
}
  1.  void fn_ReturnCurrentPaymentTerms() 
  2.  { 
  3.      v_BooksOrgID = "12345678901"
  4.      r_PaymentTerms = invokeurl 
  5.      [ 
  6.          url :"https://books.zoho.com/api/v3/settings/paymentterms?organization_id=" + v_BooksOrgID 
  7.          type :GET 
  8.          connection:"zbooks" 
  9.      ]
  10.      info r_PaymentTerms; 
  11.  } 

This should yield something as follows:
copyraw
{
  "code": 0,
  "message": "success",
  "data": {
    "payment_terms": [
      {
        "payment_terms_id": "123456000000000123",
        "payment_terms": 15,
        "is_default": false,
        "payment_terms_label": "Net 15"
      },
      {
        "payment_terms_id": "123456000000000124",
        "payment_terms": 30,
        "is_default": false,
        "payment_terms_label": "Net 30"
      },
      {
        "payment_terms_id": "123456000000000125",
        "payment_terms": 45,
        "is_default": false,
        "payment_terms_label": "Net 45"
      },
      {
        "payment_terms_id": "123456000000000126",
        "payment_terms": 60,
        "is_default": false,
        "payment_terms_label": "Net 60"
      },
      {
        "payment_terms_id": "",
        "is_mandatory": true,
        "payment_terms": -2,
        "payment_terms_label": "Due end of the month"
      },
      {
        "payment_terms_id": "",
        "is_mandatory": true,
        "payment_terms": -3,
        "payment_terms_label": "Due end of next month"
      }
    ]
  }
}
  1.  { 
  2.    "code": 0, 
  3.    "message": "success", 
  4.    "data": { 
  5.      "payment_terms": [ 
  6.        { 
  7.          "payment_terms_id": "123456000000000123", 
  8.          "payment_terms": 15, 
  9.          "is_default": false, 
  10.          "payment_terms_label": "Net 15" 
  11.        }, 
  12.        { 
  13.          "payment_terms_id": "123456000000000124", 
  14.          "payment_terms": 30, 
  15.          "is_default": false, 
  16.          "payment_terms_label": "Net 30" 
  17.        }, 
  18.        { 
  19.          "payment_terms_id": "123456000000000125", 
  20.          "payment_terms": 45, 
  21.          "is_default": false, 
  22.          "payment_terms_label": "Net 45" 
  23.        }, 
  24.        { 
  25.          "payment_terms_id": "123456000000000126", 
  26.          "payment_terms": 60, 
  27.          "is_default": false, 
  28.          "payment_terms_label": "Net 60" 
  29.        }, 
  30.        { 
  31.          "payment_terms_id": "", 
  32.          "is_mandatory": true, 
  33.          "payment_terms": -2, 
  34.          "payment_terms_label": "Due end of the month" 
  35.        }, 
  36.        { 
  37.          "payment_terms_id": "", 
  38.          "is_mandatory": true, 
  39.          "payment_terms": -3, 
  40.          "payment_terms_label": "Due end of next month" 
  41.        } 
  42.      ] 
  43.    } 
  44.  } 

Usage:
This is just a snippet of usage and obviously not the whole function to generate an invoice. Please refer to the Zoho Books API documentation for what fields are required to complete a request within your system.
copyraw
m_InvoiceDetails = Map();
m_InvoiceDetails.put("customer_id",m_BooksSO.get("customer_id"));
m_InvoiceDetails.put("payment_terms",-3);
// adding label because -3 often displays "Net 56" instead.
m_InvoiceDetails.put("payment_terms_label","Due end of next month");
//
// loop through line items and populate
for each m_SOLineItem in l_SalesOrderLineItems
{
    m_InvoiceLineItem = Map();
    m_InvoiceLineItem.put("item_id", m_SOLineItem.get("item_id"));
    m_InvoiceLineItem.put("rate", m_SOLineItem.get("rate"));
    m_InvoiceLineItem.put("quantity", m_SOLineItem.get("quantity"));
    l_InvoiceLineItems.add(m_NewLineItem);
}
m_InvoiceDetails.put("line_items",l_InvoiceLineItems);
//
// create or update
if(v_BooksInvoiceID != 0)
{
    r_InvoiceSO = zoho.books.updateRecord("invoices",v_BooksOrgID,v_BooksInvoiceID.toString(),m_InvoiceDetails,"abzohobooks");
}
else 
{
    r_InvoiceSO = zoho.books.createRecord("invoices",v_BooksOrgID,m_InvoiceDetails,"abzohobooks");
}
  1.  m_InvoiceDetails = Map()
  2.  m_InvoiceDetails.put("customer_id",m_BooksSO.get("customer_id"))
  3.  m_InvoiceDetails.put("payment_terms",-3)
  4.  // adding label because -3 often displays "Net 56" instead. 
  5.  m_InvoiceDetails.put("payment_terms_label","Due end of next month")
  6.  // 
  7.  // loop through line items and populate 
  8.  for each m_SOLineItem in l_SalesOrderLineItems 
  9.  { 
  10.      m_InvoiceLineItem = Map()
  11.      m_InvoiceLineItem.put("item_id", m_SOLineItem.get("item_id"))
  12.      m_InvoiceLineItem.put("rate", m_SOLineItem.get("rate"))
  13.      m_InvoiceLineItem.put("quantity", m_SOLineItem.get("quantity"))
  14.      l_InvoiceLineItems.add(m_NewLineItem)
  15.  } 
  16.  m_InvoiceDetails.put("line_items",l_InvoiceLineItems)
  17.  // 
  18.  // create or update 
  19.  if(v_BooksInvoiceID != 0) 
  20.  { 
  21.      r_InvoiceSO = zoho.books.updateRecord("invoices",v_BooksOrgID,v_BooksInvoiceID.toString(),m_InvoiceDetails,"abzohobooks")
  22.  } 
  23.  else 
  24.  { 
  25.      r_InvoiceSO = zoho.books.createRecord("invoices",v_BooksOrgID,m_InvoiceDetails,"abzohobooks")
  26.  } 

Note(s):
  • There are 2 other payment terms which is by setting payment terms to 0 which will result in a "Due on Receipt".
    copyraw
    m_InvoiceDetails.put("payment_terms",0);
    m_InvoiceDetails.put("payment_terms_label","Due on Receipt");
    1.  m_InvoiceDetails.put("payment_terms",0)
    2.  m_InvoiceDetails.put("payment_terms_label","Due on Receipt")

Source(s):
Category: Zoho Books :: Article: 381

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com