00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00086 #ifndef XACC_TRANSACTION_H
00087 #define XACC_TRANSACTION_H
00088
00089 typedef struct _TransactionClass TransactionClass;
00090
00091 #include <time.h>
00092
00093 #include "gnc-commodity.h"
00094 #include "gnc-engine.h"
00095 #include "Split.h"
00096
00097
00098 #define GNC_TYPE_TRANSACTION (gnc_transaction_get_type ())
00099 #define GNC_TRANSACTION(o) \
00100 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_TRANSACTION, Transaction))
00101 #define GNC_TRANSACTION_CLASS(k) \
00102 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_TRANSACTION, TransactionClass))
00103 #define GNC_IS_TRANSACTION(o) \
00104 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_TRANSACTION))
00105 #define GNC_IS_TRANSACTION_CLASS(k) \
00106 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_TRANSACTION))
00107 #define GNC_TRANSACTION_GET_CLASS(o) \
00108 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_TRANSACTION, TransactionClass))
00109 GType gnc_transaction_get_type(void);
00110
00111
00112
00113 #define GNC_IS_TRANS(obj) GNC_IS_TRANSACTION(obj)
00114 #define GNC_TRANS(obj) GNC_TRANSACTION(obj)
00115
00119 #define TXN_TYPE_NONE '\0'
00120 #define TXN_TYPE_INVOICE 'I'
00121 #define TXN_TYPE_PAYMENT 'P'
00124
00125
00126
00134 Transaction * xaccMallocTransaction (QofBook *book);
00135
00144 void xaccTransDestroy (Transaction *trans);
00145
00150 Transaction * xaccTransClone (const Transaction *t);
00151
00175 gboolean xaccTransEqual(const Transaction *ta,
00176 const Transaction *tb,
00177 gboolean check_guids,
00178 gboolean check_splits,
00179 gboolean check_balances,
00180 gboolean assume_ordered);
00181
00185 void xaccTransBeginEdit (Transaction *trans);
00186
00192 void xaccTransCommitEdit (Transaction *trans);
00193
00199 void xaccTransRollbackEdit (Transaction *trans);
00200
00207 gboolean xaccTransIsOpen (const Transaction *trans);
00208
00212 Transaction * xaccTransLookup (const GUID *guid, QofBook *book);
00213 #define xaccTransLookupDirect(g,b) xaccTransLookup(&(g),b)
00214
00215 Split * xaccTransFindSplitByAccount(const Transaction *trans,
00216 const Account *acc);
00217
00225 void xaccTransScrubGains (Transaction *trans, Account *gain_acc);
00226
00227
00232 guint gnc_book_count_transactions(QofBook *book);
00233
00244 void xaccTransSortSplits (Transaction *trans);
00245
00249 void xaccTransSetTxnType (Transaction *trans, char type);
00253 char xaccTransGetTxnType (const Transaction *trans);
00254
00255
00257 void xaccTransSetNum (Transaction *trans, const char *num);
00259 void xaccTransSetDescription (Transaction *trans, const char *desc);
00263 void xaccTransSetNotes (Transaction *trans, const char *notes);
00264
00266 const char * xaccTransGetNum (const Transaction *trans);
00268 const char * xaccTransGetDescription (const Transaction *trans);
00272 const char * xaccTransGetNotes (const Transaction *trans);
00273
00274
00282 #define xaccTransAppendSplit(t, s) xaccSplitSetParent((s), (t))
00283
00291 Split * xaccTransGetSplit (const Transaction *trans, int i);
00292
00294 int xaccTransGetSplitIndex(const Transaction *trans, const Split *split);
00295
00300 SplitList * xaccTransGetSplitList (const Transaction *trans);
00301 gboolean xaccTransStillHasSplit(const Transaction *trans, const Split *s);
00302
00303
00305 void xaccTransSetReadOnly (Transaction *trans, const char *reason);
00306 void xaccTransClearReadOnly (Transaction *trans);
00308 const char * xaccTransGetReadOnly (const Transaction *trans);
00309
00311 int xaccTransCountSplits (const Transaction *trans);
00312
00314 gboolean xaccTransHasReconciledSplits (const Transaction *trans);
00316 gboolean xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
00317 const Account *account);
00318
00320 gboolean xaccTransHasSplitsInState (const Transaction *trans, const char state);
00322 gboolean xaccTransHasSplitsInStateByAccount (const Transaction *trans,
00323 const char state,
00324 const Account *account);
00325
00326
00334 gnc_commodity * xaccTransGetCurrency (const Transaction *trans);
00335
00337 void xaccTransSetCurrency (Transaction *trans, gnc_commodity *curr);
00338
00347 gnc_numeric xaccTransGetImbalance (const Transaction * trans);
00348
00355 gnc_numeric xaccTransGetAccountValue (const Transaction *trans,
00356 const Account *account);
00357
00359 gnc_numeric xaccTransGetAccountAmount (const Transaction *trans,
00360 const Account *account);
00361
00362
00363
00364
00365
00366
00367
00368
00369 gnc_numeric xaccTransGetAccountConvRate(Transaction *txn, Account *acc);
00370
00373 gnc_numeric xaccTransGetAccountBalance (const Transaction *trans,
00374 const Account *account);
00375
00392 int xaccTransOrder (const Transaction *ta, const Transaction *tb);
00393
00410 void xaccTransSetDate (Transaction *trans,
00411 int day, int mon, int year);
00412
00417 #define xaccTransSetDateSecs xaccTransSetDatePostedSecs
00418 void xaccTransSetDatePostedSecs (Transaction *trans, time_t time);
00419
00422 void xaccTransSetDatePostedTS (Transaction *trans,
00423 const Timespec *ts);
00424
00427 void xaccTransSetDateEnteredSecs (Transaction *trans, time_t time);
00430 void xaccTransSetDateEnteredTS (Transaction *trans,
00431 const Timespec *ts);
00432
00434 void xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts);
00435
00440 time_t xaccTransGetDate (const Transaction *trans);
00445 void xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts);
00450 Timespec xaccTransRetDatePostedTS (const Transaction *trans);
00451
00454 void xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts);
00457 Timespec xaccTransRetDateEnteredTS (const Transaction *trans);
00458
00460 Timespec xaccTransRetDateDueTS (const Transaction *trans);
00462 void xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts);
00467
00468
00469
00470
00471
00484 void xaccTransVoid(Transaction *transaction,
00485 const char *reason);
00486
00494 void xaccTransUnvoid(Transaction *transaction);
00495
00507 Transaction * xaccTransReverse(Transaction *transaction);
00508
00516 Transaction * xaccTransGetReversedBy(const Transaction *trans);
00517
00525 gboolean xaccTransGetVoidStatus(const Transaction *transaction);
00526
00534 const char *xaccTransGetVoidReason(const Transaction *transaction);
00535
00543 Timespec xaccTransGetVoidTime(const Transaction *tr);
00549 #define TRANS_KVP "kvp"
00550 #define TRANS_NUM "num"
00551 #define TRANS_DESCRIPTION "desc"
00552 #define TRANS_DATE_ENTERED "date-entered"
00553 #define TRANS_DATE_POSTED "date-posted"
00554 #define TRANS_DATE_DUE "date-due"
00555 #define TRANS_IMBALANCE "trans-imbalance"
00556 #define TRANS_IS_BALANCED "trans-balanced?"
00557 #define TRANS_NOTES "notes"
00558 #define TRANS_TYPE "type"
00559 #define TRANS_VOID_STATUS "void-p"
00560 #define TRANS_VOID_REASON "void-reason"
00561 #define TRANS_VOID_TIME "void-time"
00562 #define TRANS_SPLITLIST "split-list"
00563
00565 #define RECONCILED_MATCH_TYPE "reconciled-match"
00566
00568 #define xaccTransGetBook(X) qof_instance_get_book (QOF_INSTANCE(X))
00569
00570 #define xaccTransGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
00571
00572 #define xaccTransReturnGUID(X) (X ? *(qof_entity_get_guid(QOF_INSTANCE(X))) : *(guid_null()))
00573
00574 #define xaccTransGetSlots(X) qof_instance_get_slots (QOF_INSTANCE(X))
00575
00576 #endif
00577