42#include "TransactionP.hpp"
50static QofLogModule log_module = GNC_MOD_LOT;
67 for (
auto split : xaccAccountGetSplits (acc))
70 if (split->lot)
continue;
110 LEAVE (
"Lot Closed (lot=%s, acc=%s)", gnc_lot_get_title(lot),
114 split = pcy->PolicyGetSplit (pcy, lot);
117 LEAVE (
"No Split (lot=%s, acc=%s)", gnc_lot_get_title(lot),
125 LEAVE (
"Stock split transaction (lot=%s, acc=%s)",
134 LEAVE (
"Voided transaction (lot=%s, acc=%s)",
148 if (subsplit == split)
150 PERR (
"Accounting Policy gave us a split that "
151 "doesn't fit into this lot\n"
152 "lot baln=%s, isclosed=%d, aplit amt=%s",
161 split = pcy->PolicyGetSplit (pcy, lot);
173 gnc_commodity *currency =
nullptr;
176 gnc_numeric zero = gnc_numeric_zero();
177 gnc_numeric value = zero;
181 ENTER (
"lot=%s", gnc_lot_get_title(lot));
185 Split *s = GNC_SPLIT(snode->data);
192 LEAVE (
"lot=%s is closed", gnc_lot_get_title(lot));
198 Split *s = GNC_SPLIT(snode->data);
199 Transaction *trans = s->parent;
202 if (
nullptr == currency)
204 currency = trans->common_currency;
210 PWARN (
"Lot with multiple currencies:\n"
219 PINFO (
"Split=%p value=%s Accum Lot value=%s", s,
233 PERR (
"Closed lot fails to double-balance !! lot value=%s",
237 Split *s = GNC_SPLIT(node->data);
238 PERR (
"s=%p amt=%s val=%s", s,
244 LEAVE (
"lot=%s", gnc_lot_get_title(lot));
249static inline gboolean
250is_subsplit (Split *split)
254 if (!split)
return FALSE;
255 g_return_val_if_fail (split->parent, FALSE);
271remove_guids (Split *sa, Split *sb)
283merge_splits (Split *sa, Split *sb)
287 gnc_numeric amt, val;
296 remove_guids (sa, sb);
312 if ((sb->gains_split) &&
313 (sb->gains_split->gains & GAINS_STATUS_GAINS))
315 Transaction *t = sb->gains_split->parent;
336 if (strict && (FALSE == is_subsplit (split)))
return FALSE;
346 ENTER (
"(Lot=%s)", gnc_lot_get_title(lot));
348 for (node = txn->splits; node; node = node->next)
350 Split *s = GNC_SPLIT(node->data);
352 if (s == split)
continue;
373 merge_splits (split, s);
381 PWARN (
"Result of merge has zero amt!");
385 LEAVE (
" splits merged=%d", rc);
395 if (!lot)
return FALSE;
401 Split *s = GNC_SPLIT(node->data);
407 LEAVE (
" splits merged=%d", rc);
This is the private header for the account structure.
Account handling public routines.
Account public routines (C++ api)
Utilities to Convert Stock Accounts to use Lots.
API for Transactions and Splits (journal entries)
Utilities to Automatically Compute Capital Gains/Losses.
All type declarations for the whole Gnucash engine.
Business Invoice Interface.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
GNCPolicy * gnc_account_get_policy(Account *acc)
Get the account's lot order policy.
Split * xaccSplitAssignToLot(Split *split, GNCLot *lot)
The xaccSplitAssignToLot() routine will fit the indicated split into the indicated lot,...
gboolean xaccSplitAssign(Split *split)
The`xaccSplitAssign() routine will take the indicated split and, if it doesn't already belong to a lo...
void xaccSplitComputeCapGains(Split *split, Account *gain_acc)
The xaccSplitComputeCapGains() routine computes the cap gains or losses for the indicated split.
gboolean gnc_commodity_equiv(const gnc_commodity *a, const gnc_commodity *b)
This routine returns TRUE if the two commodities are equivalent.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
char * gnc_ctime(const time64 *secs)
Return a string representation of a date from a 64-bit time value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
gboolean xaccTransGetVoidStatus(const Transaction *trans)
Retrieve information on whether or not a transaction has been voided.
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
GList SplitList
GList of Split.
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
GncInvoice * gncInvoiceGetInvoiceFromTxn(const Transaction *txn)
Given a transaction, find and return the Invoice.
#define PINFO(format, args...)
Print an informational note.
#define LEAVE(format, args...)
Print a function exit debugging message.
#define PERR(format, args...)
Log a serious error.
#define PWARN(format, args...)
Log a warning.
#define ENTER(format, args...)
Print a function entry debugging message.
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
gnc_numeric gnc_lot_get_balance(GNCLot *lot)
Returns the lot balance.
SplitList * gnc_lot_get_split_list(const GNCLot *lot)
Returns a list of all the splits in this lot.
gboolean gnc_lot_is_closed(GNCLot *lot)
Returns closed status of the given lot.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
gboolean gnc_numeric_zero_p(gnc_numeric a)
Returns 1 if the given gnc_numeric is 0 (zero), else returns 0.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
gchar * gnc_num_dbg_to_string(gnc_numeric n)
Convert to string.
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
@ GNC_HOW_DENOM_EXACT
Use any denominator which gives an exactly correct ratio of numerator to denominator.
void xaccAccountAssignLots(Account *acc)
Loop over all splits, and make sure that every split belongs to some lot.
gboolean xaccScrubMergeSubSplits(Split *split, gboolean strict)
The xaccScrubMergeSubSplits() routine will merge together all of the splits that were at one time spl...
void xaccLotFill(GNCLot *lot)
The xaccLotFill() routine attempts to assign splits to the indicated lot until the lot balance goes t...
gboolean xaccScrubMergeLotSubSplits(GNCLot *lot, gboolean strict)
The xaccScrubMergeLotSubSplits() routine does the same as the xaccScrubMergSubSplits,...
void xaccLotScrubDoubleBalance(GNCLot *lot)
The xaccLotScrubDoubleBalance() routine examines the indicated lot.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
gboolean xaccSplitDestroy(Split *split)
Destructor.
void xaccSplitMergePeerSplits(Split *split, const Split *other_split)
Merge the other_split's peer splits into split's peers.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
void xaccSplitRemovePeerSplit(Split *split, const Split *other_split)
Remove a peer split from this split's lot-split list.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
GNCLot * xaccSplitGetLot(const Split *split)
Returns the pointer to the debited/credited Lot where this split belongs to, or NULL if it doesn't be...
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
gboolean xaccSplitHasPeers(const Split *split)
Does this split have peers?
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
#define NREC
not reconciled or cleared
gboolean xaccSplitIsPeerSplit(const Split *split, const Split *other_split)
Report if a split is a peer of this one.
gboolean xaccSplitIsStockSplit(Split *s)
Returns true if the split is of type stock split.
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
Implement Accounting Policy Private header File.