Skip to content

Commit

Permalink
Remove rebalance cruft.
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3339 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
jdavisp3 committed Dec 22, 2000
1 parent 1e3fd8b commit 2230fbb
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 205 deletions.
24 changes: 12 additions & 12 deletions src/SplitLedger.c
Expand Up @@ -1085,7 +1085,7 @@ LedgerAutoCompletion(SplitRegister *reg, gncTableTraversalDir dir,
if (auto_trans == NULL)
return FALSE;

xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
gnc_copy_trans_onto_trans (auto_trans, trans, FALSE, FALSE);

if (info->default_source_account != NULL)
Expand Down Expand Up @@ -1517,7 +1517,7 @@ LedgerDestroy (SplitRegister *reg)
pending_trans = NULL;
}

xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);

Expand Down Expand Up @@ -1900,7 +1900,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)

new_split = xaccMallocSplit();

xaccTransBeginEdit(trans, TRUE);
xaccTransBeginEdit(trans);
xaccTransAppendSplit(trans, new_split);
xaccTransCommitEdit(trans);

Expand Down Expand Up @@ -1930,7 +1930,7 @@ xaccSRDuplicateCurrent (SplitRegister *reg)

gnc_copy_trans_onto_trans(trans, new_trans, FALSE, TRUE);

xaccTransBeginEdit(new_trans, TRUE);
xaccTransBeginEdit(new_trans);
xaccTransSetDateSecs(new_trans, info->last_date_entered);
xaccTransCommitEdit(new_trans);

Expand Down Expand Up @@ -2153,7 +2153,7 @@ xaccSRPasteCurrent (SplitRegister *reg)
{ /* We are on a null split in an expanded transaction. */
split = xaccMallocSplit();

xaccTransBeginEdit(trans, TRUE);
xaccTransBeginEdit(trans);
xaccTransAppendSplit(trans, split);
xaccTransCommitEdit(trans);
}
Expand Down Expand Up @@ -2262,7 +2262,7 @@ xaccSRDeleteCurrentSplit (SplitRegister *reg)

account = xaccSplitGetAccount(split);

xaccTransBeginEdit(trans, TRUE);
xaccTransBeginEdit(trans);
xaccAccountBeginEdit(account);
xaccSplitDestroy(split);
xaccAccountCommitEdit(account);
Expand Down Expand Up @@ -2314,7 +2314,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)
pending_trans = NULL;
}

xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);

Expand All @@ -2332,7 +2332,7 @@ xaccSRDeleteCurrentTrans (SplitRegister *reg)

accounts = gnc_trans_prepend_account_list(trans, NULL);

xaccTransBeginEdit(trans, TRUE);
xaccTransBeginEdit(trans);
xaccTransDestroy(trans);
xaccTransCommitEdit(trans);

Expand Down Expand Up @@ -2384,7 +2384,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
pending_trans = NULL;
}

xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
xaccTransDestroy (trans);
xaccTransCommitEdit (trans);

Expand All @@ -2403,7 +2403,7 @@ xaccSREmptyCurrentTrans (SplitRegister *reg)
accounts = gnc_trans_prepend_account_list(trans, NULL);
splits = gnc_trans_prepend_split_list(trans, NULL);

xaccTransBeginEdit(trans, TRUE);
xaccTransBeginEdit(trans);
for (node = splits; node; node = node->next)
if (node->data != split)
xaccSplitDestroy(node->data);
Expand Down Expand Up @@ -2701,7 +2701,7 @@ xaccSRSaveRegEntry (SplitRegister *reg, gboolean do_commit)
if (pending_trans != trans) {
if (xaccTransIsOpen (pending_trans))
xaccTransCommitEdit (pending_trans);
xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
pending_trans = trans;
info->pending_trans_guid = *xaccTransGetGUID(trans);
}
Expand Down Expand Up @@ -4238,7 +4238,7 @@ xaccSRLoadRegister (SplitRegister *reg, GList * slist,

trans = xaccMallocTransaction ();

xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);
xaccTransSetDateSecs (trans, info->last_date_entered);
blank_split = xaccMallocSplit ();
xaccTransAppendSplit (trans, blank_split);
Expand Down
48 changes: 22 additions & 26 deletions src/doc/design/engine.texinfo
Expand Up @@ -29,6 +29,7 @@ be created as a shared library for use by other programs.
* Accounts::
* Account Groups::
* GNCBooks::
* Scrub::
@end menu


Expand All @@ -46,22 +47,19 @@ arbitrary data (@pxref{Key-Value Pair Frames}).
Transactions (@pxref{Transactions}) embody the notion of "double entry"
accounting. A Transaction consists of a date, a description, a number, a
list of one or more Splits, and a key-value frame. When double-entry
rules are properly enabled in the engine (they are settable with various
flags), the total value of the splits is forced to be zero. Note that
if there is just one split, its value must be zero; this is useful
because a zero-valued split can store a price (useful for e.g. tracking
stocks). If there are two splits, then the value of one must be
positive, the other negative: this denotes that one account is credited,
and another is debited by an equal amount. Positive Split values are
'debits' and negative Split values are 'credits'. Forcing the Splits to
'add up' to zero causes a double-entry accounting system to always
balance.

