Utilities to Automatically Compute Capital Gains/Losses. More...
|gboolean||xaccAccountHasTrades (const Account *acc)|
|GNCLot *||xaccAccountFindEarliestOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency)|
|GNCLot *||xaccAccountFindLatestOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency)|
|void||xaccAccountSetDefaultGainAccount (Account *acc, const Account *gain_acct)|
|Account *||xaccAccountGetDefaultGainAccount (const Account *acc, const gnc_commodity *currency)|
|Split *||xaccSplitAssignToLot (Split *split, GNCLot *lot)|
|gboolean||xaccSplitAssign (Split *split)|
|Split *||xaccSplitGetCapGainsSplit (const Split *split)|
|Split *||xaccSplitGetGainsSourceSplit (const Split *split)|
|void||xaccSplitComputeCapGains (Split *split, Account *gain_acc)|
|gnc_numeric||xaccSplitGetCapGains (Split *split)|
|void||xaccLotComputeCapGains (GNCLot *lot, Account *gain_acc)|
Utilities to Automatically Compute Capital Gains/Losses.
This file implements the various routines to automatically compute and handle Cap Gains/Losses resulting from trading activities. Some of these routines might have broader applicability, for handling depreciation & etc.
This code is under development, and is 'beta': we think we're mostly done, and we've tested and "things work for us", but there may still be something missing, and there might still be some bugs.
This code uses a 'gains dirty' flag: A 'dirty' flag on the source split indicates that the gains transaction needs to be recomputed. Another flag, the gains transaction flag, marks the split as being a gains split, and that the source transaction should be checked for dirtiness before returning the date, the amount, the value, etc. Finally, these flags make amount and value read-only for the gains splits. (the memo is user-modifieable).
If the amount in a split is changed, then the lot has to be recomputed. This has a potential trickle-through effect on all later lots. Ideally, later lots are dissolved, and recomputed. However, some lots may have been user-hand-built. These should be left alone.
ToDo: o XXX Need to create a data-integrity scrubber, tht makes sure that the various flags, and pointers & etc. match. See sections marked with XXX below for things that might go wrong.
Definition in file cap-gains.c.