I'm working on a rails application with Postgres and ActiveRecord that is keeping track of payments and transaction fees (which are based on percentages).
Currently I'm using BigDecimal (and decimal columns in ActiveRecord) to keep track of the values of these transactions, but dealing with rounding has been frustrating. (for example how 8.05 - 1.0 ==> 7.050000000000001
)
Does it make sense to continue using decimal
columns for dollar amounts? Or should I switch to storing everything in integer
value cents so I don't need to deal with rounding issues.
An important note is that none of my transactions (as of now) are worth fractional cents.
What are the pros and cons of each approach?
There are a number of possible strategies for dealing with currency in Rails,
Such as What is the best method of handling currency/money?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With