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

                                  • Automate pushing Zoho CRM backups into Zoho WorkDrive

                                    Through our Zoho One subscription we have both Zoho CRM and Zoho WorkDrive. We have regular backups setup in Zoho CRM. Once the backup is created, we are notified. Since we want to keep these backups for more than 7 days, we manually download them. They
                                  • Backup to external location (Dropbox etc)

                                    Dear Zoho Team, I've set the CRM Backup schedule to once a month, which when complete sends me an email. Of course I then need to manually login and download the file. Nice but VERY 20th century and relies on us humans not to fail. Can you please provide
                                  • Cloud backup for CRM

                                    This is an idea / feature request for ability to periodically export CRM backup to an external cloud provider, similar to Zoho Vault: https://www.zoho.com/vault/data-backup.html Alternatively I would help being able to access manual data backup programatically
                                  • Introducing throw statements in Deluge

                                    Hello everyone, We're introducing a powerful addition to Deluge that gives you more precise control over error handling in your scripts. Whether you're calling an external API, validating user input, or enforcing a business rule, there are moments when
                                  • WhatsApp Coexistence

                                    Hello, please implement WhatsApp Coexistence, we need to track staff whatsapp chats on their PC and they need to be able to use WhatsApp on their mobile in around the office and warehouse, as we video call customers and send them product pictures. Thank
                                  • Zoho Creator to Zoho Writer for prefilled documents...

                                    In response to the question about connecting Zoho Creator to Zoho Writer for prefilled documents, I wanted to share a working implementation that demonstrates how to use the record_id parameter with the Zoho Writer Merge API. This allows Writer to automatically
                                  • Upload a video to embed into an article

                                    How can we upload a video to embed into the article...? We can upload images but this only seems to support image files. And the video option seems to just support YouTube, Vimeo and DailyMotion which is no good, we need to create our own videos and upload
                                  • PAN - Aadhar Link Status

                                    Can Zohobooks also get latest PAN-Aadhar Linking Status from Income Tax Portal ?
                                  • LinkedIn RSC is now live in Zoho Recruit

                                    LinkedIn Recruiter System Connect (RSC) is here. Your Zoho Recruit data (candidates, jobs, notes, stage updates, resume attachments, and more) now syncs with LinkedIn in real time. Note: LinkedIn RSC is included with your LinkedIn Recruiter Corporate
                                  • Zoho Writer for Android - Headings

                                    Hello Zoho team, I have created structured doc with headings in writer web version on pc. Then I have opened it in my phone. Write is crashing while used function: menu "three dots", Document Navigation, Headings. Zoho Writer for Android 6.1.4 Samsung
                                  • The in between line spacing management

                                    In the Microsoft Word, when we write something there is a tool from where we can manage the line spacing. Here in writer app in mobile it is by default 1.5. I request Zoho Team to give the option from where I can control Line Spacing, Remove space between
                                  • Zoho Books | Product updates | September 2026

                                    Hello Partners, We've rolled out new updates to Zoho Books. From a brand-new Nigeria edition expanding our presence on the African continent to the new Super Admin privilege, here's everything that's new this month. Nigeria Edition Now Live [Nigeria Edition]
                                  • Zoho Books | Product updates | August 2026

                                    Hello users, July has been an exciting month for Zoho Books! This month, we're excited to introduce HTML PDF Templates, Placeholders as Pills, expanded approval workflows for Sales Returns and Journals, and significant compliance updates across the India,
                                  • Pulling data from lookup fields

                                    If I try to pull in CRM data from a lookup field, it only shows a number and not the actual name. Is there a way to get around this? It impossible to do reports using lookup field data.
                                  • CRM x WorkDrive: We're rolling out the WorkDrive-powered file storage experience for existing users

                                    Release plan: Gradual rollout to customers without file storage add-ons, in this order: 1. Standalone CRM 2. CRM Plus and Zoho One DCs: All | Editions: All Available now for: - Standalone CRM accounts in Free and Standard editions without file storage
                                  • Marketing Tip #49: Set up Meta Pixel and turn store visitors into repeat buyers

                                    Most of your store visitors don't buy on their first visit. They browse, get distracted, and leave. Without a way to reach them again, that traffic is gone forever. Meta Pixel changes that. What is Meta Pixel? Meta Pixel (previously called Facebook Pixel)
                                  • unable to join meeting due to speaker issue

                                    unable to join meeting due to speaker issue
                                  • Unlock smarter scheduling with AI in Zoho Bookings

                                    Hello everyone! Scheduling touches more parts of a business than we often realize. Teams need to coordinate. Workflows need to move. Business apps need to connect. And with AI, the way we interact with scheduling is changing too. Join our upcoming live
                                  • Zoho CRM Layout Rules: Nine New Actions, Profile-Based Execution, and Interactive Preview

                                    Hello everyone, Availability: This feature is now available for all users. We’re excited to announce powerful new enhancements to Layout Rules in Zoho CRM - a feature built to guide our teams through form-filling by showing the right information to the
                                  • I want to delete payment detail of my cards from the system.

                                    I want to delete payment detail of my cards from the system.
                                  • Urgent: Outgoing Emails Delayed Across All Zoho Desk Departments

                                    Dear Zoho Support, We have started receiving delivery delay notifications across all our Zoho Desk departments. Error details: Error: 451 4.7.500 Server busy Action: Delayed Receiving system: Microsoft 365 / Exchange Online Affected Zoho sending IPs identified
                                  • Les meilleures pratiques d’email marketing pour booster les ouvertures, les clics et les conversions

                                    L’email marketing connaît aujourd’hui des changements profonds. Gmail, Yahoo et Microsoft ont notamment renforcé leurs exigences en matière d’authentification, ce qui rend la délivrabilité plus complexe et exigeante. Dans le même temps, les filtres basés
                                  • Header Line in Quote product rows

                                    I believe this is an essential feature that Zoho should provide us, when adding products we want the ability to add titles for our product, in quotes: The Solution/Category Title Product1 Product2..... and then it would show the sub-total of that title 
                                  • add pdf bills

                                    as zoho scan is to high cost,and claude and others as costing low , why u are not costing less than apps
                                  • Error with bank feed activaiton (Global edition)

                                    Hi there, We've started using Zoho Books in NZ and have been struggling to activate bank feed from BNZ. Althouhg following the instruction to active bank feed, an error message appears every time as attached. Plase advise how to resolve this matter. Thank
                                  • prefill_data for Creator + Merge & Sign

                                    Hello, Is there an option to use prefill_data for signer fields from creator? I see the option for CRM but it will not work with creator? I have tried passing the value in the signer data, and that also does not work. Alternatively, is there a way to
                                  • Support Required for Integrating Zoho SalesIQ in Flutter Web

                                    Hi Team, I have developed a Flutter application and I am currently using the salesiq_mobilisten: ^6.5.4 package. As per the package documentation ( https://pub.dev/packages/salesiq_mobilisten ), it supports only Android and iOS, and it is working fine
                                  • Books is extremely slow again today !

                                    Everything is running slowly even with 500mb connection speed
                                  • Automate Credit Card Surcharge

                                    Is there a way to create an automation that will add a 3.0% credit card surcharge to a subscription whenever a customer pays via credit card?
                                  • How to charge Convenience fee OR payment gateway charges to the end client who is paying the invoice?

                                    Hello, I am creating this topic after having discussions with various sets of users and have understood that with people moving more and more to digital payments, it is important for the client to enable the "Convenience fee" kind of scenario. I have
                                  • How to add a fee based on payment method

                                    I currently accept both ACH payments and credit card. I want to add a 3% fee to a number of my subscription plans if the customer chooses to use a credit card (and not ACH/checking). How do I do this? Is there an in-built feature, or would i have to create
                                  • Customer Statement Showing Incorrect Negative Balance Due to Unused Advance

                                    Dear Zoho Support Team, We are facing an issue with the Customer Statement in Zoho Invoice related to customer advances/mobilization advances. The issue is that when a customer has made an advance payment that has not yet been fully utilized against invoices,
                                  • ICICI Bank integration bulk payments to multiple vendors

                                    Hi Team, I would like to know why ICICI Bank integration doesn't allow bulk payments to multiple vendors. Other banks such as HSBC, Yes Bank and Axis Bank allows zoho integration to make payments to multiple vendors at a time
                                  • Zoho Inventory - Profit Margin Feature - Allow Users to Set Default Cost Price Calculation Method

                                    Hi Zoho Inventory Team, I'm working with an automotive parts distributor using Zoho Inventory. They have expressed frustration about having to change the Cost Price Method on every line item they add from the defult "Inventory Valuation Method" to "Item
                                  • Deprecation Notice: OpenAI Assistants API will be shut down on August 26, 2026

                                    I recieved this email from openAI what does it means for us that are using the integration and what should we do? Earlier this year, we shared our plan to deprecate the Assistants API once the Responses API reached feature parity. With the launch of Conversations,
                                  • Payment for product renewal

                                    Good morning, I am requesting your kind assistance to renew my subscription because when I try to make the payment I get this way
                                  • Calendar Year View?

                                    Is there a way I can view the calendar in year view? Maybe create a page with a view like this?
                                  • Razorpay + Zoho Billing + Zoho Books Integration

                                    Please help us set up this integration.
                                  • Proyecto SII

                                    Buenas tardes amigos de zoho. en mi empresa vamos a implementar el proyecto de emisión de facturas SII pero para poder hacerlo hay que subir un xml, estoy intentando automatizar este proceso pero no se como convertir la factura que retorna books a xml
                                  • Automate Workflows at the Subform Level

                                    Hello, Enterprise Support Community! We are excited to introduce an enhancement to Workflow Rules that gives you more control over automation within your records. Previously, Workflow Rules could only be configured at the module level, which meant changes
                                  • Next Page