I am building a test billing application, built in rub on rails, Jquery and Postgres DB (using decimal columns)
This is the below way I am storing values, but I think that is not the way it should save the values
Product 1: 57.5
Charge: 1.7249999999999999
S-Tax: 0.13799999999999998
C-Tax: 4.6
Total: 63.97
Here, I am not rounding any values other than Total when submitting the form; without rounding the Total will be 63.963. So, doing this rounding only for Total and not for others creates issues. For some countries I need to use the precision 2, and others 3
Moreover, I would like to know if this is the correct way to store these values in DB.
Is there any rule like doing the rounding for each column (Charge, S-Tax, C-Tax, and Total)? or any rules for the precision & scale? OR should we convert this to integer?
If we go for integer, should we round it and convert to integer?
What would be the correct data we should store when we submit it? It would be great if someone could suggest, as this has been haunting for some time.
Aucun commentaire:
Enregistrer un commentaire