SUMMARY After kmymoney update to 5.1.92, the credit account "Online Balance" bar became red color (error indication) even the account balance and online balances are equal. NOTE: This problem affects only the credit account. Other accounts types are behaving as expected. Looking at the source code: file: kmymoney/views/onlinebalancedelegate.cpp function: OnlineBalanceDelegate::paint() I printed the values used in the condition KColorScheme::BackgroundRole role = (accountBalance == onlineBalanceValue) ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground; qDebug() << "accountBalance = " << accountBalance << "\n"; qDebug() << "onlineBalanceValue= " << onlineBalanceValue << "\n"; When I opened the credit account, I got the output: accountBalance = -1423.76 "-35594/25" onlineBalanceValue= 1423.76 "35594/25" The problem is the negative sign of the account balance. STEPS TO REPRODUCE 1. Update to version 5.1.92 2. Import bank transactions for a credit account using OFX OBSERVED RESULT The "Online Balance" bar is red even if the account and online balances are the same EXPECTED RESULT The "Online Balance" bar should be green if the account and online balances are the same SOFTWARE/OS VERSIONS Linux/KDE Plasma: KDE Plasma Version: 6.3.3 KDE Frameworks Version: 5.116.0 Qt Version: 5.15.16 ADDITIONAL INFORMATION This function used to work as expected in version 5.1.3 before the update to 5.1.92
Suggested fix: --- onlinebalancedelegate.cpp 2025-03-21 19:55:20.508887229 +1100 +++ onlinebalancedelegate.cpp.new 2025-03-21 19:53:28.868843506 +1100 @@ -148,9 +148,10 @@ } const auto onlineBalanceValue = index.data(eMyMoney::Model::AccountOnlineBalanceValueRole).value<MyMoneyMoney>(); const auto accountId(index.data(eMyMoney::Model::IdRole).toString()); + const MyMoneyMoney showValuesInverted = index.data(eMyMoney::Model::ShowValueInvertedRole).toBool() ? MyMoneyMoney::MINUS_ONE : MyMoneyMoney::ONE; auto accountBalance(onlineBalanceValue); if (!accountId.isEmpty()) { - accountBalance = MyMoneyFile::instance()->balance(accountId, onlineBalanceDate); + accountBalance = MyMoneyFile::instance()->balance(accountId, onlineBalanceDate) * showValuesInverted; onlineBalanceValueTxt = onlineBalanceValue.formatMoney(index.data(eMyMoney::Model::AccountFractionRole).toInt()); }
Well, the solution might work in your case but there are others where it might fail. The problem here is that we don't know how the institution reports the credit card account balance. My idea currently is - and I present that here for discussion - to compare the absolute values of those two balances. I think it is very unlikely that this will produce false positives (meaning the status will show as green when it is actually red). Thoughts?
I think it will work.
I'm not certain, but I think I may have actually seen this problem on occasion. I'll have to check my OFX for negative balance, but I do like the absolute value concept.
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/267
Git commit 1051093bb69629561c3bfc0ab167571ccc36020f by Thomas Baumgart, on behalf of Thomas Baumgart. Committed on 31/03/2025 at 09:19. Pushed by tbaumgart into branch 'master'. If only sign of balance differs treat as OK If only the sign of the balance differs between the online received value and the one calculated by KMyMoney mark it as OK anyway. FIXED-IN: 5.2 M +2 -1 kmymoney/views/onlinebalancedelegate.cpp https://invent.kde.org/office/kmymoney/-/commit/1051093bb69629561c3bfc0ab167571ccc36020f