mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add a flag to the account structure to defer balance computation
This commit is contained in:
@@ -1859,6 +1859,29 @@ gnc_account_set_balance_dirty (Account *acc)
|
||||
priv->balance_dirty = TRUE;
|
||||
}
|
||||
|
||||
void gnc_account_set_defer_bal_computation (Account *acc, gboolean defer)
|
||||
{
|
||||
AccountPrivate *priv;
|
||||
|
||||
g_return_if_fail (GNC_IS_ACCOUNT (acc));
|
||||
|
||||
if (qof_instance_get_destroying (acc))
|
||||
return;
|
||||
|
||||
priv = GET_PRIVATE (acc);
|
||||
priv->defer_bal_computation = defer;
|
||||
}
|
||||
|
||||
gboolean gnc_account_get_defer_bal_computation (Account *acc)
|
||||
{
|
||||
AccountPrivate *priv;
|
||||
if (!acc)
|
||||
return false;
|
||||
priv = GET_PRIVATE (acc);
|
||||
return priv->defer_bal_computation;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@@ -2214,7 +2237,7 @@ xaccAccountRecomputeBalance (Account * acc)
|
||||
|
||||
priv = GET_PRIVATE(acc);
|
||||
if (qof_instance_get_editlevel(acc) > 0) return;
|
||||
if (!priv->balance_dirty) return;
|
||||
if (!priv->balance_dirty || priv->defer_bal_computation) return;
|
||||
if (qof_instance_get_destroying(acc)) return;
|
||||
if (qof_book_shutting_down(qof_instance_get_book(acc))) return;
|
||||
|
||||
|
||||
@@ -360,7 +360,18 @@ void gnc_account_set_balance_dirty (Account *acc);
|
||||
*
|
||||
* @param acc Set the flag on this account. */
|
||||
void gnc_account_set_sort_dirty (Account *acc);
|
||||
|
||||
|
||||
/** Set the defer balance flag. If defer is true, the account balance
|
||||
* is not automatically computed, which can save a lot of time if
|
||||
* multiple operations have to be done on the same account. If
|
||||
* defer is false, further operations on account will cause the
|
||||
* balance to be recomputed as normal.
|
||||
*
|
||||
* @param acc Set the flag on this account.
|
||||
*
|
||||
* @param defer New value for the flag. */
|
||||
void gnc_account_set_defer_bal_computation (Account *acc, gboolean defer);
|
||||
|
||||
/** Insert the given split from an account.
|
||||
*
|
||||
* @param acc The account to which the split should be added.
|
||||
@@ -403,6 +414,8 @@ const char * xaccAccountGetNotes (const Account *account);
|
||||
const char * xaccAccountGetLastNum (const Account *account);
|
||||
/** Get the account's lot order policy */
|
||||
GNCPolicy *gnc_account_get_policy (Account *account);
|
||||
/** Get the account's flag for deferred balance computation */
|
||||
gboolean gnc_account_get_defer_bal_computation (Account *acc);
|
||||
|
||||
/** The following recompute the partial balances (stored with the
|
||||
* transaction) and the total balance, for this account
|
||||
|
||||
@@ -126,6 +126,7 @@ typedef struct AccountPrivate
|
||||
* in any way desired. Handy for specialty traversals of the
|
||||
* account tree. */
|
||||
short mark;
|
||||
gboolean defer_bal_computation;
|
||||
} AccountPrivate;
|
||||
|
||||
struct account_s
|
||||
|
||||
@@ -46,6 +46,13 @@ xaccTransGetSplit (const Transaction *trans, int i)
|
||||
return ((MockTransaction*)trans)->getSplit(i);
|
||||
}
|
||||
|
||||
SplitList *
|
||||
xaccTransGetSplitList (const Transaction *trans)
|
||||
{
|
||||
g_return_val_if_fail(GNC_IS_MOCK_TRANSACTION(trans), NULL);
|
||||
return trans ? ((MockTransaction*)trans)->getSplitList() : NULL;
|
||||
}
|
||||
|
||||
Split *
|
||||
xaccTransFindSplitByAccount(const Transaction *trans, const Account *acc)
|
||||
{
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
MOCK_METHOD0(beginEdit, void());
|
||||
MOCK_METHOD0(commitEdit, void());
|
||||
MOCK_METHOD1(getSplit, Split *(int));
|
||||
MOCK_METHOD0(getSplitList, SplitList *());
|
||||
MOCK_METHOD1(findSplitByAccount, Split *(const Account*));
|
||||
MOCK_METHOD0(getDate, time64());
|
||||
MOCK_METHOD1(setDatePostedSecsNormalized, void(time64));
|
||||
|
||||
Reference in New Issue
Block a user