gnucash stable: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Mon Sep 30 17:14:22 EDT 2024
Updated via https://github.com/Gnucash/gnucash/commit/78ef5be7 (commit)
via https://github.com/Gnucash/gnucash/commit/5c5b627c (commit)
from https://github.com/Gnucash/gnucash/commit/711554ec (commit)
commit 78ef5be7b2de12490781dac62a4698e761326e9e
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Sep 30 14:06:30 2024 -0700
Warn and don't try to balance a transaction with a too-small imbalance.
In a book using trading accounts, if the user sets an account's
minimum fraction to be smaller than the commodity's and makes use of
the extra fraction, GnuCash can't create a correct trading split
because that uses the commodity fraction. Instead of offering to
balance the transaction, put up an error dialog explaing that the
transaction can't be balanced.
Ref Bug 799432 (https://bugs.gnucash.org/show_bug.cgi?id=799423)
diff --git a/gnucash/register/ledger-core/split-register-control.cpp b/gnucash/register/ledger-core/split-register-control.cpp
index a44d264945..e213ec8928 100644
--- a/gnucash/register/ledger-core/split-register-control.cpp
+++ b/gnucash/register/ledger-core/split-register-control.cpp
@@ -43,6 +43,7 @@
#include "split-register.h"
#include "table-allgui.h"
#include "engine-helpers.h"
+#include <gnc-gui-query.h> //for gnc_error_dialog
/* This static indicates the debugging module that this .o belongs to. */
@@ -90,6 +91,12 @@ gnc_split_register_balance_trans (SplitRegister *reg, Transaction *trans)
multi_currency = FALSE;
else
multi_currency = TRUE;
+ if (multi_currency &&
+ imbal_mon->value.denom > gnc_commodity_get_fraction(imbal_mon->commodity))
+ {
+ gnc_error_dialog(gnc_ui_get_main_window(GTK_WIDGET(reg)), "%s", _("This transaction cannot be balanced: The imbalance is a fraction smaller than the commodity allows."));
+ return FALSE;
+ }
}
/* We're done with the imbalance list, the real work will be done
commit 5c5b627cb147ecc8f7816e66abf60bbaedb98ce7
Author: John Ralls <jralls at ceridwen.us>
Date: Mon Sep 30 12:49:52 2024 -0700
Bug 799423 - Crash when creating ETF transaction
Don't keep the old split if it's a trading split. The balance code
regenerates those, invalidating the pointer.
diff --git a/gnucash/register/ledger-core/split-register-control.cpp b/gnucash/register/ledger-core/split-register-control.cpp
index 1c38c7d3fe..a44d264945 100644
--- a/gnucash/register/ledger-core/split-register-control.cpp
+++ b/gnucash/register/ledger-core/split-register-control.cpp
@@ -364,6 +364,12 @@ gnc_split_register_check_account (SplitRegister *reg,
return TRUE;
}
+static inline bool
+is_trading_split (Split* split)
+{
+ return xaccAccountGetType (xaccSplitGetAccount (split)) == ACCT_TYPE_TRADING;
+}
+
static void
gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
gpointer user_data)
@@ -374,10 +380,10 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
Transaction *pending_trans;
Transaction *new_trans;
Transaction *old_trans;
- Split *old_trans_split;
+ Split *old_trans_split{nullptr};
Split *new_trans_split;
Split *new_split;
- Split *old_split;
+ Split *old_split{nullptr};
CursorClass new_class;
CursorClass old_class;
gboolean exact_traversal;
@@ -399,10 +405,13 @@ gnc_split_register_move_cursor (VirtualLocation *p_new_virt_loc,
info = gnc_split_register_get_info (reg);
/* The transaction we are coming from */
- old_split = gnc_split_register_get_current_split (reg);
+ if (auto s{gnc_split_register_get_current_split (reg)}; !is_trading_split(s))
+ old_split = s;
old_trans = gnc_split_register_get_current_trans (reg);
- old_trans_split =
- gnc_split_register_get_current_trans_split (reg, &old_trans_split_loc);
+ if (auto s{gnc_split_register_get_current_trans_split (reg, &old_trans_split_loc)};
+ is_trading_split(s))
+ old_trans_split = s;
+
old_class = gnc_split_register_get_current_cursor_class (reg);
exact_traversal = info->exact_traversal;
Summary of changes:
.../ledger-core/split-register-control.cpp | 26 +++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
More information about the gnucash-changes
mailing list