00001 /********************************************************************\ 00002 * checkpoint.h -- balance checkpoints * 00003 * * 00004 * This program is free software; you can redistribute it and/or * 00005 * modify it under the terms of the GNU General Public License as * 00006 * published by the Free Software Foundation; either version 2 of * 00007 * the License, or (at your option) any later version. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License* 00015 * along with this program; if not, contact: * 00016 * * 00017 * Free Software Foundation Voice: +1-617-542-5942 * 00018 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00019 * Boston, MA 02110-1301, USA gnu@gnu.org * 00020 \********************************************************************/ 00021 00022 /* 00023 * FILE: 00024 * checkpoint.h 00025 * 00026 * FUNCTION: 00027 * Defines balance checkpoints 00028 * 00029 * HISTORY: 00030 * Copyright (c) 2001 Linas Vepstas <linas@linas.org> 00031 */ 00032 00033 00034 #ifndef CHECKPOINT_H 00035 #define CHECKPOINT_H 00036 00037 #include "Account.h" 00038 #include "qof.h" 00039 #include "Transaction.h" 00040 00041 #include "PostgresBackend.h" 00042 00043 /* -------------------------------------------------------- */ 00044 /* The balance checkpoint structure is used to store partial, 00045 * running balances. The balances are correct for the checkpoint 00046 * date shown. The commodity indicates what commodity the 00047 * balances are valued in (they need not be in the same 00048 * commodity as the account) 00049 */ 00050 00051 /* the MIN_CHECKPOINT_COUNT value is the number of splits that 00052 * each checkpoint will handle, on avergage. 30 seems like a good 00053 * number. The number of splits in a checkpoint will vary; 00054 * checkpoints can only occur in between entry dates, so a 00055 * bunch of entries with the same date will go into the same 00056 * checkpoint (and there might be an arbitrarily large number of these) 00057 */ 00058 #define MIN_CHECKPOINT_COUNT 30 00059 00060 typedef struct _checkpoint { 00061 const GUID *account_guid; 00062 const char * commodity; 00063 Timespec date_start; 00064 Timespec date_end; 00065 gint64 balance; 00066 gint64 cleared_balance; 00067 gint64 reconciled_balance; 00068 } Checkpoint; 00069 00070 /* -------------------------------------------------------- */ 00071 /* function prototypes */ 00072 00073 #define CK_EARLIEST_DATE "1903-01-02 08:35:46.00" 00074 #define CK_AFTER_EARLIEST_DATE "1903-01-03 03:03:03.00" 00075 #define CK_BEFORE_LAST_DATE "2038-01-01 12:12:12.00" 00076 #define CK_LAST_DATE "2038-01-02 08:35:46.00" 00077 00078 00079 void pgendTransactionRecomputeCheckpoints (PGBackend *be, Transaction *trans); 00080 void pgendAccountRecomputeOneCheckpoint (PGBackend *be, Account *acc, Timespec ts); 00081 void pgendAccountTreeRecomputeAllCheckpoints (PGBackend *, Account *); 00082 void pgendAccountTreeGetAllBalances (PGBackend *, Account *, Timespec as_of_date); 00083 00084 /* The pgendAccountGetBalance() routine goes to the sql database and finds the 00085 * balance as of the 'as_of_date' argument. It sets the starting balance for 00086 * this account based on that value. 00087 */ 00088 void pgendAccountGetBalance (PGBackend *, Account *, Timespec as_of_date); 00089 00090 #endif /* CHECKPOINT_H */
1.5.2