42 #include "TransactionP.hpp" 50 static QofLogModule log_module = GNC_MOD_LOT;
67 for (
auto split : xaccAccountGetSplits (acc))
70 if (split->lot)
continue;
107 LEAVE (
"Lot Closed (lot=%s, acc=%s)", gnc_lot_get_title(lot),
111 split = pcy->PolicyGetSplit (pcy, lot);
114 LEAVE (
"No Split (lot=%s, acc=%s)", gnc_lot_get_title(lot),
123 LEAVE (
"Voided transaction (lot=%s, acc=%s)",
137 if (subsplit == split)
139 PERR (
"Accounting Policy gave us a split that " 140 "doesn't fit into this lot\n" 141 "lot baln=%s, isclosed=%d, aplit amt=%s",
150 split = pcy->PolicyGetSplit (pcy, lot);
162 gnc_commodity *currency =
nullptr;
165 gnc_numeric zero = gnc_numeric_zero();
166 gnc_numeric value = zero;
170 ENTER (
"lot=%s", gnc_lot_get_title(lot));
174 Split *s = GNC_SPLIT(snode->data);
181 LEAVE (
"lot=%s is closed", gnc_lot_get_title(lot));
187 Split *s = GNC_SPLIT(snode->data);
188 Transaction *trans = s->parent;
191 if (
nullptr == currency)
193 currency = trans->common_currency;
199 PWARN (
"Lot with multiple currencies:\n" 208 PINFO (
"Split=%p value=%s Accum Lot value=%s", s,
222 PERR (
"Closed lot fails to double-balance !! lot value=%s",
226 Split *s = GNC_SPLIT(node->data);
227 PERR (
"s=%p amt=%s val=%s", s,
233 LEAVE (
"lot=%s", gnc_lot_get_title(lot));
238 static inline gboolean
239 is_subsplit (Split *split)
243 if (!split)
return FALSE;
244 g_return_val_if_fail (split->parent, FALSE);
260 remove_guids (Split *sa, Split *sb)
272 merge_splits (Split *sa, Split *sb)
276 gnc_numeric amt, val;
285 remove_guids (sa, sb);
301 if ((sb->gains_split) &&
302 (sb->gains_split->gains & GAINS_STATUS_GAINS))
304 Transaction *t = sb->gains_split->parent;
325 if (strict && (FALSE == is_subsplit (split)))
return FALSE;
335 ENTER (
"(Lot=%s)", gnc_lot_get_title(lot));
337 for (node = txn->splits; node; node = node->next)
339 Split *s = GNC_SPLIT(node->data);
341 if (s == split)
continue;
362 merge_splits (split, s);
370 PWARN (
"Result of merge has zero amt!");
374 LEAVE (
" splits merged=%d", rc);
384 if (!lot)
return FALSE;
390 Split *s = GNC_SPLIT(node->data);
396 LEAVE (
" splits merged=%d", rc);
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
This is the private header for the account structure.
gboolean gnc_numeric_equal(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b represent the same number.
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.
time64 xaccTransGetDate(const Transaction *trans)
Retrieve the posted date of the transaction.
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.
gboolean xaccSplitDestroy(Split *split)
Destructor.
Utilities to Convert Stock Accounts to use Lots.
gboolean qof_instance_get_destroying(gconstpointer ptr)
Retrieve the flag that indicates whether or not this object is about to be destroyed.
void xaccSplitComputeCapGains(Split *split, Account *gain_acc)
The xaccSplitComputeCapGains() routine computes the cap gains or losses for the indicated split...
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
Return a+b.
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 xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
Use any denominator which gives an exactly correct ratio of numerator to denominator.
void xaccSplitRemovePeerSplit(Split *split, const Split *other_split)
Remove a peer split from this split's lot-split list.
#define PERR(format, args...)
Log a serious error.
#define ENTER(format, args...)
Print a function entry debugging message.
GncInvoice * gncInvoiceGetInvoiceFromTxn(const Transaction *txn)
Given a transaction, find and return the Invoice.
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
#define PWARN(format, args...)
Log a warning.
gboolean xaccSplitHasPeers(const Split *split)
Does this split have peers?
void xaccSplitMergePeerSplits(Split *split, const Split *other_split)
Merge the other_split's peer splits into split's peers.
GList SplitList
GList of Split.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
Account handling public routines.
Account public routines (C++ api)
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.
gboolean xaccSplitIsPeerSplit(const Split *split, const Split *other_split)
Report if a split is a peer of this one.
const char * xaccTransGetDescription(const Transaction *trans)
Gets the transaction Description.
const char * gnc_commodity_get_fullname(const gnc_commodity *cm)
Retrieve the full name for the specified commodity.
gboolean xaccScrubMergeSubSplits(Split *split, gboolean strict)
The xaccScrubMergeSubSplits() routine will merge together all of the splits that were at one time spl...
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
All type declarations for the whole Gnucash engine.
Business Invoice Interface.
Split * xaccSplitAssignToLot(Split *split, GNCLot *lot)
The xaccSplitAssignToLot() routine will fit the indicated split into the indicated lot...
gboolean xaccTransGetVoidStatus(const Transaction *trans)
Retrieve information on whether or not a transaction has been voided.
gboolean xaccSplitAssign(Split *split)
The`xaccSplitAssign() routine will take the indicated split and, if it doesn't already belong to a lo...
gboolean gnc_lot_is_closed(GNCLot *lot)
Returns closed status of the given lot.
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
#define LEAVE(format, args...)
Print a function exit debugging message.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Account * gnc_lot_get_account(const GNCLot *lot)
Returns the account with which this lot is associated.
char * gnc_ctime(const time64 *secs)
Return a string representation of a date from a 64-bit time value.
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
#define GNC_DENOM_AUTO
Values that can be passed as the 'denom' argument.
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.
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.
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...
#define NREC
not reconciled or cleared
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.