For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.

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://books.zoho.com/api/v3/settings/paymentterms?organization_id=" + v_BooksOrgID
		type :GET
		connection:"abzohobooks"
	];
	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:"abzohobooks" 
  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 :: Article: 852

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

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin bc1qf6elrdxc968h0k673l2djc9wrpazhqtxw8qqp4

Ethereum:
Donate to Joel Lipman with Ethereum 0xb038962F3809b425D661EF5D22294Cf45E02FebF
© 2024 Joel Lipman .com. All Rights Reserved.