Function #13: Transaction level profitability

Function #13: Transaction level profitability

In Zoho Books, the Profit & Loss report provides valuable insights into the overall profitability of your business, indicating whether you have made a profit or incurred a loss. However, there may be occasions when you wish to assess whether a specific sale you made has been profitable. For such cases, you can utilize today's custom function which will automatically calculate profitability at the sales order level.

Prerequisites:
1. You need to create a Sales Order level custom field with the name "Total Margin" and data type as "Decimal". 



2. Create a Connection named "zbooks" to successfully execute the function. You can watch the GIF attached below to know how to create the connection. 


Note:
The cost price to calculate the margin will not be fetched and updated based on FIFO. The margin will be calculated based on the sales price entered in the transaction and the cost price mentioned at the item level. Also, the margin will be updated only after the sales order has been created.

Custom Function:
Navigate to Settings -> Automation -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link.
 
Workflow Rule: 
Go to Settings -> Automation -> Workflow Rules -> +New Workflow Rule and set up the workflow rule as shown below:-



In the final step of this workflow rule, associate the custom function you created and then hit Save. Here's a GIF of how the function will work.



This function helps you analyze the financial performance of each sale, providing you with a clearer understanding of whether a particular transaction has been profitable or not. We believe that this function will be highly advantageous for your business. If you require any assistance with setting up this custom function, please do not hesitate to reach out to us at support[at]zohobooks[dot]com. Our team is always there for assistance!

