Negative Stock error (float precision issue)

i get an error
insufficient stock
stock less by 0.0023365 qty
i have changed the float value precision to 2 in global settings
but still i get this error
any help on this please
its critical

Please elaborate why this is an error - for example do you get a traceback?

Hi clarkej
Thanks for the reply
let me try to explain a scenario
i buy raw material in lengths
example : dia 50 x L3660 mm
i send this to subcontaract to get the length rod to smaller sizes
in my case
i need BUSH A 50 pieces of length 30 that is : 50nos x 30mm = 1500mm of material consumed
i need BUSH B 83 pieces of length 26 that is : 83nos x 26mm = 2158mm of material consumed
so total material consumed is 3658mm (sufficient enough from a single length of 3660mm)
in the bom of BUSH A
the conversion factor is — 122 nos from 1 length (3660mm) of material
in the bom of BUSH B
the conversion factor is — 140 nos from 1 length (3660mm) of material
i create a PO for the material to be sent to subcontract for the following items
BUSH A = 50 Nos
BUSH B = 83 Nos
so in stock entry while tranferring material to subcontract, erpnext calculates the amount of material to be sent to the subcontract
BUSH A = 50 Nos
raw material – reqrd qty = 0.41
BUSH B = 83 Nos
raw material – reqrd qty = 0.59
all above is ok… erpnext does its calculation correctly
i submit the stock entry
i recieve the material
while creating a purchase reciept

now while submitting the purchase reciept, i get this error

its giving an error of 0.002693 qty shortage / insufficient stock
how do i over come this
i have set float precision to 2 in global settings
please help me
iam stuck and unable to move forward

You need to do some analysis and derive the calculation here - the question is whether the negative value is correct.

If the problem is a result of say float round-off difference - due to ‘throwing away’ significant digits - then the code probably needs to be fixed to carry more digits or have a tolerance factor?

Stock Settings allows for Negative Stock Value. If you enable that, that may be an option perhaps.

I think this is a calculation problem related to round off. While its true that you’ve set the float to 2, ERPNext does calculations according to default decimal values rather than the float you set.

Let me submit a github issue on your behalf and let’s try and solve this.



Hi JayRam
Sir thanks for raising a github issue on this
really stuck with this and not able to move forward
thanks again

Pushed a fix