Dave Peticolas
Tue, 21 Nov 2000 02:44:31 -0800

Transaction Rebalancing

Right now, the engine rebalances transactions whenever they
are commited, and sometimes during transaction modification.

The engine rebalances transactions by computing the amount
of the imbalance, selecting an essentially arbitrary split,
and modifying its value so that the transaction is in balance.

The purpose of engine rebalancing is to keep all transactions
in balance, regardless of what the user code does. However, this
scheme suffers from two problems:

1. Confusion -- from the user's point of view, the split which
                gets modified is random. This makes using the
                register for multi-split transactions very
                confusing at times.

2. Correctness -- imbalance isn't really an engine problem, it's
                  a user problem. The engine can't really be
                  expected to 'do the right thing' since it has
                  no way of knowing what that is. Just putting
                  the transaction into balance probably isn't
                  solving the underlying problem, it's just
                  hiding it.


1. Rebalancing should work by computing the imbalance, and then
   modifying a specially designated 'imbalance' split to bring
   the transaction into balance. If the imbalance split does not
   exist one will be created. If it does exist and its value
   should be zero for balance, the imbalance split will be

2. Rebalancing should only occur when user code requests it, not
   automatically. For convenience, the xaccTransCommitEdit() api
   should be extended with a flag to ask for rebalancing, but
   user code can elect not to rebalance.

3. The gui should visually identify imbalance splits, and allow
   the user to bring up a list of unbalanced transactions.