Zoho Invoice

Help Docs

Back to Settings Overview

Workflow Scenarios

Workflows can come in handy if you wish to get things done automatically in Zoho Invoice. Following are some of the scenarios where workflows come into play.

Scenarios for Email Alerts

Scenario 1:

Dillion Inc. is a garment export company. The VP of sales wants to receive email alerts when an employee raises a estimate for an amount greater than $10,000 for one of their top customers. This will help them offer their best services. In that case, a workflow can be designed to automatically trigger email alerts when the following conditions are met.

Execute When: Created
Rule Criteria: Total amount due is greater than $10,000.
Immediate Action: Email alert to the VP of the Sales/ Finance team.
Time Based Action: —


Scenario 2:

Joseph, the CTO of Bookworm.com, an online bookstore wants to implement a system wherein an alert message should be triggered to the packing section, upon raising an invoice for an order placed by the customer. The Email Alerts feature allows him to accomplish this by creating a workflow rule with the following parameters.

Execute When: Created or Edited
Rule Criteria: Contact Name is XYZ
Immediate Action: —
Time Based Action: Email alert to the packing section upon raising an invoice.


Scenarios for Field Updates

Scenario 1:

Andrew is the Head of Marketing of SolarSync, a solar panel manufacturing company. According to his newly issued directive, the sales person should be changed to “XYZ” as soon as the sales person “ABC” has landed the sale i.e when an invoice for a total amount greater than $10,000 has been created or edited. A workflow automates the process of re-assigning the task to another person by setting up the following parameters to execute the directive.

Execute When: Created or Edited
Rule Criteria: When Sales Person is “ABC” and Total Amount is greater than $10,000.
Immediate Action: Update Sales person field to “XYZ”
Time Based Action: —


Scenario 2:

Andy is the owner of Phoenix Rent-a-Car, a car rental company in Chicago. One of his regular customers has rented a car for a month. Andrew sends him an invoice for $1500 for a period of 30 days i.e $50/day i.e $1500/month. He has also offered his customer a discount of $500. However, he wishes to update the Customer Notes 10 days past the Estimate Date by offering him a few freebies as well. He can automate this task by setting up the following parameters.

Execute When: Created or Edited
Rule Criteria: When Total=1000 and Discount > 500.
Immediate Action: —
Time Based Action: Update the field Customer Notes 10 days after Estimate Date.


Scenarios for Webhooks

Scenario 1:

Greg is the Public Relations manager for a Home & Office Security company. A first time customer had asked for a quotation for setting up security systems for his office in Boston. Greg wants to make a good impression by promptly sending a ‘Thank You’ SMS as soon as he accepts the estimate. The webhooks feature in automation can do that by setting the following parameters and connecting to a SMS gateway.

Execute When: Created or Edited
Rule Criteria: When Contact Name is “XYZ” and Contact Type is “Customer”.
Immediate Action: SMS alert using a webhook with SMS gateway.
Time Based Action: —


Scenario 2:

Frank is the financial controller of a Stock Brokerage firm. Most of the company’s revenue is credited into the company’s official Stripe account. He wants to be notified of any high value deposits or withdrawals towards invoices or expenses from that account via Email or SMS, on a weekly basis. He can achieve that by setting up a webhook using the following parameters.

Execute When: Created or Edited
Rule Criteria: When Total Amount>=$10,000
Immediate Action: —
Time Based Action: Trigger Email Alert 7 days after Rule Trigger Date


Scenarios for Custom Functions

Scenario 1:

Applying a 10% discount if your invoice total exceeds $2500

Sarah runs a supermarket and she wishes to provide discounts to celebrate her store’s 10th Anniversary. She decides to give a 10% discount for anybody who makes a purchase for $2500 or more. It would be a painful task to include discount everytime she creates an invoice.

With the help of custom functions, she can write a small piece of code to execute this action.

Sarah can set a condition where if the total of the invoice exceeds $2500, the function will be executed and a 10% discount will be applied.

Now, let’s look at how the custom function would look for this scenario.

Custom function name: Discount

Description: Apply a 10% discount when the invoice total exceeds $2500

Module: Invoice

Script:

