Tendie-Tracker icon indicating copy to clipboard operation
Tendie-Tracker copied to clipboard

Expense update error - expense record doesn't exist

Open eddyharrington opened this issue 4 years ago • 1 comments

Some users are reporting that when they try to update an expense record, they get an error message: "The expense record you're trying to update doesn't exist"

eddyharrington avatar May 27 '20 20:05 eddyharrington

Root cause of this is because all of the monetary value columns use data type 'REAL' which is imprecise. According to Postgres docs, 'NUMERIC' data type is the solution to this problem:

The data types real and double precision are inexact, variable-precision numeric types. Inexact means that some values cannot be converted exactly to the internal format and are stored as approximations, so that storing and retrieving a value might show slight discrepancies. If you require exact storage and calculations (such as for monetary amounts), use the numeric type instead.

Tables | Columns that need to be updated from real to numeric(8,2):

  • users | income
  • expenses | amount
  • budgets | amount

Front-end changes that need regex to be updated to prevent more than 8 digits, 2 precision:

  • dashboard
  • addexpense
  • createbudget
  • updatebudget

Back-end can be improved to also check for numeric constraints, otherwise user will face 'Internal Error' message if for some reason they are able to enter a numeric with more than 8 digits or 2 precision

eddyharrington avatar May 27 '20 22:05 eddyharrington