For Zoho Services only:


I'm actually part of a bigger team at Ascent Business Solutions where we have support technicians and project consultants. Support is for smaller technical fixes but this can include developments, reports or integrations; depending on the size of the task. Projects are for more time-consuming developments such as revamps of the Zoho Suite of apps or on-site training. The advantage of a team is that if I am out-of-office for a day or so, there is always someone at Ascent Business Solutions who can deal with any queries/issues you may have.

Our support rates can be found and purchased at http://ascentbusiness.co.uk/zoho-support-2. A support bundle doesn't have an expiry date. So whether we can do what you want within the bundle and a year later need further support, if there are minutes left on the bundle then there is no additional charge.

Our project rates for bigger developments can be found at http://ascentbusiness.co.uk/crm-solutions/zoho-crm-packages-prices and will involve a dedicated project consultant along with developers who will hold your hand through the development process.

If you want help building a solution for one of the Zoho Apps in the Zoho Suite, contact us on 0121 293 8140 (UK) or by email at info@ascentbusiness.co.uk. You can also visit our website at http://ascentbusiness.co.uk.

I regularly build and specialize in 2-way API integrations for Xero, Shopify and eBay.

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: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used 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 - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.