Through various flags, forced double-entry can be disabled; this is
often desirable for novice, home-oriented users. As an alternative, it
may be better to leave double-entry enabled, but credit all dangling
splits to some dummy account, and then simply not show that dummy
account to the user.
rules are enforced, the total value of the splits is zero. Note that if
there is just one split, its value must be zero for double-entry
accounting; this is useful because a zero-valued split can store a price
(useful for e.g. tracking stocks). If there are two splits, then the
value of one must be positive, the other negative: this denotes that one
account is credited, and another is debited by an equal amount. Positive
Split values are 'debits' and negative Split values are 'credits'.
Ensuring the Splits to 'add up' to zero causes a double-entry accounting
system to always balance.

The engine does not enforce double-entry accounting, but provides an API
to enable user-code to find unbalanced transactions and 'repair' them so
that they are in balance. @xref{Scrub}.

Note the sum of the values of Splits in a Transaction is always computed
with respect to a currency; thus splits can be balanced even when they
Expand Down Expand Up @@ -1256,8 +1254,7 @@ Set the share price of @var{split} to @var{price}.
@deftypefun void xaccSplitSetSharePriceAndAmount (Split * @var{split}, gnc_numeric @var{price}, gnc_numeric @var{amount})
Set both the share price and share quantity of @var{split}. This routine
is more efficent than calling @code{xaccSplitSetShareAmount} and
@code{xaccSplitSetSharePrice} in succesion, because the parent Transaction
is only rebalanced once. @xref{Transactions}.
@code{xaccSplitSetSharePrice} in succesion.
@end deftypefun

@deftypefun void xaccSplitSetValue (Split * @var{split}, gnc_numeric @var{value})
Expand Down Expand Up @@ -1371,14 +1368,9 @@ be freed, or by @code{xaccTransRollbackEdit()}, in which case all the
original Splits are put back into place.
@end deftypefun

@deftypefun void xaccTransBeginEdit (Transaction * @var{trans}, gboolean @var{defer})
@deftypefun void xaccTransBeginEdit (Transaction * @var{trans})
This method must be called before any changes are made to @var{trans} or
any of its component Splits. If this is not done, errors will result. If
@var{defer} is true, then the automated re-balancing of all Splits in
this transaction is deferred until the @code{xaccTransCommitEdit()}
call. This allows multiple splits to be edited, quantities modified,
with the whole system temporarily out of balance, up until the
Commit call is made when double-entry is once again enforced.
any of its component Splits. If this is not done, errors will result.
@end deftypefun

@deftypefun void xaccTransCommitEdit (Transaction * @var{trans})
Expand Down Expand Up @@ -1511,7 +1503,7 @@ Set the description field of @var{trans} to @var{desc}.
@tindex AccountGroup


@node GNCBooks, , Account Groups, Engine
@node GNCBooks, Scrub, Account Groups, Engine
@section GNCBooks
@tindex GNCBook

Expand Down Expand Up @@ -1647,3 +1639,7 @@ Commit all changes that have been made to the book.
Release the session lock. It will @emph{not} save the account group to
a file. Thus, this method acts as an "abort" or "rollback" primitive.
@end deftypefun


@node Scrub, , GNCBooks, Engine
@section Scrub
1 change: 1 addition & 0 deletions src/doc/design/gnucash-design.texinfo
Expand Up @@ -88,6 +88,7 @@ Engine
* Accounts::
* Account Groups::
* GNCBooks::
* Scrub::
Globally Unique Identifiers
Expand Down
2 changes: 1 addition & 1 deletion src/engine/Account.c
Expand Up @@ -146,7 +146,7 @@ xaccFreeAccount (Account *acc)
for(lp = acc->splits; lp; lp = lp->next) {
Split *s = (Split *) lp->data;
t = s->parent;
xaccTransBeginEdit (t, TRUE);
xaccTransBeginEdit (t);
xaccSplitDestroy (s);
xaccTransCommitEdit (t);
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/BackendP.h
Expand Up @@ -36,7 +36,7 @@ struct _backend
int (*book_end) (GNCBook *);
int (*account_begin_edit) (Backend *, Account *, int defer);
int (*account_commit_edit) (Backend *, Account *);
int (*trans_begin_edit) (Backend *, Transaction *, int defer);
int (*trans_begin_edit) (Backend *, Transaction *);
int (*trans_commit_edit) (Backend *, Transaction *new, Transaction *orig);
int (*trans_rollback_edit) (Backend *, Transaction *);
};
Expand Down
4 changes: 2 additions & 2 deletions src/engine/Scrub.c
Expand Up @@ -195,7 +195,7 @@ xaccSplitScrub (Split *split)
trans_was_open = xaccTransIsOpen (trans);

if (!trans_was_open)
xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);

xaccSplitSetShareAmount (split, xaccSplitGetValue (split));

Expand Down Expand Up @@ -303,7 +303,7 @@ xaccTransScrubImbalance (Transaction *trans)
trans_was_open = xaccTransIsOpen (trans);

if (!trans_was_open)
xaccTransBeginEdit (trans, TRUE);
xaccTransBeginEdit (trans);

common_currency = xaccTransFindCommonCurrency (trans);
account = xaccSplitGetAccount (balance_split);
Expand Down

0 comments on commit 2230fbb

Please sign in to comment.