[GNC] Budget report fails in multiple currencies
ml enquirer
ml.hnel.227484 at gmail.com
Sun Jan 8 03:34:25 EST 2023
Yes, it's cumulative, which is a problem I think.
Let:
0 indicate the opening of the book
1 indicate the start of the budget period in question
2 indicate the end of that period
S_i indicates the sum of transactions since 0 at marker i, in the currency
of the sub-account
P_i indicates the sum of transactions since 0 at marker i, in the currency
of the parent account
ES_ij indicates the sum of transactions during a period bounded by i and j,
in sub-account currency
X_i gives the exchange rate between sub-account and parent-account
The trouble is that the report prints out:
P_2 - P_1
= S_2*X_2 - S_1*X_1
= (S_1+ES_12) * X_2 - S_1 * X_1
= ES_12 * X_2 + S_1( X_2 - X_1)
My problem is that I only really care about the first term, that contains
ES_12. But as the years go by, S_1 >> ES_12, so the second term
increasingly dominates. This becomes particularly visible when X_2-X_1 is
significant, which has certainly been the case looking at GBP and EUR in
recent years ;)
By the way, I agree that "ES_12*X_2" is a bit trivial, and it would be nice
to account for the variation of exchange rates during the year, but that's
a second-order effect compared to this bug.
To show this in the code:
The "Actual" column in the budget report is populated by
"gnc:get-account-periodlist-actual-value"
https://github.com/Gnucash/gnucash/blob/master/gnucash/report/reports/standard/budget.scm#L404
which just calls "gnc-budget-get-account-period-actual-value budget acct
period"
https://github.com/Gnucash/gnucash/blob/master/gnucash/report/reports/standard/budget.scm#L313
which calls "gnc_budget_get_account_period_actual_value"
https://github.com/Gnucash/gnucash/blob/master/libgnucash/engine/gnc-budget.cpp#L671gnc_budget_get_account_period_actual_value
which calls "recurrenceGetAccountPeriodValue"
https://github.com/Gnucash/gnucash/blob/master/libgnucash/engine/Recurrence.c#L421
where the documentation says "@return the amount that an Account's value
changed between the beginning and end of the nth instance of the
Recurrence."
The problem is that this does:
https://github.com/Gnucash/gnucash/blob/master/libgnucash/engine/Account.cpp#L3992
gnc_numeric b1, b2;
b1 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t1, NULL,
recurse);
b2 = xaccAccountGetNoclosingBalanceAsOfDateInCurrency(acc, t2, NULL,
recurse);
return gnc_numeric_sub(b2, b1, GNC_DENOM_AUTO, GNC_HOW_DENOM_FIXED);
More information about the gnucash-user
mailing list