Hi All,
One of the project requirement - we need to add additional amount on price for the selected item.
We are able to achieve the requirement by adding custom field.
Now, fields are like Item, Qty, Rate, Addon and Amount.
With client script, we calculate like Amount = (Qty*Rate) + Addon. and it’s showing perfectly fine.
When we save the invoice Amount get recalculated with (Qty*Rate) and Addon not added in the Amount.
Can anyone help us for this?
We did below steps
- Open Sales Invoice item, Go to customization
- Add custom field next to Rate called “Addon”. Now columns would be Qty, Rate, Addon and Total.
- Added client side script like Amount = (Qty*Rate) + Addon
- Save invoice and Amount changed/ recalculated.
I believe, its due to rate. Amount is simply the Qty*Rate, which is handled by backend. If you want to add anything in Amount, your Addon should be reflected in the rate.
You can easily achieve your desired outcome by overwriting core code. Being also an accountant, I can tell you, its very bad idea to add anything in ERPNext amount column. Its a nightmare from IFRS15 perspective, and event a bigger nightmare from Sales Tax/VAT point of view.
So add another field, like Amount Incl Addon, and do your calculations there. Hope this helps.
Thank you for your reply.
Addon/Additional amount will be added into tax and that’s confirmed with client.
Can you guild me where I can make changes in core code? Can you share path?
You should read erpnext docs first, how erpnext handles taxes. And try to see whether default implementation meet your requirement or not.
Following process is not that straightforward, stick to erpnext default implmentation, Any mistake here will mess up your accounting records.
By default ERPNext saves automatically calculate tax based on item tax template and saves it in item_wise_tax in a json field in tabSales Invoice. If you want to save tax amount lets say vat_amount for each item in Items Table. create a new field vat_amount in Sales Invoice Item, save your calculated tax amount there. Finally sum all the amounts in vat_amount for each row. and add that total in Sales Taxes and Charges table. In this way, erpnext will automatically make proper Journal Entries for your tax.
Its not that simple to explain this whole process in a short post. But my suggestion is to read erpnext docs thoroughly.
1 Like