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.