diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index ea976be491..ebe8f38518 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -3428,6 +3428,24 @@ xaccAccountGetNoclosingBalanceAsOfDate (Account *acc, time64 date) 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 * diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h index 92ee17ab53..e778bc86fa 100644 --- a/libgnucash/engine/Account.h +++ b/libgnucash/engine/Account.h @@ -558,6 +558,9 @@ gnc_numeric xaccAccountGetProjectedMinimumBalance (const Account *account); gnc_numeric xaccAccountGetBalanceAsOfDate (Account *account, 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 another. The account argument is only used to get the Book, and may have nothing to do with the supplied balance. Likewise, the