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)
This commit is contained in:
John Ralls 2024-09-30 14:06:30 -07:00
parent 5c5b627cb1
commit 78ef5be7b2

View File

@ -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