Calculate total quantity from sales invoice item table (Bonus item for customer)

Hi everyone!
This is my first post here. In our pharmaceutical business we give bonus item to customer if they purchase a certain number of items as shown in the screenshot below.


I’ve added the bonus column in sales invoice item table. What I want is that below the table total quantity will be calculated including the bonus quantity and the calculated total will be deducted from the stock. For example, in the screenshot it is showing 10. I want it to be 11 and 11 items should be deducted from stock. How can I achieve this?
Thanks in advance.

You have to write custom script for Doctype Sales Invoice to add the Bonus quantity in Total Quantity.

Thanks. But how can I find necessary variables?

So it was adding before, what you need to do is to add the the bonus qty variable to total qty.
Hope this will help.

@Faisal_Pasha Did you figured out the way to handle bonus?

No. I didn’t do it after that.

@Faisal_Pasha is required this type of module in the software.