GnuCash c935c2f+
Loading...
Searching...
No Matches
Split.h
Go to the documentation of this file.
1/********************************************************************\
2 * This program is free software; you can redistribute it and/or *
3 * modify it under the terms of the GNU General Public License as *
4 * published by the Free Software Foundation; either version 2 of *
5 * the License, or (at your option) any later version. *
6 * *
7 * This program is distributed in the hope that it will be useful, *
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10 * GNU General Public License for more details. *
11 * *
12 * You should have received a copy of the GNU General Public License*
13 * along with this program; if not, contact: *
14 * *
15 * Free Software Foundation Voice: +1-617-542-5942 *
16 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17 * Boston, MA 02110-1301, USA gnu@gnu.org *
18 * *
19\********************************************************************/
34#ifndef XACC_SPLIT_H
35#define XACC_SPLIT_H
36
37typedef struct _SplitClass SplitClass;
38
39#include <time.h>
40
41#include "gnc-commodity.h"
42#include "gnc-engine.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* --- type macros --- */
49#define GNC_TYPE_SPLIT (gnc_split_get_type ())
50#define GNC_SPLIT(o) \
51 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, Split))
52#define GNC_SPLIT_CLASS(k) \
53 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, SplitClass))
54#define GNC_IS_SPLIT(o) \
55 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT))
56#define GNC_IS_SPLIT_CLASS(k) \
57 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT))
58#define GNC_SPLIT_GET_CLASS(o) \
59 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, SplitClass))
60GType gnc_split_get_type(void);
61
62
73#define CREC 'c'
74#define YREC 'y'
75#define FREC 'f'
76#define NREC 'n'
77#define VREC 'v'
80/* Convert the amount/value of the Split for viewing in the account --
81 * in particular we want to convert the Split to be in to_commodity.
82 * Returns the amount.
83 */
84gnc_numeric xaccSplitConvertAmount (const Split *split, const Account * account);
85
86/*-----------------------------------------------------------------------
87 * Splits
88 *-----------------------------------------------------------------------*/
89
95Split * xaccMallocSplit (QofBook *book);
96
97/* Reinit a previously malloc'd split. Split remains in the book it
98 was already in, and the QofInstance portions also remain unchanged.
99 It's basically the data elements that are reverted to default
100 values. */
101void xaccSplitReinit(Split * split);
102
121gboolean xaccSplitDestroy (Split *split);
122
123/*################## Added for Reg2 #################*/
131void xaccSplitCopyOnto(const Split *from_split, Split *to_split);
132/*################## Added for Reg2 #################*/
133
136QofBook * xaccSplitGetBook (const Split *split);
137
140Account * xaccSplitGetAccount (const Split *split);
141void xaccSplitSetAccount (Split *s, Account *acc);
142
144Transaction * xaccSplitGetParent (const Split *split);
145void xaccSplitSetParent (Split *split, Transaction *trans);
146
149GNCLot * xaccSplitGetLot (const Split *split);
150
152void xaccSplitSetLot(Split* split, GNCLot* lot);
153
158void xaccSplitSetMemo (Split *split, const char *memo);
159
161const char * xaccSplitGetMemo (const Split *split);
162
172void xaccSplitSetOnlineID (Split *split, const char *id);
173
177const char * xaccSplitGetOnlineID (const Split *split);
178
180gboolean xaccSplitHasOnlineID (const Split *split);
181
193void xaccSplitSetAction (Split *split, const char *action);
194
200const char * xaccSplitGetAction (const Split *split);
209void xaccSplitSetReconcile (Split *split, char reconciled_flag);
211char xaccSplitGetReconcile (const Split *split);
212
215void xaccSplitSetDateReconciledSecs (Split *split, time64 time);
216
217/*################## Added for Reg2 #################*/
219time64 xaccSplitGetDateReconciled (const Split *split);
220/*################## Added for Reg2 #################*/
221
251void xaccSplitSetAmount (Split *split, gnc_numeric amount);
252
257gnc_numeric xaccSplitGetAmount (const Split * split);
258
265void xaccSplitSetValue (Split *split, gnc_numeric value);
266
271gnc_numeric xaccSplitGetValue (const Split * split);
272
278void xaccSplitSetSharePriceAndAmount (Split *split,
279 gnc_numeric price,
280 gnc_numeric amount);
281
285gnc_numeric xaccSplitGetSharePrice (const Split * split);
286
300void xaccSplitSetBaseValue (Split *split, gnc_numeric value,
301 const gnc_commodity * base_currency);
302
309gnc_numeric xaccSplitGetBaseValue (const Split *split,
310 const gnc_commodity * base_currency);
311
319gnc_numeric xaccSplitGetBalance (const Split *split);
320
328gnc_numeric xaccSplitGetNoclosingBalance (const Split *split);
329
337gnc_numeric xaccSplitGetClearedBalance (const Split *split);
338
346gnc_numeric xaccSplitGetReconciledBalance (const Split *split);
347
351void xaccSplitSetAdjustedAmount (Split *split, gnc_numeric amount);
352
355gnc_numeric xaccSplitGetAdjustedAmount (const Split *split);
356
357
381gboolean xaccSplitEqual(const Split *sa, const Split *sb,
382 gboolean check_guids,
383 gboolean check_balances,
384 gboolean check_txn_splits);
385
389Split * xaccSplitLookup (const GncGUID *guid, QofBook *book);
390#define xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b)
391
396void xaccSplitAddPeerSplit (Split *split, const Split *other_split,
397 const time64 timestamp);
400gboolean xaccSplitHasPeers (const Split *split);
405gboolean xaccSplitIsPeerSplit (const Split *split, const Split *other_split);
409void xaccSplitRemovePeerSplit (Split *split, const Split *other_split);
410
414void xaccSplitMergePeerSplits (Split *split, const Split *other_split);
415
421Split * xaccSplitGetOtherSplit (const Split *split);
422
425const char *xaccSplitGetType(Split *s);
426
429void xaccSplitMakeStockSplit(Split *s);
430
433gboolean xaccSplitIsStockSplit(Split *s);
434
447gint xaccSplitOrder (const Split *sa, const Split *sb);
448gint xaccSplitOrderDateOnly (const Split *sa, const Split *sb);
449
450
451/*
452 * These functions compare two splits by different criteria.
453 *
454 * These functions were added because converting strings to guile
455 * for comparisons in the transaction report is terribly inefficient.
456 * More may be added here in future if it turns out that other types
457 * of comparisons also induces guile slowdowns.
458 */
459
462int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb);
465int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb);
469int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb);
473int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb);
474
475
492char * xaccSplitGetCorrAccountFullName(const Split *sa);
494const char * xaccSplitGetCorrAccountName(const Split *sa);
496const char * xaccSplitGetCorrAccountCode(const Split *sa);
497
498#ifdef DUMP_FUNCTIONS
499void xaccSplitDump (const Split *split, const char *tag);
500#endif
501
512void xaccSplitSetSharePrice (Split *split, gnc_numeric price);
513
517/********************************************************************\
518 * Miscellaneous utility routines.
519\********************************************************************/
520
521
533gnc_numeric xaccSplitVoidFormerAmount(const Split *split);
534
542gnc_numeric xaccSplitVoidFormerValue(const Split *split);
543
555#define SPLIT_DATE_RECONCILED "date-reconciled"
556#define SPLIT_BALANCE "balance"
557#define SPLIT_CLEARED_BALANCE "cleared-balance"
558#define SPLIT_RECONCILED_BALANCE "reconciled-balance"
559#define SPLIT_MEMO "memo"
560#define SPLIT_ACTION "action"
561#define SPLIT_RECONCILE "reconcile-flag"
562#define SPLIT_AMOUNT "amount"
563#define SPLIT_SHARE_PRICE "share-price"
564#define SPLIT_VALUE "value"
565#define SPLIT_TYPE "type"
566#define SPLIT_VOIDED_AMOUNT "voided-amount"
567#define SPLIT_VOIDED_VALUE "voided-value"
568#define SPLIT_LOT "lot"
569#define SPLIT_TRANS "trans"
570#define SPLIT_ACCOUNT "account"
571#define SPLIT_ACCOUNT_GUID "account-guid"
572/* used for SORTING ONLY */
573#define SPLIT_ACCT_FULLNAME "acct-fullname"
574#define SPLIT_CORR_ACCT_NAME "corr-acct-fullname"
575#define SPLIT_CORR_ACCT_CODE "corr-acct-code"
579#define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
580
581#ifdef __cplusplus
582} /* extern "C" */
583#endif
584
585#endif /* XACC_SPLIT_H */
Commodity handling public routines.
All type declarations for the whole Gnucash engine.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb)
Compare two splits by code of account.
Definition Split.cpp:1712
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
void xaccSplitSetAdjustedAmount(Split *split, gnc_numeric amount)
Sets the stock split adjusted amount of a split.
Definition Split.cpp:1346
void xaccSplitSetReconcile(Split *split, char reconciled_flag)
Set the reconcile flag.
gboolean xaccSplitDestroy(Split *split)
Destructor.
Definition Split.cpp:1506
char xaccSplitGetReconcile(const Split *split)
Returns the value of the reconcile flag.
gnc_numeric xaccSplitGetClearedBalance(const Split *split)
The cleared-balance is the currency-denominated balance of all transactions that have been marked as ...
Definition Split.cpp:1328
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb)
Compare two splits by full name of the other account.
Definition Split.cpp:1726
void xaccSplitSetSharePrice(Split *split, gnc_numeric price)
Definition Split.cpp:1205
gint xaccSplitOrder(const Split *sa, const Split *sb)
The xaccSplitOrder(sa,sb) method is useful for sorting.
Definition Split.cpp:1536
void xaccSplitMergePeerSplits(Split *split, const Split *other_split)
Merge the other_split's peer splits into split's peers.
Definition Split.cpp:2138
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
The xaccSplitLookup() subroutine will return the split associated with the given id,...
Definition Split.cpp:1091
void xaccSplitSetValue(Split *split, gnc_numeric value)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
const char * xaccSplitGetCorrAccountName(const Split *sa)
document me
Definition Split.cpp:1638
void xaccSplitRemovePeerSplit(Split *split, const Split *other_split)
Remove a peer split from this split's lot-split list.
Definition Split.cpp:2121
Split * xaccMallocSplit(QofBook *book)
Constructor.
gnc_numeric xaccSplitGetNoclosingBalance(const Split *split)
The noclosing-balance is the currency-denominated balance of all transactions except 'closing' transa...
Definition Split.cpp:1322
void xaccSplitSetAmount(Split *split, gnc_numeric amount)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
const char * xaccSplitGetAction(const Split *split)
Returns the action string.
const char * xaccSplitGetType(Split *s)
Returns the split type, which is either the string "normal", or "stock-split" for a split from a stoc...
Definition Split.cpp:2039
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...
Definition Split.cpp:1920
char * xaccSplitGetCorrAccountFullName(const Split *sa)
These functions take a split, get the corresponding split on the "other side" of the transaction,...
Definition Split.cpp:1655
time64 xaccSplitGetDateReconciled(const Split *split)
Retrieve the date when the Split was reconciled.
Definition Split.cpp:1859
gnc_numeric xaccSplitVoidFormerValue(const Split *split)
Returns the original pre-void value of a split.
Definition Split.cpp:2199
gnc_numeric xaccSplitGetValue(const Split *split)
Returns the value of this split in the transaction's commodity.
void xaccSplitSetLot(Split *split, GNCLot *lot)
Assigns the split to a specific Lot.
Definition Split.cpp:1926
gnc_numeric xaccSplitGetSharePrice(const Split *split)
Returns the price of the split, that is, the value divided by the amount.
Definition Split.cpp:1995
const char * xaccSplitGetCorrAccountCode(const Split *sa)
document me
Definition Split.cpp:1671
int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb)
Compare two splits by full name of account.
Definition Split.cpp:1688
gnc_numeric xaccSplitGetReconciledBalance(const Split *split)
Returns the reconciled-balance of this split.
Definition Split.cpp:1334
gboolean xaccSplitEqual(const Split *sa, const Split *sb, gboolean check_guids, gboolean check_balances, gboolean check_txn_splits)
Equality.
Definition Split.cpp:819
gboolean xaccSplitHasPeers(const Split *split)
Does this split have peers?
Definition Split.cpp:2102
Account * xaccSplitGetAccount(const Split *split)
Returns the account of this split, which was set through xaccAccountInsertSplit().
int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb)
Compare two splits by code of the other account.
Definition Split.cpp:1747
void xaccSplitCopyOnto(const Split *from_split, Split *to_split)
This is really a helper for xaccTransCopyOnto.
Definition Split.cpp:648
void xaccSplitSetSharePriceAndAmount(Split *split, gnc_numeric price, gnc_numeric amount)
The xaccSplitSetSharePriceAndAmount() method will simultaneously update the share price and the numbe...
Definition Split.cpp:1177
const char * xaccSplitGetMemo(const Split *split)
Returns the memo string.
void xaccSplitSetDateReconciledSecs(Split *split, time64 time)
Set the date on which this split was reconciled by specifying the time as time64.
gnc_numeric xaccSplitVoidFormerAmount(const Split *split)
Returns the original pre-void amount of a split.
Definition Split.cpp:2191
void xaccSplitSetOnlineID(Split *split, const char *id)
The online_id is the OFX/HBCI "FITID" recorded on a split when it is imported.
void xaccSplitSetBaseValue(Split *split, gnc_numeric value, const gnc_commodity *base_currency)
Depending on the base_currency, set either the value or the amount of this split or both: If the base...
Definition Split.cpp:1355
gnc_numeric xaccSplitGetBaseValue(const Split *split, const gnc_commodity *base_currency)
Depending on the base_currency, return either the value or the amount of this split: If the base_curr...
Definition Split.cpp:1410
const char * xaccSplitGetOnlineID(const Split *split)
Returns the split's online_id.
Split * xaccSplitGetOtherSplit(const Split *split)
The xaccSplitGetOtherSplit() is a convenience routine that returns the other of a pair of splits.
QofBook * xaccSplitGetBook(const Split *split)
Returns the book of this split, i.e.
gnc_numeric xaccSplitGetAdjustedAmount(const Split *split)
Returns the stock-split adjusted amount of the split in the account's commodity.
Definition Split.cpp:1340
void xaccSplitAddPeerSplit(Split *split, const Split *other_split, const time64 timestamp)
Add a peer split to this split's lot-split list.
Definition Split.cpp:2084
gnc_numeric xaccSplitGetBalance(const Split *split)
Returns the running balance up to and including the indicated split.
Definition Split.cpp:1316
gboolean xaccSplitIsPeerSplit(const Split *split, const Split *other_split)
Report if a split is a peer of this one.
Definition Split.cpp:2108
void xaccSplitSetAction(Split *split, const char *action)
The Action is an arbitrary user-assigned string.
Definition Split.cpp:1786
gboolean xaccSplitIsStockSplit(Split *s)
Returns true if the split is of type stock split.
Definition Split.cpp:2078
gnc_numeric xaccSplitGetAmount(const Split *split)
Returns the amount of the split in the account's commodity.
void xaccSplitMakeStockSplit(Split *s)
Mark a split to be of type stock split - after this, you shouldn't modify the value anymore,...
Definition Split.cpp:2063
gboolean xaccSplitHasOnlineID(const Split *split)
Returns TRUE if the split has a non-empty online_id.
Definition Split.cpp:1963
STRUCTS.
The type used to store guids in C.
Definition guid.h:75
QofBook reference.
Definition qofbook-p.hpp:47