Bug 798148 - Chart of Accounts page Present(xxx) value wrong

If for some reason you have price information in the future for a
security, the present value is based on the price retrieved for the
greatest date and not a price which is before the current date.

To fix this use the 'xaccAccountGetBalanceAsOfDateInCurrencyRecursive'
function.
This commit is contained in:
Robert Fewell
2021-04-20 13:29:57 +01:00
parent ab80a0c495
commit b54c30e03d

View File

@@ -3666,8 +3666,8 @@ xaccAccountGetXxxBalanceAsOfDateInCurrency(Account *acc, time64 date,
g_return_val_if_fail(GNC_IS_COMMODITY(report_commodity), gnc_numeric_zero());
priv = GET_PRIVATE(acc);
return xaccAccountConvertBalanceToCurrency(
acc, fn(acc, date), priv->commodity, report_commodity);
return xaccAccountConvertBalanceToCurrencyAsOfDate(
acc, fn(acc, date), priv->commodity, (gnc_commodity*)report_commodity, date);
}
/*
@@ -3841,8 +3841,9 @@ xaccAccountGetPresentBalanceInCurrency (const Account *acc,
const gnc_commodity *report_commodity,
gboolean include_children)
{
return xaccAccountGetXxxBalanceInCurrencyRecursive (
acc, xaccAccountGetPresentBalance, report_commodity,
return xaccAccountGetXxxBalanceAsOfDateInCurrencyRecursive (
(Account*)acc, gnc_time64_get_today_end (), xaccAccountGetBalanceAsOfDate,
(gnc_commodity*)report_commodity,
include_children);
}