Skip to content

Commit

Permalink
[gnc-budget-view.c] gbv_get_accumulated_budget_amount returns unrever…
Browse files Browse the repository at this point in the history
…sed 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
  • Loading branch information
christopherlam committed Jan 6, 2022
1 parent 5603acb commit 42a22ee
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions gnucash/gnome/gnc-budget-view.c
Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit 42a22ee

Please sign in to comment.