Tracking refunds and adjusting the sales executive's revenue in Zoho CRM
Business scenario:
Having a clear refund policy goes a long way in gaining customer trust. Depending upon the line of business, the refund window might vary. This is even more important in the case of online purchases where customers get to see and feel the product only after making the purchase.
The Deals module in CRM helps track the revenue associated with the sales executives. By taking a report of all the 'won' businesses pertaining to a month, you'll be able to calculate the revenue associated with the sales executives concerned. Recently one of our users asked if there is any working solution to track refunds. Typically, the refund period is 30 days and the refunds have to be tracked without affecting the revenue numbers from the preceding month. Hence updating the closed Deal stage to a "Refunded" stage won't work.
A simple solution to this problem is to clone the won deal that needs to be refunded and make the following updates in the cloned deal:
- Update the deal value in negative to account for the refund amount.
- Update the deal closing date to current date.
- Update the status of the cloned deal to "Refunded".
This leaves the revenue numbers of the preceding months and the sales forecast for the current month intact while accounting for the refunds too. Expecting your sales executives do all these steps manually is a tall order. Fret not, the Function I'm sharing this week helps you do all these steps at the click of a button.
Pre-requisites
- Create a Deal Status named "Refunded".
Getting started with the function:
- Go to Setup > Customization > Modules and Fields > Select the required module > Links and Buttons > + New Button.
- Provide a name for the button. Add a description(optional).
- Choose View Page from the drop-down list.
- Select Writing Function from the subsequent drop-down.
- Provide a name for the function. Add a description(optional).
- Copy the code given below.
- Click Edit Arguments.
- Enter the name as dealId and select the value as Deal Id.
- Save the changes.
- Select the profiles who can see this button.
- Click Save.
The Code:
dealDetails = zoho.crm.getRecordById("Deals", input.dealId.toLong());
mp=map();
mp.put("Deal_Name",ifnull(dealDetails.get("Deal_Name"),""));
mp.put("Owner",ifnull(dealDetails.get("Owner"),"").get("id"));
mp.put("Account_Name",ifnull(dealDetails.get("Account_Name"),"").get("id"));
mp.put("Contact_Name",ifnull(dealDetails.get("Contact_Name"),"").get("id"));
mp.put("Amount","-"+ifnull(dealDetails.get("Amount"),""));
mp.put("Stage","Refunded");
mp.put("Closing_Date",today);
create=zoho.crm.create("Deals", mp);
info mp;
info create;
return "success";
Before refund

After refund

Note:
- The above code works only for API V2.0 and not the previous version.
Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!