Add balance total after each transactions #570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
This pull request is primarily made to answer to the following issue : #568
It should display account balance after each transactions.
The changes are summarized below :
I created three variables :
_runningBalancesByTransactionId
,_lastCalculatedBalance
and_balanceAccount
which store the balance for each transaction, store the last calculated balance and store a reference to the account respectively.I created three helper functions
_parseBalance
,_isRevenueOrExpense
,_updateBalance
- maybe they should be moved else where.Lines 267-288: This is where I update for each transactions the balance based on the last balance (either
_lastCalculatedBalance
or the actual account's balance)Lines 725-739: When a transaction is edited for some reasons, the account linked to the transaction is being fetched and the balance is being re-calculated. This part of the code should probably be optimized.
I updated the syntax of some part of the code too.
Unit tests might be a good thing to add some days in the future. Maybe.
Disclaimer:
I never ever developed for mobiles, used Dart language nor used the "Flutter" framework.