GnuCash
2.6.99
|
Utilities to Automatically Compute Capital Gains/Losses. More...
#include "config.h"
#include <glib.h>
#include <glib/gi18n.h>
#include "AccountP.h"
#include "Scrub2.h"
#include "Scrub3.h"
#include "Transaction.h"
#include "TransactionP.h"
#include "cap-gains.h"
#include "gnc-engine.h"
#include "engine-helpers.h"
#include "gnc-lot.h"
#include "policy.h"
#include "policy-p.h"
Go to the source code of this file.
Data Structures | |
struct | find_lot_s |
Functions | |
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) |
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.