-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add start balance to manual accounts #735
Add start balance to manual accounts #735
Conversation
0cbdb80
to
d5403bd
Compare
@zachgoll After this is reviewed I will need some help with updating the Google Sheet to include the new manual account fixtures. |
@jakubkottnauer will take a look this afternoon! |
@jakubkottnauer thanks for the work on this! I've addressed some of the various questions below along with some overall thoughts:
We do have some designs, I'll be getting them out for dev soon!
Should future dates be valid? I know we're not enforcing this currently but it may be a good idea to set a max date of
There are some designs in the works to distinguish between the two, but I'm starting to think that we should simply overwrite the existing sync process and tests and assume that all accounts are manual for now. I'm completely fine deleting the existing sync logic and making this the new "base case" until we have connected accounts to work with. We can always go back in source control to find the "connected account logic". For now, I think it will be a lot simpler to deal with concrete flows rather than trying to design for the future. Off the top of my head, I think the pieces that we'd need to address would be: StrategyIn my head, a "start balance" is ultimately the same thing as a Rather than introducing a new DB field, I think we can just use the "oldest Valuation" as our start balance. When a user creates an account, we can ask them for this information and our system will automatically create the
If we did this, I think we'd be able to keep almost all of our existing balance calculator logic. The only thing that would then change would be this line:
We would then need to make sure that on every sync, |
Thank you for the review! I'll incorporate the changes you've suggested, making manual accounts the "base case" for now 👍
Some other apps I have used allow future transactions, though I don't see much value in allowing future valuations. And if we won't be allowing those, maybe it makes not to allow transactions either for consistency 😄 Up to you!
I like the proposed solution, I'll make the change today/tomorrow |
@jakubkottnauer I think for now we can enforce a max date of
|
a9db30f
to
fe9f0f0
Compare
17215f5
to
077f4b9
Compare
077f4b9
to
b3c957d
Compare
@zachgoll I've implemented the changes, seems to work well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Can you update the tests to expect this new convention? Will get it merged after those pass.
Co-authored-by: Zach Gollwitzer <[email protected]> Signed-off-by: Jakub Kottnauer <[email protected]>
6cfd917
to
ce97125
Compare
@zachgoll I've pushed a few new tests. Can you help out with updating the CSVs? |
@jakubkottnauer here is the link to the Google sheet that I've been using to visualize the test cases: https://docs.google.com/spreadsheets/d/18LN5N-VLq4b49Mq1fNwF7_eBiHSQB46qQduRtdAEN98/edit?usp=sharing I'll go ahead and get this updated after this PR is merged. But for now, I think all we need to do is update the final row in each of these CSVs:
|
@zachgoll All tests are green now 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, looks great! Thanks for the work on this!
This PR makes
balance
of manual accounts be automatically updated whenever a new valuation or a transaction is added to that account. In this first iteration, the solution "hijacks" the existing sync flow by first computing the correct current balance which is then treated as the "source of truth" in the rest of the sync (as if it was an account connected to a 3rd party provider).Current balance of a manual account is calculated as follows:
start_balance
if no valuation existsChanges
A new
accounts.start_balance
column has been added. I have considered making the migration populate the column for all accounts (as we only have manual accounts at the time of running the migration) but then to be consistent I would also have to change all of the seed data to create manual accounts, which doesn't sound like something we'd like to do. Happy to discuss this further.All newly created accounts will be manual by default as we don't have support for connected accounts yet.
Next steps
date
set in the future. This means that accounts need to be synced periodically to make sure the balance is up to date every day the user opens Maybe. Somewhat similar to the issue When exchange rates are not available, foreign currency account rollups should show a warning UI + message #724 and can be fixed the same way.account.start_balance.nil?
. In the future it would be nicer to check if a provider connection exists for the account, but we're not quite there yet.