Regards,
Shireen Farhana S
Zoho Books.


      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

                            Writer is a powerful online word processor, designed for collaborative work.

                              Zoho CRM コンテンツ




                                ご検討中の方

                                  • Recent Topics

                                  • No connection to the server

                                    Hello! I can't add a new email address to my mailbox because your server is rejecting me. Please help. I took and added a screenshot of this problem Marek Olbrys
                                  • URGENT: Business Email Disruption – SMTP Authentication Failed

                                    Dear Zoho Support, I am writing to escalate a critical issue with my business email account: 📧 marek@olbrys.de My domain olbrys.de is fully verified in Zoho (MX, SPF, DKIM, DMARC all valid – green status). I am using the correct configuration: smtp.zoho.eu
                                  • Emails missing from desktop but visible on phone

                                    Subject says it all. Windows 11 laptop. Apple phone. all systems up to date.
                                  • Website Hosting

                                    Hello, I want to host my domain on Hostinger, and I want my emails to run through Zoho Mail. Please provide me with the SPF record, MX record (Type: TXT), and A record, so that I don’t face any issues with my emails. My website is on Hostinger hosting,
                                  • Can not search zoho mail after update V.1.7.0

                                    i can not search mail on to and cc box from attached picture and then search contacts box can't click or use anything. include replay mail too.
                                  • Urgent Security Feature Request – Add MFA to Zoho Projects Client Portal Hello Zoho Projects Team,

                                    Hello Zoho Projects Team, We hope you are doing well. We would like to submit an urgent security enhancement request regarding the Zoho Projects Client Portal. At this time, as far as we are aware, there is no Multi-Factor Authentication (MFA) available
                                  • How to retreive the "To be received" value of an Item displayed in Zoho inventory.

                                    Hi everyone, We have our own Deluge code to generate a PO according to taget quantity and box quantity, pretty usefull and powerful! However, we want to reduce our quantity to order according to "To be received" variable. Seems like this might not even
                                  • Add Support for Authenticator App MFA in Zoho Desk Help Center

                                    Hello Zoho Desk Team, We hope you are doing well. We would like to request an enhancement related to security for the Zoho Desk Help Center (customer portal). Currently, the Help Center supports MFA for portal users via SAML, JWT, SMS authentication,
                                  • Payment on a past due balance

                                    Scenario: Customer is past due on their account for 4 months. We suspend their billing in Zoho books. Customer finally logs into the portal and enters a new credit card. We associate that cardwith their subscription, which will permit the card to be used
                                  • Instant Sync of Zoho CRM Data?

                                    With how valuable Zoho Analytics is to actually creating data driven dashboards/reports, we are surprised that there is no instant or near instant sync between Zoho CRM and Zoho Analytics. Waiting 3 hours is okay for most of our reports, but there are
                                  • Kaizen #211 - Answering your Questions | Using Canvas and Widgets to Tailor CRM for Mobile

                                    Howdy, tech wizards! We are back with the final post in addressing the queries you shared for our 200th milestone. This week, we are focusing on a couple of queries on Zoho CRM mobile configurations and custom payment gateway integration. 1. Mobile SDK
                                  • Remove "Invalid entries found. Rectify and submit again" modal

                                    Following up on a post from a few years back, but can the Zoho team consider either removing the 'Invalid entries found. Rectify and submit again' modal that displays for empty mandatory fields OR allow an admin to change it? I've built a custom error
                                  • Validation function not preventing candidates under 18 or over 30 from submitting the web form

                                    Hello everyone, I’m trying to create a validation rule for the Candidate Webform in Zoho Recruit. I added a custom field called “Date of Birth”, and I want to make sure that candidates cannot submit the form unless their age is between 18 and 30 years.
                                  • Remember all the ways we've posted?

                                    The world celebrates World Postal Day in 2025 with the theme “#PostForPeople: Local Service. Global Reach". The story of the “post” is a story of human connection itself, evolving from simple handwritten notes carried over long distances to instant digital
                                  • Custom domain issue

                                    I recently changed records for my support area custom domain for a few months, I then wanted to come back to Zoho, but now I can't connect it and I can't login as it's having an SSL issue. I cannot get a good response from support, as I've been notified
                                  • Cadence reports as front-end reports

                                    Hello everyone, We have built a cadence which is connected to the Leads module. There are 11 steps in total, 7 are automatic emails and 4 are tasks for the Lead owners. As admins, we have access to this (very nicely made) 'View Reports' tab where we can
                                  • Zoho Commerce in multiple languages

                                    When will you be able to offer Zoho Commerce in more languages? We sell in multiple markets and want to be able to offer a local version of our webshop. What does the roadmap look like?
                                  • Show elapsed time on the thank-you page?

                                    Is it possible to display the total time a user spent filling out a Zoho Form on the thank-you? I’d like to show the difference between the `form submission timestamp` and the `start time` (currently have a hidden Date-Time field set to autofill the date
                                  • The present is a "present"

                                    The conversation around mental health has been gaining attention in recent years. Even with this awareness, we often feel stuck; the relentless pace of modern life makes us too busy to pause, reflect, and recharge. In the world of customer support, this
                                  • Cliq iOS can't see shared screen

                                    Hello, I had this morning a video call with a colleague. She is using Cliq Desktop MacOS and wanted to share her screen with me. I'm on iPad. I noticed, while she shared her screen, I could only see her video, but not the shared screen... Does Cliq iOS is able to display shared screen, or is it somewhere else to be found ? Regards
                                  • Kaizen# 209 - Answering Your Questions | All About Client Script

                                    Hello everyone! Welcome back to another exciting Kaizen post! Thanks for all your feedback and questions. In this post, let's see the answers to your questions related to Client Script. We took the time to discuss with our development team, carefully
                                  • Email Integration - Zoho CRM - OAuth and IMAP

                                    Hello, We are attempting to integrate our Microsoft 365 email with Zoho CRM. We are using the documentation at Email Configuration for IMAP and POP3 (zoho.com) We use Microsoft 365 and per their recommendations (and requirements) for secure email we have
                                  • Search in Zoho Community Not Working

                                    I realize this is a bit of a meta topic, but the search for the various Zoho Communities appears to not be working. I'm under the impression that they run on some version of the Zoho Desk platform, so I'm posting this here.
                                  • I need to do crud with snippet html

                                    I need to implement a form with an improved user interface. I would like to use snippets to build a CRUD that allows me to create and update records. How could I achieve this using snippets?
                                  • Allow Stripe Credit Card and Stripe ACH payment methods to be enabled separately on an invoice.

                                    I need to be able to pick at the invoice level whether Stripe Credit Card and/or Stripe ACH payment methods are available. Currently, I'm not able to select from the two Stripe payment methods individually on an invoice. However, there are some larger
                                  • Enhancements to finance suite integrations

                                    Update: Based on your feedback, we’ve updated the capabilities for integration users. In addition to the Estimates module, they can now create, view, and edit records in all the finance modules including Sales Order, Invoices, Purchase Order. We're also
                                  • Meeting impossible to use when sharing screen

                                    he Meeting tool in Brazil is practically unusable when sharing anything, whether it’s a presentation or simple navigation. When accessed via Cliq, the situation gets even worse: even basic calls fail to work properly, constantly freezing. And as you are
                                  • Connecting two modules - phone number

                                    Hi, I’d like some guidance on setting up an automation in Zoho CRM that links records between the Leads module and a custom module called Customer_Records whenever the phone numbers match. Here’s what I’m trying to achieve: When a new Lead is created
                                  • Resume Harvester: New Enhancements for Faster Sourcing

                                    We’re excited to share a set of enhancements to Resume Harvester that make sourcing faster and more flexible. These updates help you cut down on repetitive steps, manage auto searches more efficiently, and review candidate profiles with ease. Why we built
                                  • Incorrect “correct” password on email client apple mail

                                    I have troubleshot this account several times. I have deleted and re added account. It keeps saying incorrect password. Can you check that it is not locked on your end?
                                  • Is it possible to lock editing subform rows?

                                    Ideally editing would only be locked after the form has been updated but I still want them to be able to add new subform records at any time and they should be able to delete rows from the subform. It is a named subform if that's relevant however the
                                  • "Spreadsheet Mode" for Fast Bulk Edits

                                    One of the challenges with using Zoho Inventory is when bulk edits need to be done via the UI, and each value that needs to be changed is different. A very common use case here is price changes. Often, a price increase will need to be implemented, and
                                  • What is the maximum file size of a video upload in Zoho chat?

                                    Can I upload a 20 mb video file and share it with my colleagues? 
                                  • The Social Wall: September 2025

                                    Hello everyone, As we step into the fall season, some major updates are on the horizon. Meanwhile, here are the exciting updates we rolled out this September. Approvals in iOS Managing approvals just got more seamless on mobile. With this update, the
                                  • Update a field in ALL all calls under a contact

                                    HI guys! I have written some deluge code to update a field in my calls after i have comepleted the call, i need this field to update in all my scheduled calls as well that are comeing up. I just cant seem to get it to work, i have put teh code below,
                                  • MS Teams Meeting to Zoho CRM

                                    Has anyone figured out a good way to push MS Teams meeting info on a trigger of "meeting end" to Zoho CRM? We're looking for a way to take attendees of a meeting and meeting duration and push it into Zoho CRM after the meeting has ended. If I can just
                                  • In place field editing for candidates

                                    Wondering about any insight/best practices for efficiently updating candidate records while reviewing them in a Job Opening pipeline. We can do in-field editing (e.g. update job title or City) only when we have the full candidate record open, however
                                  • Automatic Matching from Bank Statements / Feeds

                                    Is it possible to have transactions from a feed or bank statement automatically match when certain criteria are met? My use case, which is pretty broadly applicable, is e-commerce transactions for merchant services accounts (clearing accounts). In these
                                  • Verifying Zoho Mail Functionality After Switching DNS from Cloudflare to Hosting Provider

                                    I initially configured my domain's (https://roblaxmod.com/) email with Zoho Mail while using Cloudflare to manage my DNS records (MX, SPF, etc.). All services were working correctly. Recently, I have removed my site from Cloudflare and switched my domain's
                                  • Fat Download of Ulaa Browser

                                    I just observed that Ulaa Browser is offering an one-capsule big download. These days it is a custom to offer a small bootstrap downloader and based on user customization options an appropriate download completes. And this is particularly common with
                                  • Next Page