Tip #1 Automating online sales order to invoice conversions in Zoho Inventory
Hope the day is treating you well.
We've been getting more than a few requests from online sellers who use Zoho Inventory to help them automate invoice generation for all online orders that drop into Zoho Inventory automatically from a sales channel or a shopping cart that they have integrated. Are you an online seller like them? Then we've got some exciting news for you. You can do it with the help of a few simple things that we'll see here today.
So how do we go about this?
If you have integrated online sales channels like Amazon, Etsy and Ebay or a shopping cart like Shopify to Zoho Inventory, then you will be aware of sales orders being automatically generated inside of Zoho Inventory whenever your online customers buy something from you through these integrated channels. Since invoices are generated and automatically sent to your clients by the channel, you have little need of the invoices inside of Zoho Inventory apart from accounting purposes. Depending on the amount of online orders you get per day, it can get tricky to convert these orders into invoices manually. So we are going to automate this part for you with the help of a simple custom function.
Wondering what custom functions are? They are one of the automation tools at your disposal inside of Zoho Inventory and can be accessed inside of Settings. To know more about custom functions in general, please refer to our help document.
Now let's see how we can write one to automatically convert all online sales orders into invoices as soon as they are generated within Zoho Inventory.
Log in to your Zoho account and click on this link to generate an Auth Token which is required to make this work.
1) Open your Zoho Inventory organization.
2) Navigate to Settings using the gear icon from the top-right corner.
3) Select Automation from the sidebar. Click on the +New Workflow Rule button that is found at the top-right corner.
4) Out of the four tabs within Automation, select Custom Functions.
5) Now let's add a name for this workflow rule. (Note: Name cannot contain spaces)
6) The module to be chosen is Sales Orders.
7) Add a description if you need one.
8) Now, the workflow type is going to be Event Based.
9) And for the trigger, choose the option - "When a Sales Order is" "Created".
10) In the deluge pane, copy and paste the following code snippet:
salesorderID = salesorder.get("salesorder_id");
salesorderdate = salesorder.get("date").toDate();
organizationID = organization.get("organization_id");
authtoken = "Copy and Paste your auth token in place of this text";
sal = invokeurl
url :"https://inventory.zoho.com/api/v1/salesorders/" + salesorderID + "?authtoken=" + authtoken + "&organization_id=" + organizationID
temp = sal.get("salesorder");
// info temp;
new = temp.get("sales_channel");
bson = Map();
customerID = salesorder.get("customer_id").toString();
salesoderdate = salesorder.get("date").toDate();
//invoice_number = salesorder.get("salesorder_number").replaceFirst("SO","INV");
lineItems = salesorder.get("line_items").toList();
newLineItems = List();
for each lineItem in lineItems
lineItemMap = Map();
solineitemID = lineItem.get("line_item_id");
id = lineItem.get("item_id");
des = lineItem.get("description");
wh = lineItem.get("warehouse_id");
quantity = lineItem.get("quantity");
r = lineItem.get("rate");
d = lineItem.get("discount");
tidd = lineItem.get("tax_id");
tex = lineItem.get("tax_exemption_code");
response = zoho.inventory.createRecord("Invoices",organizationID,bson);
inv = response.get("invoice");
//marking as sent//
invoiceID = inv.get("invoice_id");
invoicedate = inv.get("date").toDate();
respond = invokeurl
url :"https://inventory.zoho.com/api/v1/invoices/" + invoiceID + "/status/sent?authtoken=" + authtoken + "&organization_id=" + organizationID
info "Order is not from a Marketplace";
11) Before you save, you are required to copy and paste your auth token inside the quotes in the 4th line that says: authtoken = "Copy and Paste your auth token in place of this text";
Note: The auth token is a critical piece of information that helps the system identify you, so keep yours safe and confidential. Do not share it with anyone, not even with folks from Zoho.
12) Now, hit Save to finish.
Henceforth, all your online sales orders that are auto-generated from Amazon, Etsy, Ebay or Shopify will be automatically converted to invoices. And the status of these invoices inside of Zoho Inventory will be Sent. If you wish to auto-generate invoices of Paid status, then it can be made possible with a few changes. You can either experiment that part by yourself or contact us at email@example.com
Note: If you need this automation only for one channel, say for Shopify alone and not other channels, then you need to make a few changes to line 13 that originally says - if(!new.equalsIgnoreCase("direct_sales")) to if(new.equalsIgnoreCase("shopify"))
Hope this helps you in your online selling endeavors. Oh and by the way, have you ever dabbled with the custom functions module by yourself? You can share your discoveries, questions and suggestions with us anytime. We look forward to hearing from you. (Email us: firstname.lastname@example.org)
Until next time.
Your everyday end user,
Ajay Aadhithya Chandrasekaran
Zoho SalesIQ Resources
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Desk Resources
Zoho Projects Resources
Zoho Sprints Resources
Zoho Creator Resources
Zoho WorkDrive Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.