From 4cc766b07a4c5a886f632f44eac9ec19778ec467 Mon Sep 17 00:00:00 2001 From: BLR Date: Tue, 14 Mar 2023 13:52:06 -0400 Subject: [PATCH 1/2] budget totals for one period would be wrong when increasing the number of periods. --- gnucash/gnome/gnc-budget-view.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c index 9089640976..b69baa7112 100644 --- a/gnucash/gnome/gnc-budget-view.c +++ b/gnucash/gnome/gnc-budget-view.c @@ -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); } From 372a36eeb92605628cf52652be7110dbf52c6e54 Mon Sep 17 00:00:00 2001 From: BLR Date: Fri, 17 Mar 2023 09:13:47 -0400 Subject: [PATCH 2/2] 798570 Budget totals for income, expenses and remaining to budget incorrect when increasing the number of periods. --- gnucash/gnome/gnc-budget-view.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c index b69baa7112..789841b86a 100644 --- a/gnucash/gnome/gnc-budget-view.c +++ b/gnucash/gnome/gnc-budget-view.c @@ -1547,11 +1547,13 @@ 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. + // Column identifiers + enum { + code_column = 1, + description_column = 2, + startPeriods_column = 3 + // The Totals column will be after the periods columns. + }; GncBudgetViewPrivate *priv; gint num_periods; @@ -1595,13 +1597,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), GNC_BUDGET_VIEW_CODE_COL); + code_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), code_column); 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), GNC_BUDGET_VIEW_DESC_COL); + desc_col = gtk_tree_view_get_column (GTK_TREE_VIEW(priv->totals_tree_view), description_column); gtk_tree_view_column_set_visible (desc_col, priv->show_account_desc); /* If we're creating new columns to be appended to already existing @@ -1614,7 +1616,7 @@ gnc_budget_view_refresh (GncBudgetView *budget_view) 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), - GNC_BUDGET_VIEW_START_PERIODS_COL + num_periods_visible); + startPeriods_column + num_periods_visible); gtk_tree_view_remove_column (GTK_TREE_VIEW(priv->totals_tree_view), col); }