Closed kidhab closed 1 year ago
awesome bug hunting kidhab!
Could it be possible that in conversion_factor = (supplier_unit / fc_unit).to_base.to_r
fc_unit is zero ?
wait .. shouldn't unit just be kg
or g
without a numeric value? I'm irritated :D I'll have a closer look tomorrow
soo for some reason Unit.new("0,9kg") becomes 0 ... I fixed it by adding zero checks to the convert_units function. The same exception could be reproduced by simply setting Unit to "0kg" ... Not sure if we'd want to maybe replace "," to "." or explain the user that only "." is allowed
This is actually a users feedback that I was able to reproduce via our demo instance.
Trying to synchronise the supplier database with the external source failed with a ZeroDivisionError:
The error occurs when the unit field contains a comma seperated weight (e.g. "kg" or "g") value which differs from the value of the external database - if it also contains a weight specification.
There's no error if you remove the weight specification. So I assume it's caused by the conversion.
You can reproduce here.
The screenshot shows the problematic unit field of "Article1":
And the related Article in the shared database: