gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Apr 10 18:48:47 EDT 2020
Updated via https://github.com/Gnucash/gnucash/commit/3b0c91bb (commit)
via https://github.com/Gnucash/gnucash/commit/aac3ea69 (commit)
from https://github.com/Gnucash/gnucash/commit/642885a1 (commit)
commit 3b0c91bb577859761031ca251320fd10b496debc
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Apr 10 15:44:00 2020 -0700
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.
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 4abc2133e..2d9f8ad3e 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));
commit aac3ea69092119d462e1eee2e1ed49da7332cd7c
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Apr 10 14:05:48 2020 -0700
Bug 797676 - Register displays amount in transaction currency...
instead of register currency.
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 8f3bb21a8..4abc2133e 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -1879,10 +1879,6 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
}
else
{
- /* If this account is not a stock/mutual/currency account, and
- * currency != the account commodity, then use the SplitAmount
- * instead of the SplitValue.
- */
gboolean currency_match;
switch (reg->type)
{
@@ -1893,10 +1889,21 @@ gnc_split_register_get_debcred_entry (VirtualLocation virt_loc,
print_info = gnc_commodity_print_info (currency, reg->mismatched_commodities);
break;
+ /* If the register is not a stock/fund register that
+ * displays both amount and value, display the split value
+ * in the register's currency instead of the transaction's
+ * currency. Note that we don't want the split amount as
+ * some splits will be in a different currency.
+ */
default:
- amount = xaccSplitGetValue (split);
+ if (commodity && !gnc_commodity_equal (commodity, currency))
+ /* Convert this to the "local" value */
+ amount = xaccSplitConvertAmount(split, account);
+ else
+ amount = xaccSplitGetValue (split);
+
print_info = gnc_account_print_info (account, reg->mismatched_commodities);
- print_info.commodity = currency;
+ print_info.commodity = commodity;
break;
}
}
Summary of changes:
.../register/ledger-core/split-register-model.c | 31 ++++++++++++++--------
1 file changed, 20 insertions(+), 11 deletions(-)
More information about the gnucash-changes
mailing list