From 3b0c91bb577859761031ca251320fd10b496debc Mon Sep 17 00:00:00 2001 From: John Ralls Date: Fri, 10 Apr 2020 15:44:00 -0700 Subject: [PATCH] Show transaction value, not amount, for registers with subaccounts. If the register has subaccounts in different currencies and a transaction has splits in more than one, the transaction will incorrectly appear to be unbalanced if we total amounts because the balancing logic works on split values. --- gnucash/register/ledger-core/split-register-model.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c index 4abc2133eb..2d9f8ad3e1 100644 --- a/gnucash/register/ledger-core/split-register-model.c +++ b/gnucash/register/ledger-core/split-register-model.c @@ -1591,10 +1591,11 @@ gnc_split_register_get_mxfrm_help (VirtualLocation virt_loc, return g_strdup (help); } -/* Return the total amount of the transaction for splits of default account - * and all subaccounts of the register. */ +/* Return the total value in the register currency of the transaction + * for splits of default account and all subaccounts of the register. + */ static gnc_numeric -get_trans_total_amount_subaccounts (SplitRegister* reg, Transaction* trans) +get_trans_total_value_subaccounts (SplitRegister* reg, Transaction* trans) { GList* children, *child; Account* parent; @@ -1607,12 +1608,13 @@ get_trans_total_amount_subaccounts (SplitRegister* reg, Transaction* trans) has no account then we have no way of picking out the desired splits, return zero. */ return total; + children = gnc_account_get_descendants (parent); children = g_list_append (children, parent); for (child = children; child; child = child->next) { - total = gnc_numeric_add_fixed (total, xaccTransGetAccountAmount (trans, + total = gnc_numeric_add_fixed (total, xaccTransGetAccountValue (trans, child->data)); } @@ -1642,7 +1644,7 @@ gnc_split_register_get_tdebcred_entry (VirtualLocation virt_loc, { case GENERAL_JOURNAL: case INCOME_LEDGER: - total = get_trans_total_amount_subaccounts (reg, xaccSplitGetParent (split)); + total = get_trans_total_value_subaccounts (reg, xaccSplitGetParent (split)); break; default: total = get_trans_total_amount (reg, xaccSplitGetParent (split));