//create a variable and get invoice total
total = invoice.get("total").toDecimal(); 
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
//set a condition: when invoice amount is >= 2500
if ( total >= 2500.00 ) 
{
	adjustment = invoice.get("adjustment").toDecimal();
	adjustment = adjustment - total * 0.10;
	jsonMap = Map();
	jsonMap.put("adjustment", adjustment);
	jsonMap.put("reason", "discount");
	// To update the current record
	result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
	info result.toMap().get("message") ;
}

She then creates a workflow rule with the following parameters.

Workflow Rule Name: Anniversary discount

Module: Invoice

Workflow type: Event based

When an invoice is: created

Triggers: When total >= 2500

Actions: Custom functions - Discount

Now, when the invoice total is greater than or equal to $2500, the workflow will be triggered and the custom function will be executed.


Scenario 2:

Adding a 5% latefee when an invoice becomes overdue

Dennis runs a self-storage facility in Manhattan where customers can store anything in a box, small enough to safely store documents and, big enough to store an expensive car. He charges his clients the option to pay on a daily, weekly, monthly or even a yearly basis. He offers them a 10-day grace period from the invoice date to make the payment after which, he charges an additional 5% of the invoiced amount as late fees.

Using Zoho Invoice, he writes a small code using Custom Functions to automatically calculate the late fees and add it as adjustments in the invoices when the invoices become Overdue.

Now, let’s look at how the custom function would look for this scenario.

Custom function name: Latefee

Description: Apply a 5% late fees on the invoice amount

Module: Invoice

Script:

//create a variable to get invoice total and add a 5% discount
latefee = invoice.get("total").toDecimal() * 0.05;
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
//display the value stored in the latefee variable
info latefee;
//add late fee and adjustment and store the total amount in the variable 'adjustment'  
adjustment = invoice.get("adjustment").toDecimal() + latefee;
jsonMap = Map();
jsonMap.put("adjustment",adjustment);
jsonMap.put("reason","Late fee");
// To update the current record
result = zoho.invoice.update("invoices",orgID,invoiceID,jsonMap);
info result.toMap().get("message"); 

He then creates a workflow rule with the following parameters.

Workflow Rule Name: Late fee

Module: Invoice

Workflow type: Date based

Date of Execution: 0 day(s) after Due Date

Execution time: Enter the time of execution

Execution cycle: Once

Triggers: When > Status > isn’t > Paid > AND > Status > isn’t > Partially Paid

Actions: Custom functions - Latefee

Now, when the invoice due date exceeds the set date (in the workflow rule), the workflow will be triggered and the custom function will be executed.


Scenario 3:

Provide discount if payment for the invoice is made before the due date

Donna runs a design firm that creates promotional materials for websites on a monthly basis. This involves designing brochures, banner ads, and other promotional materials. Donna sends invoices at the end of each month and often receives payment only after the credit period, which is 30 days. To receive funds immediately, she decides to offer a discount if the invoice amount was paid before the invoice due date.

In order to implement this, she adds a discount of 5% to her invoices and in the customer notes section she mentions that the discount would be applicable only if the payment is made before the due date.

To make this work, Donna writes the following custom function.

//if payment for the invoice is received after the invoice due date then discount won't be applied 
orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
jsonMap = Map();
jsonMap.put("discount", 0);
jsonMap.put("reason", "reached due date.");
result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
info result.toMap().get("message") ;

Once done, she creates a workflow to execute ths custom function. The parameters of the workflow rule is mentioned below:

Workflow rule name: Discount for early payment

Module: Invoice

Workflow type: Date based

Date of Execution: 0 day(s) after Due Date

Execution time: Enter the time of execution

Execution cycle: Once

Trigger: When > Status > isn’t > Paid

Actions

Type: Custom function and Name: Name of your custom function

So, if an invoice reaches the due date, the workflow will be triggered and the custom function will add 0% discount instead of the actual 5%


Scenario 4:

Automatically set due date for an invoice as 30 days before the event date (that is entered via a custom field)

Tom is a creative wedding photographer. His client book for his services 2-3 months prior to the wedding date (event date.) And, Tom would confirm the date only if the client pays the full amount 30 days before the wedding date. In order to streamline this process, Jake, one of the members of Tom’s studio writes a small custom function.

To start with, Jake creates a custom field named “Wedding Date” with the date datatype and writes the following custom function


