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 account balance to Content Provider #68
Comments
|
Short answer: This will cause tight coupling. Instead account balance should be exposed! Long answer: The bank balance is not a part of the domain/datamodel per se, it is actually a saved state calculated from the accounts. When UID is implemented the bank balance value does not need to be saved in the database anymore. Exposing it would cause tight coupling with any application that uses it. Therefore the AccountBalance column should be exposed instead. I actually happen to need that as well so I will implement it. Below is the code that uses the balance (the diff variable): currentBalance = bank.getBalance();
accounts.clear();
for (final Account account : bank.getAccounts()) {
accounts.put(account.getId(), account);
}
bank.update();
diff = currentBalance.subtract(bank.getBalance());The balance itself is calculated on the fly public BigDecimal getBalance() {
if (STATIC_BALANCE) {
return balance;
}
else {
BigDecimal bal = new BigDecimal(0);
for (Account account : accounts) {
if (account.getType() == Account.REGULAR || account.getType() == Account.CCARD) {
if (!account.isHidden() || (account.getAliasfor() == null || account.getAliasfor().length() == 0)) {
bal = bal.add(account.getBalance());
}
}
}
return bal;
}
} |
|
Hmmm.... very tired and misread the original question. Embarrasing but anyhow, I'm almost done implementing it. |
|
This is implemented in a pending pull request: #89 |
Fix for issue #68: Add account balance to Content Provider
|
Thanks magnusart! |
Today you only can get the transaction amount via the content provider. But you can't get the account balance.
So I suggest that you add account balance to the category "BANK_ACCOUNTS_CAT"
The text was updated successfully, but these errors were encountered: