Grand "Total amount" calculation going wrong in Purchase invoice .....#Error in code

Hello experts & developers …
finding miss match amount total in purchase invoice during creating .
after purchase Receipt ----- when convert to purchase invoice ----
& pulling all items from purchase receipt …as moving on save & permanently submission
message fleshing “Debit and Credit not equal for purchase invoice #PINV-00001. Differance is 0.08”
first didn’t understand where is mistake but after checking deeply find mistake in below images … please have a look
check carefully #Error & Grand total section

can this problem fix soon ? without fixing this error bug its highly risky & not pleasurable to use such a good software .


I’d say it’s probably rounding. The Grand Total is most likely calculated by taking each individual product and applying the exchange rate to it and storing that line total to 2 decimal places. Then all those items are totalled giving a slight rounding error. Whereas the Outstanding Amount is calculated by multiplying the USD Total by the exchange rate. If you set the decimal places you use to 3 or 4 places that should resolve the issue.

Hello @eamonn … thanks for reply & suggestions .
sir i already set Float Precision on 5 … please check attachment here
but problem not resolving…
is there another way to come-out from this issue ?
please suggest …


@1worldguru My hunch is still that’s it rounding. You can test that yourself by taking the line totals on the purchase receipt and working out the totals after applying the exchange rate and seeing if they have been rounded and if the precision on the line totals is being dropped. If that is the case then they need too handle the rounding issue. Simple way to do that would be to show a rounding figure on the receipt so that the total is the calculated total plus or minus any rounding. That’s the way eBay does it with it’s fees calculations which often result in rounding issues on their invoices.

Hello @eamonn
im very sorry for disturbing you lot :smiley:
and really appreciating for your kind helping nature
sir if you see in purchase receipt there is auto rounding option available .
system automatically doing rounding …that’s why while creating purchase receipt or purchase order
this problem not facing
but in purchase invoice this facility not having .
also i doubt we have this facility in erpnext that we can make rounding manually…
if possible please share me step by step guidance so i can fix this issue …

please find both below images for reference.


@vishal It looks to me that rounding is being used in two different ways here. There is the rounding that I suspect is going on against product lines on the Purchase Receipt and the rounding that you have circled in the Purchase Receipt which is simply rounding the total to the nearest INR so that the total can be put in its written form in INR only. That rounding that you have highlighted isn’t the issue as it’s only a display thing and not an actual payment amount which the INR37,62,926.21 is and this can be proved as the difference between the two documents is 0.08 which is the difference between that and the amount shown on the invoice which is ends .13.

Is it possible to screenshot the purchase receipt in full blanking out only sensitive info so that I can see the line by line totals for each product on the receipt and any other charges or taxes that make up the final grand total?

@1worldguru seems like a rounding think, you can choose to write it off or wait for @nabinhait to fix it next week.

CC @nabinhait

@1worldguru Can you please create the Purchase Invoice record in and post it here? It will help to analyse the case.

Hello @nabinhait is it possible to import all that CSV file in demo version ? to find exact similar condition i need to create all so-many manual entries… will you please suggest any short cut is it possible ?


@1worldguru I have checked in your cloud account. And fixed the issue, it will be updated in the next release.


The issue still seems to be there. Attaching screens from the latest demo site.

I have been struggling it with my hosted version (latest).

Noticed forms: Purchase invoice, Sales invoice
Issue: For certain amount of additional discount on Grand_total gives a very small difference in the total value.

Demo site Purchase invoice PINV-00010. Below is the total

Below is the additional discount applied on Grand_Total.

The value gets calculated correctly for many other discount values. For eg.

If the discount is applied on Net_total, the calculation is correct.

Its not fixed yet. The issue is still there if you put additional discount base on grand total. For now write it off is the solution