Create Zoho CRM Quotes Using Zoho CRM API but Tax and Aggregate Field Not working.
Hello Team,
I have wrote a deluge script to create the record in Quotes and update the same quotes, all things are working fine but line Item Tax value is coming more then 2 value after point, like 2.0002, 2.0036
I am also sharing the Deluge code, Please check and suggest what is missing in this.
Deluge Code:-
- resvp = zoho.crm.getRecordById("Quotes",qid);
- Tax_Total = 0.00;
- total = 0.00;
- tem_total = 0.00;
- if(resvp.get("Split_Quotes") == false)
- {
- CotntactID = ifnull(resvp.get("Contact_Name"),null);
- if(CotntactID != null)
- {
- Contact_Data = zoho.crm.getRecordById("Contacts",CotntactID.get("id"));
- if(Contact_Data.get("Type_of_work") == "Retrofit")
- {
- DealID = ifnull(resvp.get("Deal_Name"),null);
- Subject1 = ifnull(resvp.get("Subject"),null) + " -1";
- Subject2 = ifnull(resvp.get("Subject"),null) + " -2";
- Quotage_Stage = ifnull(resvp.get("Quote_Stage"),"");
- Date1 = ifnull(resvp.get("Date"),"");
- Product_Details = resvp.get("Product_Details");
- ProductList = List();
- for each rec in Product_Details
- {
- Productid = Map();
- Productid.put("id",rec.get("product").getJSON("id"));
- linetaxmap = List();
- if(rec.get("line_tax").size() > 0)
- {
- linetaxmap1 = Map();
- linetaxmap1.put("percentage",rec.get("line_tax").getJSON("percentage"));
- linetaxmap1.put("name",rec.get("line_tax").getJSON("name"));
- linetaxmap1.put("value",((rec.get("total_after_discount") * rec.get("line_tax").getJSON("percentage")) / 100).round(2) / 2);
- linetaxmap1.put("id",rec.get("line_tax").getJSON("id"));
- linetaxmap.add(linetaxmap1);
- }
- if(rec.get("Tax") != "")
- {
- Tax_Total = Tax_Total + (rec.get("Tax") / 2).round(2);
- Tax_Value = (rec.get("Tax") / 2).round(2);
- }
- else
- {
- Tax_Total = Tax_Total + 0.00;
- Tax_Value = 0.00;
- }
- total1 = rec.get("quantity") * (rec.getJSON("list_price") / 2).round(2);
- mp = Map();
- mp.put("product",Productid);
- mp.put("Discount",(rec.get("Discount") / 2).round(2));
- mp.put("quantity",rec.get("quantity"));
- mp.put("list_price",(rec.get("list_price") / 2).round(2));
- mp.put("line_tax",linetaxmap);
- ProductList.add(mp);
- }
- mp1 = Map();
- mp1.put("Subject",Subject2);
- mp1.put("Product_Details",ProductList);
- mp1.put("Contact_Name",CotntactID);
- mp1.put("Deal_Name",DealID);
- mp1.put("Quote_Stage",Quotage_Stage);
- mp1.put("Date",Date1);
- resvp1 = zoho.crm.createRecord("Quotes",mp1,{"trigger":{"workflow"}});
- if(resvp1.size() > 0)
- {
- New_Record_Link = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + resvp1.get("id");
- Openlink = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + resvp1.get("id") + "/edit?layoutId=5388660000000091017";
- openUrl(Openlink,"new window");
- updatemap = Map();
- updatemap.put("Subject",Subject1);
- updatemap.put("Product_Details",ProductList);
- updatemap.put("Split_Quotes_Link",New_Record_Link);
- updatemap.put("Split_Quotes",true);
- resvp2 = zoho.crm.updateRecord("Quotes",qid,updatemap);
- resvp2 = "";
- Openlink1 = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + qid + "/edit?layoutId=5388660000000091017";
- openUrl(Openlink1,"same window");
- }
- }
- }
- else
- {
- return "This Quotes Does Not Have a Contact";
- }
- }
- return "";
Please suggest what is missing in this.
Thanks & Regards
Piyush Goyal