Only show the “Show stock split adjusted amounts” checkbox when there are stock splits

Added has_stock_split field to Account private.  This flag is set to true when  xaccAccountRecomputeBalance() detects a stock-split split otherwise it is false.  Defined and declared xaccAccountHasStockSplit() for use by the Lot Viewer to whether to display the check box.
This commit is contained in:
Sherlock committed 2026-07-09 01:17:17 -07:00
1 parent ff30f4438b
commit 31978c1b4d
4 files changed
+32 -1

No files matched your search

+12
View File
@@ -328,6 +328,7 @@ gnc_account_init(Account* acc)
priv->starting_cleared_balance = gnc_numeric_zero();
priv->starting_reconciled_balance = gnc_numeric_zero();
priv->balance_dirty = FALSE;
priv->has_stock_split = false;
new (&priv->children) AccountVec ();
new (&priv->splits) SplitsVec ();
@@ -1456,6 +1457,7 @@ xaccFreeAccount (Account *acc)
priv->commodity = nullptr;
priv->balance_dirty = FALSE;
priv->has_stock_split = false;
priv->sort_dirty = FALSE;
priv->splits.~SplitsVec();
priv->children.~AccountVec();
@@ -2288,6 +2290,7 @@ xaccAccountRecomputeBalance (Account * acc)
auto noclosing_balance = priv->starting_noclosing_balance;
auto cleared_balance = priv->starting_cleared_balance;
auto reconciled_balance = priv->starting_reconciled_balance;
auto has_stock_split = false;
PINFO ("acct=%s starting baln=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT,
priv->accountName, balance.num, balance.denom);
@@ -2314,6 +2317,7 @@ xaccAccountRecomputeBalance (Account * acc)
GNC_HOW_RND_ROUND_HALF_UP));
}
balance = new_balance;
has_stock_split = true;
}
else
{
@@ -2348,6 +2352,7 @@ xaccAccountRecomputeBalance (Account * acc)
priv->cleared_balance = cleared_balance;
priv->reconciled_balance = reconciled_balance;
priv->balance_dirty = FALSE;
priv->has_stock_split = has_stock_split;
}
/********************************************************************\
@@ -3502,6 +3507,13 @@ xaccAccountGetProjectedMinimumBalance (const Account *acc)
return minimum ? *minimum : gnc_numeric_zero();
}
gboolean
xaccAccountHasStockSplit (const Account *acc)
{
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), false);
return GET_PRIVATE(acc)->has_stock_split;
}
/********************************************************************\
\********************************************************************/
+4
View File
@@ -648,6 +648,10 @@ typedef enum
gnc_numeric xaccAccountGetBalanceChangeForPeriod (
Account *acc, time64 date1, time64 date2, gboolean recurse);
/** Returns true if the account has a stock split,
* otherwise false. */
gboolean xaccAccountHasStockSplit (const Account *acc);
/** @} */
/** @name Account Children and Parents.
+1
View File
@@ -114,6 +114,7 @@ typedef struct AccountPrivate
gnc_numeric reconciled_balance;
gboolean balance_dirty; /* balances in splits incorrect */
gboolean has_stock_split; /* account includes a stock split */
std::vector<Split*> splits; /* list of split pointers */
GHashTable* splits_hash;