From 42a22eef0f4ae9aed4d83c391e65fa5b761e729d Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Thu, 6 Jan 2022 22:08:49 +0800 Subject: [PATCH] [gnc-budget-view.c] gbv_get_accumulated_budget_amount returns unreversed amount Previously it would return an appropriately signed amount for display. However it is also used when accumulating amounts therefore needs to be sign-reversed again. This function will now return, for the particular account and period, an unreversed accumulated budget amount. The sign reversal now takes place only for display using xaccSPrintAmount in #L1112 --- gnucash/gnome/gnc-budget-view.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gnucash/gnome/gnc-budget-view.c b/gnucash/gnome/gnc-budget-view.c index cbabb810e04..49b8f4eccfd 100644 --- a/gnucash/gnome/gnc-budget-view.c +++ b/gnucash/gnome/gnc-budget-view.c @@ -1042,9 +1042,6 @@ budget_accum_helper (Account *account, gpointer data) info->pdb, numeric, currency, info->total_currency, gnc_budget_get_period_start_date (info->budget, info->period_num)); - if (gnc_reverse_balance (account)) - numeric = gnc_numeric_neg (numeric); - info->total = gnc_numeric_add (info->total, numeric, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD); } @@ -1070,9 +1067,6 @@ gbv_get_accumulated_budget_amount (GncBudget *budget, Account *account, guint pe else info.total = gnc_budget_get_account_period_value (budget, account, period_num); - if (gnc_reverse_balance (account)) - info.total = gnc_numeric_neg (info.total); - return info.total; } @@ -1111,6 +1105,10 @@ budget_col_source (Account *account, GtkTreeViewColumn *col, gtk_style_context_get_color (stylectxt, GTK_STATE_FLAG_NORMAL, &color); numeric = gbv_get_accumulated_budget_amount (priv->budget, account, period_num); + + if (gnc_reverse_balance (account)) + numeric = gnc_numeric_neg (numeric); + xaccSPrintAmount (amtbuff, numeric, gnc_account_print_info (account, FALSE)); if (gnc_is_dark_theme (&color)) g_object_set (cell, "foreground", @@ -1186,9 +1184,6 @@ bgv_get_total_for_account (Account *account, GncBudget *budget, gnc_commodity *n { numeric = gbv_get_accumulated_budget_amount (budget, account, period_num); - if (gnc_reverse_balance (account)) - numeric = gnc_numeric_neg (numeric); - if (new_currency) { numeric = gnc_pricedb_convert_balance_nearest_price_t64 (