In businesses, item prices are not always fixed and can fluctuate due to various factors. If you find yourself manually adjusting the item rates every time they change, we have the ideal time-saving solution for you. In today's post, we bring you custom functions that automatically update an item's sales price and cost price based on the latest price entered during invoice and bill creation, respectively.
1. Create two Checkbox-type custom fields by the names "Update Selling Price" and "Update Cost Price" for the Items module. Depending on which checkbox is ticked, the corresponding custom function will be executed for the particular item.
2. You must also 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 custom functions will get executed for base currency transactions only.
You will be setting up two Workflow rules associated with the corresponding custom function to update the selling price and cost price.
(I) Update selling price at item level based on the price entered during invoice creation
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.
(II) Update purchase price at item level based on the price entered during bill creation
Navigate to Settings -> Automation -> Custom Functions -> +New Custom Function > Add the function code from this GitHub link.
You can now say goodbye to the tedious work involved with manually modifying the rates. With these custom functions, you can always be sure that your item prices are up-to-date as per the values entered in the last transaction.
We hope that you are benefitting from our custom function series. If you need any help with setting up the functions, connect with us at firstname.lastname@example.org.
Shireen Farhana S