[account] add and expose xaccAccountGetReconciledBalanceAsOfDate

This commit is contained in:
Christopher Lam
2020-03-05 19:56:33 +08:00
parent cfa1625854
commit a8f03cf1c8
2 changed files with 21 additions and 0 deletions

View File

@@ -3428,6 +3428,24 @@ xaccAccountGetNoclosingBalanceAsOfDate (Account *acc, time64 date)
return GetBalanceAsOfDate (acc, date, TRUE); return GetBalanceAsOfDate (acc, date, TRUE);
} }
gnc_numeric
xaccAccountGetReconciledBalanceAsOfDate (Account *acc, time64 date)
{
gnc_numeric balance = gnc_numeric_zero();
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), gnc_numeric_zero());
for (GList *node = GET_PRIVATE(acc)->splits; node; node = node->next)
{
Split *split = (Split*) node->data;
if ((xaccSplitGetReconcile (split) == YREC) &&
(xaccSplitGetDateReconciled (split) <= date))
balance = gnc_numeric_add_fixed (balance, xaccSplitGetAmount (split));
};
return balance;
}
/* /*
* Originally gsr_account_present_balance in gnc-split-reg.c * Originally gsr_account_present_balance in gnc-split-reg.c
* *

View File

@@ -558,6 +558,9 @@ gnc_numeric xaccAccountGetProjectedMinimumBalance (const Account *account);
gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account, gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account,
time64 date); time64 date);
/** Get the reconciled balance of the account as of the date specified */
gnc_numeric xaccAccountGetReconciledBalanceAsOfDate (Account *account, time64 date);
/* These two functions convert a given balance from one commodity to /* These two functions convert a given balance from one commodity to
another. The account argument is only used to get the Book, and another. The account argument is only used to get the Book, and
may have nothing to do with the supplied balance. Likewise, the may have nothing to do with the supplied balance. Likewise, the