I would like to write a code for calculating sales commissions after creation of each invoice.
I added a custom field for commission percent to CRM Contacts module and synced this module to Zoho Invoice.
My code is as follows but it is not working. Any help is appreciated.
customerID = invoice.get("customer_id");
subtotal= invoice.get("sub_total");
sales_commission= invoice.get("cf_sales_commission");
contactMap = List();
contactMap = zoho.invoice.getRecordById("Contacts",717534537,customerID);
contact = contactMap.get("contact");
commission_percent = contact.get("cf_commission_percent");
sales_commission = floor(subtotal
* commission_percent/100);
updateparams = zoho.invoice.update("invoice", 717534537, sales_commission);
info updateparams;