Split.h

Go to the documentation of this file.
00001 /********************************************************************\
00002  * This program is free software; you can redistribute it and/or    *
00003  * modify it under the terms of the GNU General Public License as   *
00004  * published by the Free Software Foundation; either version 2 of   *
00005  * the License, or (at your option) any later version.              *
00006  *                                                                  *
00007  * This program is distributed in the hope that it will be useful,  *
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00010  * GNU General Public License for more details.                     *
00011  *                                                                  *
00012  * You should have received a copy of the GNU General Public License*
00013  * along with this program; if not, contact:                        *
00014  *                                                                  *
00015  * Free Software Foundation           Voice:  +1-617-542-5942       *
00016  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00017  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00018  *                                                                  *
00019 \********************************************************************/
00034 #ifndef XACC_SPLIT_H
00035 #define XACC_SPLIT_H
00036 
00037 typedef struct _SplitClass SplitClass;
00038 
00039 #include <time.h>
00040 
00041 #include "gnc-commodity.h"
00042 #include "gnc-engine.h"
00043 
00044 /* --- type macros --- */
00045 #define GNC_TYPE_SPLIT            (gnc_split_get_type ())
00046 #define GNC_SPLIT(o)              \
00047      (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SPLIT, Split))
00048 #define GNC_SPLIT_CLASS(k)        \
00049      (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SPLIT, SplitClass))
00050 #define GNC_IS_SPLIT(o)           \
00051      (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SPLIT))
00052 #define GNC_IS_SPLIT_CLASS(k)     \
00053      (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SPLIT))
00054 #define GNC_SPLIT_GET_CLASS(o)    \
00055      (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SPLIT, SplitClass))
00056 GType gnc_split_get_type(void);
00057 
00058 
00067 #define CREC 'c'              
00068 #define YREC 'y'              
00069 #define FREC 'f'              
00070 #define NREC 'n'              
00071 #define VREC 'v'              
00074 /* Convert the amount/value of the Split for viewing in the account --
00075  * in particular we want to convert the Split to be in to_commodity.
00076  * Returns the amount.
00077  */
00078 gnc_numeric xaccSplitConvertAmount (const Split *split, Account * account);
00079 
00080 /*-----------------------------------------------------------------------
00081  * Splits
00082  *-----------------------------------------------------------------------*/
00083 
00089 Split       * xaccMallocSplit (QofBook *book);
00090 
00091 /* Reinit a previously malloc'd split. Split remains in the book it
00092    was already in, and the QofInstance portions also remain unchanged.
00093    It's basically the data elements that are reverted to default
00094    values. */
00095 void xaccSplitReinit(Split * split);
00096 
00114 gboolean      xaccSplitDestroy (Split *split);
00115 
00118 QofBook *   xaccSplitGetBook (const Split *split);
00119 
00122 Account *     xaccSplitGetAccount (const Split *split);
00123 void xaccSplitSetAccount (Split *s, Account *acc);
00124 
00126 Transaction * xaccSplitGetParent (const Split *split);
00127 void xaccSplitSetParent (Split *split, Transaction *trans);
00128 
00131 GNCLot *      xaccSplitGetLot (const Split *split);
00132 
00134 void xaccSplitSetLot(Split* split, GNCLot* lot);
00135 
00136 
00143 KvpFrame *xaccSplitGetSlots(const Split *split);
00144 
00147 void xaccSplitSetSlots_nc(Split *s, KvpFrame *frm);
00148 
00149 
00154 void          xaccSplitSetMemo (Split *split, const char *memo);
00155 
00157 const char *  xaccSplitGetMemo (const Split *split);
00158 
00165 void          xaccSplitSetAction (Split *split, const char *action);
00166 
00168 const char *  xaccSplitGetAction (const Split *split);
00177 void          xaccSplitSetReconcile (Split *split, char reconciled_flag);
00179 char          xaccSplitGetReconcile (const Split *split);
00180 
00183 void          xaccSplitSetDateReconciledSecs (Split *split, time_t time);
00186 void          xaccSplitSetDateReconciledTS (Split *split, Timespec *ts);
00189 void          xaccSplitGetDateReconciledTS (const Split *split, 
00190                                             Timespec *ts);
00192 Timespec      xaccSplitRetDateReconciledTS (const Split *split);
00193 
00223 void         xaccSplitSetAmount (Split *split, gnc_numeric amount);
00224 
00229 gnc_numeric   xaccSplitGetAmount (const Split * split);
00230 
00237 void         xaccSplitSetValue (Split *split, gnc_numeric value);
00238 
00243 gnc_numeric   xaccSplitGetValue (const Split * split);
00244 
00250 void         xaccSplitSetSharePriceAndAmount (Split *split, 
00251                                               gnc_numeric price,
00252                                               gnc_numeric amount);
00253 
00257 gnc_numeric   xaccSplitGetSharePrice (const Split * split);
00258 
00272 void         xaccSplitSetBaseValue (Split *split, gnc_numeric value,
00273                                     const gnc_commodity * base_currency);
00274 
00281 gnc_numeric xaccSplitGetBaseValue (const Split *split, 
00282                                    const gnc_commodity * base_currency);
00283 
00291 gnc_numeric xaccSplitGetBalance (const Split *split);
00292 
00300 gnc_numeric xaccSplitGetClearedBalance (const Split *split);
00301 
00309 gnc_numeric xaccSplitGetReconciledBalance (const Split *split);
00310 
00317 /* Get a GList of unique transactions containing the given list of Splits. */
00318 GList *xaccSplitListGetUniqueTransactions(const GList *splits);
00319 
00337 gboolean xaccSplitEqual(const Split *sa, const Split *sb,
00338                         gboolean check_guids,
00339                         gboolean check_balances,
00340                         gboolean check_txn_splits);
00341 
00345 Split      * xaccSplitLookup (const GUID *guid, QofBook *book);
00346 #define      xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b)
00347 
00348 
00354 Split * xaccSplitGetOtherSplit (const Split *split);
00355 
00360 gboolean xaccIsPeerSplit (const Split *split_1, const Split *split_2);
00361 
00364 const char *xaccSplitGetType(const Split *s);
00365 
00368 void xaccSplitMakeStockSplit(Split *s);
00369 
00382 gint xaccSplitOrder (const Split *sa, const Split *sb);
00383 gint xaccSplitOrderDateOnly (const Split *sa, const Split *sb);
00384 
00385 
00386 /*
00387  * These functions compare two splits by different criteria.   
00388  *
00389  * These functions were added because converting strings to guile 
00390  * for comparisons in the transaction report is terribly inefficient.
00391  * More may be added here in future if it turns out that other types
00392  * of comparisons also induces guile slowdowns.
00393  */
00394 
00397 int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb);
00400 int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb);
00404 int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb);
00408 int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb);
00409 
00410 
00421 char * xaccSplitGetCorrAccountFullName(const Split *sa);
00423 const char * xaccSplitGetCorrAccountName(const Split *sa);
00425 const char * xaccSplitGetCorrAccountCode(const Split *sa);
00426 
00437 void         xaccSplitSetSharePrice (Split *split, gnc_numeric price);
00438 
00442 /********************************************************************\
00443  * Miscellaneous utility routines.
00444 \********************************************************************/
00445 
00446 
00458 gnc_numeric xaccSplitVoidFormerAmount(const Split *split);
00459 
00467 gnc_numeric xaccSplitVoidFormerValue(const Split *split);
00468 
00480 #define SPLIT_KVP               "kvp"
00481 
00482 #define SPLIT_DATE_RECONCILED   "date-reconciled"
00483 #define SPLIT_BALANCE           "balance"
00484 #define SPLIT_CLEARED_BALANCE   "cleared-balance"
00485 #define SPLIT_RECONCILED_BALANCE        "reconciled-balance"
00486 #define SPLIT_MEMO              "memo"
00487 #define SPLIT_ACTION            "action"
00488 #define SPLIT_RECONCILE         "reconcile-flag"
00489 #define SPLIT_AMOUNT            "amount"
00490 #define SPLIT_SHARE_PRICE       "share-price"
00491 #define SPLIT_VALUE             "value"
00492 #define SPLIT_TYPE              "type"
00493 #define SPLIT_VOIDED_AMOUNT     "voided-amount"
00494 #define SPLIT_VOIDED_VALUE      "voided-value"
00495 #define SPLIT_LOT               "lot"
00496 #define SPLIT_TRANS             "trans"
00497 #define SPLIT_ACCOUNT           "account"
00498 #define SPLIT_ACCOUNT_GUID      "account-guid" 
00499 /* used for SORTING ONLY */
00500 #define SPLIT_ACCT_FULLNAME     "acct-fullname"
00501 #define SPLIT_CORR_ACCT_NAME    "corr-acct-fullname"
00502 #define SPLIT_CORR_ACCT_CODE    "corr-acct-code"
00503 
00506 #define xaccSplitGetGUID(X)      qof_entity_get_guid(QOF_INSTANCE(X))
00507 
00508 #define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
00509 
00510 #endif /* XACC_SPLIT_H */
00511 

Generated on Sun Sep 7 05:07:41 2008 for GnuCash by  doxygen 1.5.2