GnuCash
5.6-17-gfafc745b1b+
|
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) |
The xaccAccountHasTrades() method checks to see if the indicated account is used in the trading of commodities. More... | |
GNCLot * | xaccAccountFindEarliestOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency) |
The xaccAccountFindEarliestOpenLot() method is a handy utility routine for finding the earliest open lot in an account whose lot balance is opposite to the passed argument 'sign'. More... | |
GNCLot * | xaccAccountFindLatestOpenLot (Account *acc, gnc_numeric sign, gnc_commodity *currency) |
Split * | xaccSplitAssignToLot (Split *split, GNCLot *lot) |
The xaccSplitAssignToLot() routine will fit the indicated split into the indicated lot, with the goal of closing the lot, or at least bringing the lot balance closer to closure. More... | |
gboolean | xaccSplitAssign (Split *split) |
The`xaccSplitAssign() routine will take the indicated split and, if it doesn't already belong to a lot, it will attempt to assign it to an appropriate lot. More... | |
Split * | xaccSplitGetCapGainsSplit (const Split *split) |
The xaccSplitGetCapGainsSplit() routine returns the split that records the cap gains for this split. More... | |
Split * | xaccSplitGetGainsSourceSplit (const Split *split) |
The xaccSplitGetGainsSourceSplit() routine returns the split that is the source of the cap gains in this split. More... | |
void | xaccSplitComputeCapGains (Split *split, Account *gain_acc) |
The xaccSplitComputeCapGains() routine computes the cap gains or losses for the indicated split. More... | |
gnc_numeric | xaccSplitGetCapGains (Split *split) |
The xaccSplitGetCapGains() method returns the value of capital gains (if any) associated with the indicated split. More... | |
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, that 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.