nazrinharris / pecunia

Massively ambitious personal finance app.
1 stars 0 forks source link

When creating/updating an account, an empty description should be counted as null #21

Closed nazrinharris closed 1 year ago

nazrinharris commented 1 year ago

Or more specifically, Value.absent when kept in the database, but setting as null should make drift put it as Value.absent. Right now, description is stored as an empty string, which is undesired.

Deed

nazrinharris commented 1 year ago

Should also consider having the enforcement in the Account data class itself. This kind of logic seems more appropriate there

nazrinharris commented 1 year ago

Here's an idea. Maybe have a ValueValidator kinda object, where it checks if the description is an empty String an turns it into null.

Then, update the local ds methods to receive an AccountDTO rather than parameters. So the flow of it will be like this.

  1. repo will receive the parameters, then create an Account entity.
  2. repo will convert the Account into an AccountDTO.
  3. local ds will receive the DTO and update the table using it.

This wouldn't be that major of a change, because the local ds is technically taking the parameters and converting it to a DTO before inserting it to the table.

nazrinharris commented 1 year ago

Did an epic. Because I changed the logic in the Account data class to essentially have a Description ValueObject, I barely need to change any of the repo, local_ds or the dao code. Just a minor change to the fromDTO and toDTO. Lovely.

Should be completed with 3c5ad7e in #14