orgID = organization.get("organization_id").toString();
invoiceID = invoice.get("invoice_id").toLong();
customFieldList = invoice.get("custom_fields").toList();
cfDate = null;
for each  customField in customFieldList
{
	customFieldMap = customField.toMap();
	if(customFieldMap.get("label") == "Date")
	{
		cfDate = customFieldMap.get("value");
		break;
	}
}
duedate = cfDate.toTime().subMonth(1);
info duedate;
duedate = duedate.year() + "-" + text(duedate.month(),"00") + "-" + text(duedate.day(),"00");
jsonMap = Map();
jsonMap.put("due_date", duedate);
jsonMap.put("reason", "Auto due date.");
result = zoho.invoice.update("invoices", orgID, invoiceID, jsonMap);
info result.toMap().get("message");

After creating the custom function, Jake creates a workflow rule to trigger it. The parameters of the workflow rule are as follows:

Workflow name: Payment 30 days before the wedding

Module: Invoice

Workflow type: Event based

When invoice is: Created

Actions

Type: Custom function and Name: Name of your custom function

While creating an invoice, if Tom mentions the wedding date in the custom field, the workflow will be triggered and the custom function will set the due date of the invoice to 30 days before the wedding date.


​Scenario 5:

Automatically cancel an estimate if its not accepted within 10 days from the date of creation.

Katherine owns a company that supplies automotive spare parts to several automobile service stations. Several customers ask her for a quote, but a portion of them fail to communicate their decision by neither accepting nor rejecting the quote. To avoid this, Katherine decides to decline the estimate if she doesn’t hear back from the client within 10 days from the receipt of the estimate. To implement this, she writes a custom function.

//get estimate and organization ID
estimateid = estimate.get("estimate_id");
orgid = organization.get("organization_id");
//fetch auth token and organization ID
details = Map();
details.put("authtoken","AUTHTOKEN");
details.put("organization_id",orgid);
//convert the status of the estimate to 'declined'
result = postUrl("https://invoice.zoho.com/api/v3/estimates/" + estimateid + "/status/declined",details);
info result.toMap().get("message") ;

Now, to trigger the execution of this custom function, she creates a workflow rule with the following parameters.

Workflow Name: Decline estimate after 10 days of receipt

Module: Estimate

Workflow type: Date Based

Date of Execution: 10 day(s) after Created Time

Execution time: Enter the time of execution

Execution cycle: Once

Criteria: When > Estimate Status > is > Sent > AND > Estimate Status > is > not approved

Actions

Type: Custom function and Name: Name of your custom function

Now, when the estimate exceeds 10 days from its created time, the workflow will be triggered and the custom function will be executed to change the status of the estimate to declined.


Scenario 6:

Extend due date by 7 days if the customer pays 50% of the invoice amount on or before the initial due date

Diane owns a store that supplies printing paper and office stationery for offices in her area. She wants to extend the due date of the invoice by a week if customers pay 50% of the invoice amount on or before the initial due date.

In order to do that, she writes the following custom function:

//Getting invoice total, balance after the partial payment, and due date
inv_total = invoice.get("total").toDecimal();
inv_balance = invoice.get("balance").toDecimal();
inv_duedate = invoice.get("due_date").toDate();
orgid = organization.get("organization_id").toString();
invid = invoice.get("invoice_id").toLong();
//Condition to check if the amount paid is 50% of the invoice amount
if(inv_balance == inv_total / 2)
{
	inv_duedate = inv_duedate.addDay(7);
	inv_duedate = inv_duedate.year() + "-" + text(inv_duedate.month(),"00") + "-" + text(inv_duedate.day(),"00");
	//Update the due date by 7 days
	jsonMap = Map();
	jsonMap.put("due_date", inv_duedate);
	jsonMap.put("reason", "Increased due date");
	result = zoho.invoice.update("invoices", orgid, invid, jsonMap);
	info result.toMap().get("message") ;
}

Once done, Diane creates a workflow rule to execute the custom function.

Workflow name: Extend due date

Module: Invoice

Workflow type: Event based

When invoice is: Edited

Execute the workflow When any field is updated

Just once or Everytime? Just once

Triggers When > Status > is > Partially paid

Type: Custom function and Name: Name of your custom function

Now, when a customer pays 50% of the invoice amount by the initial due date, a grace period of 7 days will be given for him to pay the balance amount.


Was this document helpful?
Thank you for your feedback!
TOP