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 http://ascentbusiness.co.uk/zoho-support-2.  For larger projects, check our bespoke pricing structure and receive dedicated support from our hands-on project consultants and developers at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices.

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 http://ascentbusiness.co.uk.

Zoho CRM & Zoho Books: Get Books Currency and Tax IDs

What?
A quick note for when I want to quickly generate maps of a currency or a tax from a client's Zoho Books.

Why?
The use-case here is that we are creating a Sales Order in Zoho Books from Zoho CRM and want to map the correct currency and tax by their ID numbers.

How?
Using the REST API and InvokeURL in Zoho Deluge to look at Zoho Books. This uses up an extra 2 calls so you could run them once, store them as a map on your function if you don't want to use up these 2 every time your sales team push a CRM Sales Order to Zoho Books. Or leave as 2 calls at the beginning of your function in case they add a currency or tax rate and want to push a sales order immediately over.

Get Currencies
Remember to replace the v_BooksOrgID with your client's Organization ID for Zoho Books and check the URL for whether it will be https://books.zoho.eu or https://books.zoho.com. You will also need your own CRM to Books connection name (joel_books) with scope to read settings:
copyraw
// our made up books org id but enter your own
v_BooksOrgID=20210924095;
//
// get currencies
m_Currencies = Map();
r_Currencies = invokeurl
[
	url :"https://books.zoho.eu/api/v3/settings/currencies?organization_id=" + v_BooksOrgID
	type :GET
	connection:"joel_books"
];
for each  r_Currency in r_Currencies.get("currencies")
{
	m_Currencies.put(r_Currency.get("currency_code"),r_Currency.get("currency_id"));
}
info m_Currencies;
//
// get Books ID for a currency from an CRM account record
r_AccountDetails = zoho.crm.getRecordByID("Accounts", 9012345678901234567);
v_BooksCurrencyID = m_Currencies.get(ifnull(r_AccountDetails.get("Currency"),"GBP"));
info v_BooksCurrencyID;
  1.  // our made up books org id but enter your own 
  2.  v_BooksOrgID=20210924095
  3.  // 
  4.  // get currencies 
  5.  m_Currencies = Map()
  6.  r_Currencies = invokeUrl 
  7.  [ 
  8.      url :"https://books.zoho.eu/api/v3/settings/currencies?organization_id=" + v_BooksOrgID 
  9.      type :GET 
  10.      connection:"joel_books" 
  11.  ]
  12.  for each  r_Currency in r_Currencies.get("currencies") 
  13.  { 
  14.      m_Currencies.put(r_Currency.get("currency_code"),r_Currency.get("currency_id"))
  15.  } 
  16.  info m_Currencies; 
  17.  // 
  18.  // get Books ID for a currency from an CRM account record 
  19.  r_AccountDetails = zoho.crm.getRecordByID("Accounts", 9012345678901234567)
  20.  v_BooksCurrencyID = m_Currencies.get(ifnull(r_AccountDetails.get("Currency"),"GBP"))
  21.  info v_BooksCurrencyID; 
Yields something like:
copyraw
{
  "EUR": "123456789012345678",
  "GBP": "234567890123456789",
  "USD": "345678901234567890",
}

234567890123456789
  1.  { 
  2.    "EUR": "123456789012345678", 
  3.    "GBP": "234567890123456789", 
  4.    "USD": "345678901234567890", 
  5.  } 
  6.   
  7.  234567890123456789 


Get Taxes
Same as above but to get the tax rates and their IDs:
copyraw
// our made up books org id but enter your own
v_BooksOrgID=20210924095;
//
// get taxes
m_Taxes = Map();
r_Taxes = invokeUrl
[
	url: "https://books.zoho.eu/api/v3/settings/taxes?organization_id="+v_BooksOrgID
	type: GET
	connection: "joel_books"
];
for each r_Tax in r_Taxes.get("taxes")
{
	m_Taxes.put(r_Tax.get("tax_percentage").toString(), r_Tax.get("tax_id"));
}
info m_Taxes;
//
// set Tax ID for a sales order line item
l_LineItems = List();
r_SoDetails = zoho.crm.getRecordById("Sales_Orders",0123456789012345678);
for each  r_LineItem in r_SoDetails.get("Product_Details")
{
	m_LineItem = Map();
	if(r_LineItem.get("Tax") > 0)
	{
		for each r_LineTax in r_LineItem.get("line_tax")
		{
			if(r_LineTax.get("percentage") > 0)
			{
				v_BooksTaxID = ifnull(m_Taxes.get(r_LineTax.get("percentage")),678901234567890123);
				m_LineItem.put("tax_id",v_BooksTaxID);
				m_LineItem.put("tax_percentage",r_LineTax.get("percentage"));
			}
		}
	}
	l_LineItems.add(m_LineItem);
}
info v_BooksTaxID;
  1.  // our made up books org id but enter your own 
  2.  v_BooksOrgID=20210924095
  3.  // 
  4.  // get taxes 
  5.  m_Taxes = Map()
  6.  r_Taxes = invokeUrl 
  7.  [ 
  8.      url: "https://books.zoho.eu/api/v3/settings/taxes?organization_id="+v_BooksOrgID 
  9.      type: GET 
  10.      connection: "joel_books" 
  11.  ]
  12.  for each r_Tax in r_Taxes.get("taxes") 
  13.  { 
  14.      m_Taxes.put(r_Tax.get("tax_percentage").toString(), r_Tax.get("tax_id"))
  15.  } 
  16.  info m_Taxes; 
  17.  // 
  18.  // set Tax ID for a sales order line item 
  19.  l_LineItems = List()
  20.  r_SoDetails = zoho.crm.getRecordById("Sales_Orders",0123456789012345678)
  21.  for each  r_LineItem in r_SoDetails.get("Product_Details") 
  22.  { 
  23.      m_LineItem = Map()
  24.      if(r_LineItem.get("Tax") > 0) 
  25.      { 
  26.          for each r_LineTax in r_LineItem.get("line_tax") 
  27.          { 
  28.              if(r_LineTax.get("percentage") > 0) 
  29.              { 
  30.                  v_BooksTaxID = ifnull(m_Taxes.get(r_LineTax.get("percentage")),678901234567890123)
  31.                  m_LineItem.put("tax_id",v_BooksTaxID)
  32.                  m_LineItem.put("tax_percentage",r_LineTax.get("percentage"))
  33.              } 
  34.          } 
  35.      } 
  36.      l_LineItems.add(m_LineItem)
  37.  } 
  38.  info v_BooksTaxID; 
Yields something like:
copyraw
{
  "0": "456789012345678901",
  "5": "567890123456789012",
  "20": "678901234567890123",
}

678901234567890123
  1.  { 
  2.    "0": "456789012345678901", 
  3.    "5": "567890123456789012", 
  4.    "20": "678901234567890123", 
  5.  } 
  6.   
  7.  678901234567890123 


Category: Zoho :: Article: 773

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
© 2023 Joel Lipman .com. All Rights Reserved.