Create Zoho CRM Quotes Using Zoho CRM API but Tax and Aggregate Field Not working.

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:-
  1. resvp = zoho.crm.getRecordById("Quotes",qid);
  2. Tax_Total = 0.00;
  3. total = 0.00;
  4. tem_total = 0.00;
  5. if(resvp.get("Split_Quotes") == false)
  6. {
  7. CotntactID = ifnull(resvp.get("Contact_Name"),null);
  8. if(CotntactID != null)
  9. {
  10. Contact_Data = zoho.crm.getRecordById("Contacts",CotntactID.get("id"));
  11. if(Contact_Data.get("Type_of_work") == "Retrofit")
  12. {
  13. DealID = ifnull(resvp.get("Deal_Name"),null);
  14. Subject1 = ifnull(resvp.get("Subject"),null) + " -1";
  15. Subject2 = ifnull(resvp.get("Subject"),null) + " -2";
  16. Quotage_Stage = ifnull(resvp.get("Quote_Stage"),"");
  17. Date1 = ifnull(resvp.get("Date"),"");
  18. Product_Details = resvp.get("Product_Details");
  19. ProductList = List();
  20. for each  rec in Product_Details
  21. {
  22. Productid = Map();
  23. Productid.put("id",rec.get("product").getJSON("id"));
  24. linetaxmap = List();
  25. if(rec.get("line_tax").size() > 0)
  26. {
  27. linetaxmap1 = Map();
  28. linetaxmap1.put("percentage",rec.get("line_tax").getJSON("percentage"));
  29. linetaxmap1.put("name",rec.get("line_tax").getJSON("name"));
  30. linetaxmap1.put("value",((rec.get("total_after_discount") * rec.get("line_tax").getJSON("percentage")) / 100).round(2) / 2);
  31. linetaxmap1.put("id",rec.get("line_tax").getJSON("id"));
  32. linetaxmap.add(linetaxmap1);
  33. }
  34. if(rec.get("Tax") != "")
  35. {
  36. Tax_Total = Tax_Total + (rec.get("Tax") / 2).round(2);
  37. Tax_Value = (rec.get("Tax") / 2).round(2);
  38. }
  39. else
  40. {
  41. Tax_Total = Tax_Total + 0.00;
  42. Tax_Value = 0.00;
  43. }
  44. total1 = rec.get("quantity") * (rec.getJSON("list_price") / 2).round(2);
  45. mp = Map();
  46. mp.put("product",Productid);
  47. mp.put("Discount",(rec.get("Discount") / 2).round(2));
  48. mp.put("quantity",rec.get("quantity"));
  49. mp.put("list_price",(rec.get("list_price") / 2).round(2));
  50. mp.put("line_tax",linetaxmap);
  51. ProductList.add(mp);
  52. }
  53. mp1 = Map();
  54. mp1.put("Subject",Subject2);
  55. mp1.put("Product_Details",ProductList);
  56. mp1.put("Contact_Name",CotntactID);
  57. mp1.put("Deal_Name",DealID);
  58. mp1.put("Quote_Stage",Quotage_Stage);
  59. mp1.put("Date",Date1);
  60. resvp1 = zoho.crm.createRecord("Quotes",mp1,{"trigger":{"workflow"}});
  61. if(resvp1.size() > 0)
  62. {
  63. New_Record_Link = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + resvp1.get("id");
  64. Openlink = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + resvp1.get("id") + "/edit?layoutId=5388660000000091017";
  65. openUrl(Openlink,"new window");
  66. updatemap = Map();
  67. updatemap.put("Subject",Subject1);
  68. updatemap.put("Product_Details",ProductList);
  69. updatemap.put("Split_Quotes_Link",New_Record_Link);
  70. updatemap.put("Split_Quotes",true);
  71. resvp2 = zoho.crm.updateRecord("Quotes",qid,updatemap);
  72. resvp2 = "";
  73. Openlink1 = "https://crm.zoho.com/crm/org783690034/tab/Quotes/" + qid + "/edit?layoutId=5388660000000091017";
  74. openUrl(Openlink1,"same window");
  75. }
  76. }
  77. }
  78. else
  79. {
  80. return "This Quotes Does Not Have a Contact";
  81. }
  82. }
  83. return "";
Please suggest what is missing in this.


Thanks & Regards
Piyush Goyal