|
GnuCash 2.4.99
|
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, const 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 00334 gboolean xaccSplitEqual(const Split *sa, const Split *sb, 00335 gboolean check_guids, 00336 gboolean check_balances, 00337 gboolean check_txn_splits); 00338 00342 Split * xaccSplitLookup (const GncGUID *guid, QofBook *book); 00343 #define xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b) 00344 00345 00351 Split * xaccSplitGetOtherSplit (const Split *split); 00352 00361 const char *xaccSplitGetType(const Split *s); 00362 00365 void xaccSplitMakeStockSplit(Split *s); 00366 00379 gint xaccSplitOrder (const Split *sa, const Split *sb); 00380 gint xaccSplitOrderDateOnly (const Split *sa, const Split *sb); 00381 00382 00383 /* 00384 * These functions compare two splits by different criteria. 00385 * 00386 * These functions were added because converting strings to guile 00387 * for comparisons in the transaction report is terribly inefficient. 00388 * More may be added here in future if it turns out that other types 00389 * of comparisons also induces guile slowdowns. 00390 */ 00391 00394 int xaccSplitCompareAccountFullNames(const Split *sa, const Split *sb); 00397 int xaccSplitCompareAccountCodes(const Split *sa, const Split *sb); 00401 int xaccSplitCompareOtherAccountFullNames(const Split *sa, const Split *sb); 00405 int xaccSplitCompareOtherAccountCodes(const Split *sa, const Split *sb); 00406 00407 00418 char * xaccSplitGetCorrAccountFullName(const Split *sa); 00420 const char * xaccSplitGetCorrAccountName(const Split *sa); 00422 const char * xaccSplitGetCorrAccountCode(const Split *sa); 00423 00424 #ifdef DUMP_FUNCTIONS 00425 void xaccSplitDump (const Split *split, const char *tag); 00426 #endif 00427 00438 void xaccSplitSetSharePrice (Split *split, gnc_numeric price); 00439 00443 /********************************************************************\ 00444 * Miscellaneous utility routines. 00445 \********************************************************************/ 00446 00447 00459 gnc_numeric xaccSplitVoidFormerAmount(const Split *split); 00460 00468 gnc_numeric xaccSplitVoidFormerValue(const Split *split); 00469 00481 #define SPLIT_KVP "kvp" 00482 00483 #define SPLIT_DATE_RECONCILED "date-reconciled" 00484 #define SPLIT_BALANCE "balance" 00485 #define SPLIT_CLEARED_BALANCE "cleared-balance" 00486 #define SPLIT_RECONCILED_BALANCE "reconciled-balance" 00487 #define SPLIT_MEMO "memo" 00488 #define SPLIT_ACTION "action" 00489 #define SPLIT_RECONCILE "reconcile-flag" 00490 #define SPLIT_AMOUNT "amount" 00491 #define SPLIT_SHARE_PRICE "share-price" 00492 #define SPLIT_VALUE "value" 00493 #define SPLIT_TYPE "type" 00494 #define SPLIT_VOIDED_AMOUNT "voided-amount" 00495 #define SPLIT_VOIDED_VALUE "voided-value" 00496 #define SPLIT_LOT "lot" 00497 #define SPLIT_TRANS "trans" 00498 #define SPLIT_ACCOUNT "account" 00499 #define SPLIT_ACCOUNT_GUID "account-guid" 00500 /* used for SORTING ONLY */ 00501 #define SPLIT_ACCT_FULLNAME "acct-fullname" 00502 #define SPLIT_CORR_ACCT_NAME "corr-acct-fullname" 00503 #define SPLIT_CORR_ACCT_CODE "corr-acct-code" 00504 00507 #define xaccSplitGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X)) 00508 00509 #define xaccSplitReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null())) 00510 00511 #endif /* XACC_SPLIT_H */ 00512
1.7.4