What is the minimum sales quantity?

We got a fun ticket from one of our users the other day, asking how to set the minimum quantity a salesperson can sell. ERPAG has a built-in option for minimum PURCHASE quantity https://www.erpag.com/news/order-step-quantity-and-minimum-order-quantity-2. However, this applies to items being purchased, not sold. So, the question was how to set a minimum quantity of items for sales. The answer, of course, is by using custom fields and blockly scripts!

Custom fields: https://www.erpag.com/news/custom-fields-upgraded

More of our blockly script examples can be found here: https://www.erpag.com/customization-examples

Setting up custom fields

First, you will have to set a Minimum Sales Quantity custom field on the item level:

custom field on item level

Then, set a Minimum Sales Quantity custom field on the Sales Order – document items level. Set it that it’s copied from the field Item – Minimum Sales Quantity (that you previously created):

Custom fields are created in the Automatization & Customization module, for those new here and wondering where to find this setup. And setting up these custom fields is mandatory, as we will use them in our blockly script!

Setting minimum Sales Quantity (custom field) for each item

Now that you have created your custom fields, each item in your database will get a new field in which you have to input your minimum quantity for sales:

populate minimum sales quantity on each item

To speed things up, you can add these values in bulk through the bulk edit option. Just select the products from your products & services page > bulk action > bulk edit, and you will get to this window:

bulk edit custom fields value

Creating the Blockly script

Go to Automatization & Customization and create a Trigger script as shown:

Save the script & run it!

Creating a Sales Order

Create your Sales Order as usual, but if you put less quantity to be sold than is required, you will get an error upon saving the document. You won’t be able to save the document until you change the quantity.

error message blockly script

Read More

Related Posts

💬 Start Chat