Hi all!
I recently learned that when you are working off of a PostgreSQL database and convert a MONEY type to DECIMAL, it defaults to DECIMAL(10, 0). That means 10 total digits and 0 digits after the decimal. This results in your money getting rounded to the nearest dollar and rendering you unable to perform necessary calculations.
Instead of simply casting to DECIMAL, incorporate parameters that meet your goal. i.e. my_money::DECIMAL(18, 2)
Although I’m not sure you’d need 18 total digits (that number would be in the Quadrillions), it’s still a good habit to make the value larger than any value that might appear in your field.
Hope this posts helps. Happy modeling!