mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-10-24 23:27:39 -05:00
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:
1 parent
ff30f4438b
commit
31978c1b4d
4 files changed
+32
-1
No files matched your search
@@ -116,6 +116,7 @@ struct _GNCLotViewer
|
||||
GtkButton * add_split_to_lot_button;
|
||||
GtkButton * remove_split_from_lot_button;
|
||||
GtkToggleButton * only_show_open_lots_checkbutton;
|
||||
GtkToggleButton * show_adjusted_amounts_checkbutton;
|
||||
|
||||
Account * account;
|
||||
GNCLot * selected_lot;
|
||||
@@ -503,6 +504,7 @@ gnc_split_viewer_fill (GNCLotViewer *lv, GtkListStore *store, SplitList *split_l
|
||||
SplitList *node;
|
||||
GtkTreeIter iter;
|
||||
gboolean is_business_lot = FALSE;
|
||||
gboolean show_adjusted_amounts = gtk_toggle_button_get_active (lv->show_adjusted_amounts_checkbutton);
|
||||
gnc_numeric baln = gnc_numeric_zero ();
|
||||
|
||||
if (lv->selected_lot)
|
||||
@@ -612,11 +614,22 @@ lv_update_split_buttons (GNCLotViewer *lv)
|
||||
}
|
||||
}
|
||||
|
||||
static void lv_refresh (GNCLotViewer * lv)
|
||||
|
||||
static void set_adjusted_ammounts_checkbutton_visibility (GNCLotViewer *lv)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET(lv->show_adjusted_amounts_checkbutton);
|
||||
gboolean has_stock_split = xaccAccountHasStockSplit (lv->account);
|
||||
|
||||
gtk_widget_set_visible (widget, has_stock_split);
|
||||
gtk_widget_set_no_show_all (widget, !has_stock_split);
|
||||
}
|
||||
|
||||
static void lv_refresh (GNCLotViewer *lv)
|
||||
{
|
||||
gnc_lot_viewer_fill (lv);
|
||||
lv_show_splits_free (lv);
|
||||
lv_show_splits_in_lot (lv);
|
||||
set_adjusted_ammounts_checkbutton_visibility (lv);
|
||||
}
|
||||
|
||||
/* ======================================================================== */
|
||||
@@ -1110,6 +1123,7 @@ lv_create (GNCLotViewer *lv, GtkWindow *parent)
|
||||
|
||||
lv->show_adjusted_amounts_checkbutton = GTK_TOGGLE_BUTTON(gtk_builder_get_object (builder, "show_adjusted_amounts_checkbutton"));
|
||||
g_signal_connect (lv->show_adjusted_amounts_checkbutton, "toggled", G_CALLBACK(lv_show_adjusted_amounts_changed_cb), lv);
|
||||
set_adjusted_ammounts_checkbutton_visibility (lv);
|
||||
|
||||
lv->lot_view = GTK_TREE_VIEW(gtk_builder_get_object (builder, "lot_view"));
|
||||
lv_init_lot_view (lv);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user