Skip to content

Commit

Permalink
Warn and don't try to balance a transaction with a too-small imbalance.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jralls committed Sep 30, 2024
1 parent 5c5b627 commit 78ef5be
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gnucash/register/ledger-core/split-register-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 78ef5be

Please sign in to comment.