Bug 452026 - Income and Expenses chart displays wrong stats when currency rate changes
Summary: Income and Expenses chart displays wrong stats when currency rate changes
Status: CONFIRMED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.1.2
Platform: Other Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-29 09:03 UTC by Tamer
Modified: 2022-04-02 09:59 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Income and Expenses chart displays wrong stats when currency rate changes (1.22 KB, application/gzip)
2022-03-29 09:03 UTC, Tamer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tamer 2022-03-29 09:03:55 UTC
Created attachment 147812 [details]
Income and Expenses chart displays wrong stats when currency rate changes

SUMMARY
***
"Income and Expenses This Year" Report showing incorrect values in a month if the currency conversion rate was changed during the month.
***


STEPS TO REPRODUCE
1. Create a new KMyMoney file having base currency as EGP
2. ADD another currency AED and make the conversion rate of 1 AED = 4 EGP with a date of 1 Jan 2022
3. Make new entry for the conversion rate to be 1 AED = 5 EGP with a date of 20 Mar 2022
4. Create a saving account "My Bank" with AED Currency.
5. Create a category "Salary" with EGP Currency.
6. Change the base currency to be AED (tools -->Currencies)
7. Add a new transaction in "My Bank" account for 1,000 AED dated 22 Mar 2022
8. Go to (Reports --> 1. Income and Expenses) and select (Income and Expenses This year)


OBSERVED RESULT
The report will show an income of 1,250 AED

EXPECTED RESULT
The report must show an income of 1,000 AED as entered.

MY ANALYSIS:
It looks like the application did the following:
1. Converted the 1,000 AED with the rate of 1 AED= 5 EGP which made it 5,000 EGP (as this is the currency of the category "Salary") which is correct behavior as conversion rate was changed on 20 Mar 2022 so application picked the right rate.
2. Converted back the 5,000 EGP to the base currency (AED) at the rate of 1 AED=4 EGP which was the conversion rate at the beginning of the month, and the result is 1,250 AED which is totally wrong.

This behavior is giving false stats on the income and expenses and users can make wrong decisions in their life.
SOFTWARE/OS VERSIONS
Windows: Windows 10
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Thomas Baumgart 2022-04-02 09:59:38 UTC
The problem is due to aggregation - which happens on the reporting period - and the conversion to the base currency which is performed on the aggregated values. That means, that at the time of conversion to the base currency, the actual transaction is not visible anymore but only the aggregated value for the month in this case. No matter if you pick the first or last date of the period to get the conversion rate at this point it maybe wrong depending when the rate changed. In your case, if the conversion changed back to 1:4 on March 24th it does not matter if you pick March 1st or March 31st: both will be provide the wrong result.

To solve this issue, it would be better to aggregate not only on the basis of the account's currency but also on the base currency and do the conversion on the basis of the rate at the post date. Then during rendering of the report use the aggregated account's value or the aggregated converted value. That will provide more accurate results but means a large change to the reporting system.