46 #include "TransactionP.hpp" 48 static QofLogModule log_module = GNC_MOD_LOT;
58 static inline gboolean
59 gains_possible (GNCLot *lot)
65 gnc_commodity *acc_commodity;
70 if (!node)
return FALSE;
71 split = GNC_SPLIT(node->data);
75 return (FALSE == comeq);
87 gboolean splits_deleted = FALSE;
89 gboolean opening_baln_is_pos, lot_baln_is_pos;
93 if (!lot)
return FALSE;
94 ENTER (
"(lot=%p) %s", lot, gnc_lot_get_title(lot));
104 gnc_lot_get_title(lot));
108 gnc_numeric opening_baln;
111 pcy->PolicyGetLotOpening (pcy, lot, &opening_baln,
nullptr,
nullptr);
118 if ((opening_baln_is_pos || lot_baln_is_pos) &&
119 ((!opening_baln_is_pos) || (!lot_baln_is_pos)))
124 Split *s = GNC_SPLIT(node->data);
125 if (pcy->PolicyIsOpeningSplit (pcy, lot, s))
continue;
145 if (gains_possible (lot))
147 xaccLotComputeCapGains (lot,
nullptr);
152 LEAVE (
"(lot=%s, deleted=%d)", gnc_lot_get_title(lot), splits_deleted);
153 return splits_deleted;
170 for (node = lots; node; node = node->next)
172 GNCLot *lot = GNC_LOT(node->data);
183 lot_scrub_cb (
Account *acc, gpointer data)
190 xaccAccountTreeScrubLots (
Account *acc)
194 gnc_account_foreach_descendant(acc, lot_scrub_cb,
nullptr);
This is the private header for the account structure.
High-Level API for imposing Lot constraints.
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.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
GList LotList
GList of GNCLots.
void xaccLotFill(GNCLot *lot)
The xaccLotFill() routine attempts to assign splits to the indicated lot until the lot balance goes t...
#define PINFO(format, args...)
Print an informational note.
Utilities to Convert Stock Accounts to use Lots.
gboolean xaccAccountHasTrades(const Account *acc)
The xaccAccountHasTrades() method checks to see if the indicated account is used in the trading of co...
void xaccAccountAssignLots(Account *acc)
Loop over all splits, and make sure that every split belongs to some lot.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
void xaccAccountScrubLots(Account *acc)
The xaccAccountScrubLots() routine makes sure that every split in the account is assigned to a lot...
#define ENTER(format, args...)
Print a function entry debugging message.
GList SplitList
GList of Split.
Account handling public routines.
Implement Accounting Policy Private header File.
SplitList * gnc_lot_get_split_list(const GNCLot *lot)
Returns a list of all the splits in this lot.
void xaccLotScrubDoubleBalance(GNCLot *lot)
The xaccLotScrubDoubleBalance() routine examines the indicated lot.
LotList * xaccAccountGetLotList(const Account *acc)
The xaccAccountGetLotList() routine returns a list of all lots in this account.
void gnc_lot_remove_split(GNCLot *lot, Split *split)
Adds a split from this lot.
All type declarations for the whole Gnucash engine.
gboolean gnc_numeric_positive_p(gnc_numeric a)
Returns 1 if a > 0, otherwise returns 0.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
#define LEAVE(format, args...)
Print a function exit debugging message.
gboolean xaccScrubLot(GNCLot *lot)
The xaccScrubLot() routine makes sure that the indicated lot is self-consistent and properly balanced...
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
API for Transactions and Splits (journal entries)
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
Utilities to Automatically Compute Capital Gains/Losses.
Commodity handling public routines.
GNCPolicy * gnc_account_get_policy(Account *acc)
Get the account's lot order policy.
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
gnc_numeric gnc_lot_get_balance(GNCLot *lot)
Returns the lot balance.