GnuCash
2.6.99
|
Files | |
file | Scrub.h |
convert single-entry accounts to clean double-entry | |
file | Scrub2.h |
Utilities to Convert Stock Accounts to use Lots. | |
file | Scrub3.h |
High-Level API for imposing Lot constraints. | |
file | ScrubBusiness.h |
Cleanup functions for business objects. | |
Double-Entry Scrubbing | |
Convert single-entry accounts to clean double-entry Provides a set of functions and utilities for checking and repairing (formerly called 'scrubbing clean') single-entry accounts so that they can be promoted into self-consistent, clean double-entry accounts. Basically and additionally, this file collects all functions that turn old (deprecated) data structures into the current new data model. The ScrubOrphans() methods search for transacations that contain splits that do not have a parent account. These "orphaned splits" are placed into an "orphan account" which the user will have to go into and clean up. Kind of like the unix "Lost+Found" directory for orphaned inodes. | |
void | xaccTransScrubOrphans (Transaction *trans) |
void | xaccAccountScrubOrphans (Account *acc) |
void | xaccAccountTreeScrubOrphans (Account *acc) |
void | xaccSplitScrub (Split *split) |
void | xaccTransScrubSplits (Transaction *trans) |
void | xaccAccountScrubSplits (Account *account) |
void | xaccAccountTreeScrubSplits (Account *account) |
void | xaccTransScrubImbalance (Transaction *trans, Account *root, Account *parent) |
void | xaccAccountScrubImbalance (Account *acc) |
void | xaccAccountTreeScrubImbalance (Account *acc) |
void | xaccTransScrubCurrency (Transaction *trans) |
void | xaccAccountScrubCommodity (Account *account) |
void | xaccAccountTreeScrubCommodities (Account *acc) |
void | xaccAccountTreeScrubQuoteSources (Account *root, gnc_commodity_table *table) |
void | xaccAccountScrubKvp (Account *account) |
Lot Management Routines | |
Provides the low-level API for checking and repairing ('scrubbing clean') the usage of Lots and lot balances in stock and commodity accounts. Broken lots are repaired using a first-in, first-out (FIFO) accounting schedule. This is a 'low-level' API in the sense that each routine accomplishes only one particular task needed to clean up a Lot. To clean up a Lot as a whole, you almost certainly want to use one of the high-level API routines from the Scrub3.h file. | |
void | xaccAccountAssignLots (Account *acc) |
void | xaccLotFill (GNCLot *lot) |
void | xaccLotScrubDoubleBalance (GNCLot *lot) |
gboolean | xaccScrubMergeSubSplits (Split *split, gboolean strict) |
gboolean | xaccScrubMergeLotSubSplits (GNCLot *lot, gboolean strict) |
High-Level Lot Constraint | |
Provides the high-level API for checking and repairing ('scrubbing clean') the usage of Lots and Cap Gains transactions in stock and commodity accounts. | |
gboolean | xaccScrubLot (GNCLot *lot) |
void | xaccAccountScrubLots (Account *acc) |
void | xaccAccountTreeScrubLots (Account *acc) |
Cleanup functions for business objects | |
Provides the high-level API for checking and repairing ('scrubbing clean') the various data objects used by the business functions. | |
gboolean | gncScrubBusinessLot (GNCLot *lot) |
void | gncScrubBusinessAccountLots (Account *acc) |
void | gncScrubBusinessAccountTreeLots (Account *acc) |
Data scrubbing, repairing and forward migration routines. These routines check and repair data, making sure that it is in a format that the current version of the GnuCash Engine likes. These routines serve both to provide backwards compatibility with older versions of GnuCash, and to fix or at least paper over possible current problems.
It is typically expected that the scrub routines are run over newly imported data, as well as during data file input.
In some cases, it is entirely appropriate to invoke these routines from the GUI, to validate that the user input through the GUI is in a format that the system likes. This includes things like balancing individual transactions, or assigning splits to lots, so that capital gains can be computed.
void gncScrubBusinessAccountLots | ( | Account * | acc | ) |
The gncScrubBusinessAccountLots() function will call gncScrubBusinessLot() on each lot in the given account.
This routine is the primary routine for ensuring that the lot structure of every lot of a business account is in good order.
Definition at line 294 of file ScrubBusiness.c.
void gncScrubBusinessAccountTreeLots | ( | Account * | acc | ) |
The gncScrubBusinessAccountTreeLots() function will call gncScrubBusinessAccountLots() on each lot in the given account and its sub accounts.
This routine is the primary routine for ensuring that the lot structure of every lot of a business account is in good order.
Definition at line 325 of file ScrubBusiness.c.
gboolean gncScrubBusinessLot | ( | GNCLot * | lot | ) |
The gncScrubBusinessLot() function makes sure that the indicated lot has all the correct properties required for a lot used in the business features.
Currently this function only does one thing: eliminate lot link transactions between invoice lots and payment lots (which were generated by GnuCash versions 2.6.0-2.6.3). Lot links between invoices and credit notes will still remain.
Scrubbing the lot may cause subsplits to be merged together, i.e. for splits to be deleted. This routine returns true if any splits were modified or deleted.
Definition at line 256 of file ScrubBusiness.c.
void xaccAccountAssignLots | ( | Account * | acc | ) |
The xaccAccountAssignLots() routine will walk over all of the splits in an account, and make sure that each belongs to a lot. Currently, the default (and only implemented) assignment policy is a FIFO policy: Any splits that are not in a lot will be used to close the oldest open lot(s). If there are no open lots, a new lot will be started. By trying to close the oldest lots, this effectively implements a FIFO accounting policy.
Loop over all splits, and make sure that every split belongs to some lot. If a split does not belong to any lots, poke it into one.
Definition at line 58 of file Scrub2.c.
void xaccAccountScrubCommodity | ( | Account * | account | ) |
The xaccAccountScrubCommodity method fixed accounts without a commodity by using the old account currency and security.
Definition at line 1110 of file Scrub.c.
void xaccAccountScrubLots | ( | Account * | acc | ) |
The xaccAccountScrubLots() routine makes sure that every split in the account is assigned to a lot, and that then, every lot is self-consistent (by calling xaccScrubLot() on each lot).
This routine is the primary routine for ensuring that the lot structure, and the cap-gains for an account are in good order.
Most GUI routines will want to use one of these xacc[*]ScrubLots() routines, instead of the various component routines, since it will usually makes sense to work only with these high-level routines.
Definition at line 159 of file Scrub3.c.
void xaccAccountScrubOrphans | ( | Account * | acc | ) |
The xaccAccountScrubOrphans() method performs this scrub only for the indicated account, and not for any of its children.
Definition at line 102 of file Scrub.c.
void xaccAccountTreeScrubCommodities | ( | Account * | acc | ) |
The xaccAccountTreeScrubCommodities will scrub the currency/commodity of all accounts & transactions in the specified account or any child account.
Definition at line 1174 of file Scrub.c.
void xaccAccountTreeScrubOrphans | ( | Account * | acc | ) |
The xaccAccountTreeScrubOrphans() method performs this scrub for the indicated account and its children.
Definition at line 62 of file Scrub.c.
void xaccAccountTreeScrubQuoteSources | ( | Account * | root, |
gnc_commodity_table * | table | ||
) |
This routine will migrate the information about price quote sources from the account data structures to the commodity data structures. It first checks to see if this is necessary since, for the time being, the quote information will still be written out as part of the account. Just in case anyone needs to fall back from CVS to a production version of code.
root | A pointer to the root account containing all accounts in the current book. |
table | A pointer to the commodity table for the current book. |
Definition at line 1231 of file Scrub.c.
void xaccLotFill | ( | GNCLot * | lot | ) |
The xaccLotFill() routine attempts to assign splits to the indicated lot until the lot balance goes to zero, or until there are no suitable (i.e. unassigned) splits left in the account. It uses the default accounting policy to choose the splits to fill out the lot.
Definition at line 96 of file Scrub2.c.
void xaccLotScrubDoubleBalance | ( | GNCLot * | lot | ) |
The xaccLotScrubDoubleBalance() routine examines the indicated lot. If it is open, it does nothing. If it is closed, it then verifies that the lot is 'double balanced'. By 'double balance', we mean that both the sum of the split amounts is zero, and that the sum of the split values is zero. If the lot is closed and the sum of the values is not zero, the lot is considered to have a 'realized gain or loss' that hadn't been correctly handled. This routine then creates a balancing transaction to so as to record the realized gain/loss, adds it to the lot, and adds it to a gain/loss account. If there is no default gain/loss account, it creates one.
Definition at line 164 of file Scrub2.c.
gboolean xaccScrubLot | ( | GNCLot * | lot | ) |
The xaccScrubLot() routine makes sure that the indicated lot is self-consistent and properly balanced, and fixes it if its not. This is an important routine to call if the amount of any split in the lot is changed. That's because (obviously) changing split values is guaranteed to throw off lot balances. This routine may end up closing the lot, or at least trying to. It will also cause cap gains to be recomputed.
Scrubbing the lot may cause subsplits to be merged together, i.e. for splits to be deleted. This routine returns true if any splits were deleted.
Definition at line 85 of file Scrub3.c.
gboolean xaccScrubMergeLotSubSplits | ( | GNCLot * | lot, |
gboolean | strict | ||
) |
The xaccScrubMergeLotSubSplits() routine does the same as the xaccScrubMergSubSplits, except that it does it for all of the splits in the lot.
Definition at line 398 of file Scrub2.c.
gboolean xaccScrubMergeSubSplits | ( | Split * | split, |
gboolean | strict | ||
) |
The xaccScrubMergeSubSplits() routine will merge together all of the splits that were at one time split off from this split, but are no longer needed to be kept separate. Splits might be split up if they need to be divided over multiple lots; they can be merged back together if the lots change. In particular, two sub-splits may be merged if they are in the same lot, or in no lot. Note that, by definition, all subsplits belong to the same transaction.
There are two ways to find matching subsplits. The first way will consider splits to be subsplits only if they are explicitly marked as such while splitting the original split. Set strict to TRUE for this matching algorhythm.
The second way is more relaxed. It will consider any two splits that happen to be part of the same lot and the same transaction to be subsplits. Set strict to FALSE for this matching algorhythm.
The routine returns TRUE if a merger was performed, else it returns FALSE.
Definition at line 347 of file Scrub2.c.
void xaccSplitScrub | ( | Split * | split | ) |
The xaccSplitScrub method ensures that if this split has the same commodity and currency, then it will have the same amount and value. If the commodity is the currency, the split->amount is set to the split value. In addition, if this split is an orphan, that is fixed first. If the split account doesn't have a commodity declared, an attempt is made to fix that first.
Definition at line 176 of file Scrub.c.
void xaccTransScrubCurrency | ( | Transaction * | trans | ) |
The xaccTransScrubCurrency method fixes transactions without a common_currency by looking for the most commonly used currency among all the splits in the transaction. If this fails it falls back to using the old account currency and security fields of the parent accounts of the transaction's splits.
Definition at line 993 of file Scrub.c.
void xaccTransScrubImbalance | ( | Transaction * | trans, |
Account * | root, | ||
Account * | parent | ||
) |
The xaccScrubImbalance() method searches for transactions that do not balance to zero. If any such transactions are found, a split is created to offset this amount and is added to an "imbalance" account.
Definition at line 521 of file Scrub.c.
void xaccTransScrubOrphans | ( | Transaction * | trans | ) |
The xaccTransScrubOrphans() method scrubs only the splits in the given transaction.
Definition at line 124 of file Scrub.c.
void xaccTransScrubSplits | ( | Transaction * | trans | ) |
The xacc*ScrubSplits() calls xaccSplitScrub() on each split in the respective structure: transaction, account, account & it's children, account-group.
Definition at line 2616 of file Transaction.c.