budget totals for one period would be wrong when increasing the number of periods.

This commit is contained in:
BLR 2023-03-14 13:52:06 -04:00
parent f40e4118dc
commit 4cc766b07a

View File

@ -1547,6 +1547,12 @@ The function will step through to only display the columns that are set
void
gnc_budget_view_refresh (GncBudgetView *budget_view)
{
// Column identifiers
const gint GNC_BUDGET_VIEW_CODE_COL = 1;
const gint GNC_BUDGET_VIEW_DESC_COL = 2;
const gint GNC_BUDGET_VIEW_START_PERIODS_COL = 3;
// The Totals column will be after the periods columns.
GncBudgetViewPrivate *priv;
gint num_periods;
gint num_periods_visible;
@ -1589,13 +1595,13 @@ gnc_budget_view_refresh (GncBudgetView *budget_view)
// set visibility of the account code columns
code_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "account-code");
gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 1);
code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), GNC_BUDGET_VIEW_CODE_COL);
gtk_tree_view_column_set_visible (code_col, priv->show_account_code);
// set visibility of the account description columns
desc_col = gnc_tree_view_find_column_by_name (GNC_TREE_VIEW(priv->tree_view), "description");
gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), 2);
desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), GNC_BUDGET_VIEW_DESC_COL);
gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc);
/* If we're creating new columns to be appended to already existing
@ -1607,7 +1613,8 @@ gnc_budget_view_refresh (GncBudgetView *budget_view)
col = priv->total_col;
gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->tree_view), col);
priv->total_col = NULL;
col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), num_periods_visible + 1);
col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view),
GNC_BUDGET_VIEW_START_PERIODS_COL + num_periods_visible);
gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col);
}