Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TransactionsDB Class Reference

class to manipulate the transactions database. More...

#include <TransactionsDB.h>

Inheritance diagram for TransactionsDB:

Database< transactionStructure, packedTransactionStructure > GenericDB Collaboration diagram for TransactionsDB:

Collaboration graph
[legend]
List of all members.

Public Methods

void unpackRecord (transactionStructure *trans, packedTransactionStructure *packed_trans) DB_SECTION2
 unpacks an Transaction record. More...

void packRecord (transactionStructure *trans, MemHandle db_entry) DB_SECTION2
 packs an Transaction record. More...

void getDate (UInt16 id, DateType *pDate) DB_SECTION2
 get the date of the transaction. More...

UInt16 getClearedCategory () DB_SECTION2
UInt16 getClUnclCategory () DB_SECTION2
UInt16 getUnclearedCategory () DB_SECTION2
UInt16 getScheduledCategory () DB_SECTION2
Boolean isBalanced (UInt32 trans_uid) DB_SECTION2
 determine if the transaction is balanced. More...

Int32 getAmount (UInt32 trans_uid, UInt32 acc_uid) DB_SECTION2
 get the amount by which the transaction affects the given account. More...

UInt32 getPeerAcc (UInt32 trans_uid, UInt32 acc_uid) DB_SECTION2
 get the peer account in the given transaction from the point of view of the given account. More...

Boolean isCleared (UInt16 id) DB_SECTION2
 checks whether a record is cleared or not. More...

Boolean willBeCleared (UInt16 id) DB_SECTION2
 checks whether a record is to be cleared or not. More...

Boolean isScheduled (UInt16 id) DB_SECTION2
 checks whether a transaction is scheduled or not by checking the record category. More...

void clearRecord (UInt16 id) DB_SECTION2
 set a record category to cleared. More...

void unclearRecord (UInt16 id) DB_SECTION2
 set a record category to uncleared. More...

 TransactionsDB () DB_SECTION2
 initialize the database. More...

void initializeTransactions () DB_SECTION2
 init the Transactions DB with some default records. More...

UInt16 newRecord (transactionStructure *s, Boolean cleared, Boolean scheduled=false) DB_SECTION2
 creates a new record and update the balances of the two involved accounts. More...

bool deleteRecord (UInt16 id, Boolean keep_balance=false) DB_SECTION2
 deletes a record, given its id. More...

void purgeTransactions (DateType last_date) DB_SECTION2
 This function deletes all the transactions earlier than the given date. More...

Boolean calculateNextDate (UInt16 id) DB_SECTION2
 records the next date in the associated transaction (in relation to the date already recorded) if we have repeated the record enought times, the record is deleted. More...

Boolean schedule (Boolean force=false) DB_SECTION2
 scans through all the scheduled transactions, and if there are any due they are recorded and their next occurance date is updated. More...

Boolean scheduleNextRecord () DB_SECTION2
 schedule the first scheduled record that is due. More...

Int32 getScheduledTotal (UInt32 account_uid) DB_SECTION2
 returns the total for the scheduled transactions in a given account. More...

UInt32 recordScheduledRecord (UInt32 record_uid, bool mod_date) DB_SECTION2
 creates a new (unscheduled) record from a scheduled one, leaving the original scheduled transaction unaltered. More...

Int32 getTransactionByPayeeAndAcc (Char *p, UInt16 start_id) DB_SECTION2
 Returns the first transaction with an id equal or higher than the given one which has a payee string which starts the same (case insensitive) as the given string and has as source account the account which is currently used. More...

Int32 getTransactionByPayee (Char *p, UInt16 start_id=0, Boolean want_cur_acc=false) DB_SECTION2
 Returns the first transaction with an id equal or higher than the given one which has a payee string which starts the same (case insensitive) as the given string. More...


Static Public Methods

Int16 compareRecords (packedTransactionStructure *rec1, packedTransactionStructure *rec2, Int16 other, SortRecordInfoPtr sr1, SortRecordInfoPtr sr2, MemHandle app_info) DB_SECTION2
 Compares two packed transaction structures. More...


Detailed Description

class to manipulate the transactions database.

Note:
Transactions can belong to one of the three categories:
  1. cleared
  2. uncleared
  3. scheduled Cleared/uncleared transaction should be treated (mostly) the same. The scheduled transactions contain the information for the transaction to be scheduled in the transaction body, and information about how this is to be done in the scheduled structure

Definition at line 130 of file TransactionsDB.h.


Constructor & Destructor Documentation

TransactionsDB::TransactionsDB  
 

initialize the database.


Member Function Documentation

Boolean TransactionsDB::calculateNextDate UInt16    id
 

records the next date in the associated transaction (in relation to the date already recorded) if we have repeated the record enought times, the record is deleted.

Parameters:
id  id of the record for which to find the next date
Returns:
true if the record has been deleted, false otherwise

void TransactionsDB::clearRecord UInt16    id
 

set a record category to cleared.

Parameters:
id  id of the record to be set

Int16 TransactionsDB::compareRecords packedTransactionStructure   rec1,
packedTransactionStructure   rec2,
Int16    other,
SortRecordInfoPtr    sr1,
SortRecordInfoPtr    sr2,
MemHandle    app_info
[static]
 

Compares two packed transaction structures.

For parameters see the PalmOS reference

bool TransactionsDB::deleteRecord UInt16    id,
Boolean    keep_balance = false
 

deletes a record, given its id.

Parameters:
id  the id of the record to be deleted
keep_balance  if true then the balances of the accounts involved in the transaction will *not* be changed

Int32 TransactionsDB::getAmount UInt32    trans_uid,
UInt32    acc_uid
 

get the amount by which the transaction affects the given account.

Parameters:
trans_uid  UID of the transaction
acc_uid  UID of the account
Returns:
signed amount

UInt16 TransactionsDB::getClearedCategory  
 

Returns:
the value of the Cleared category

UInt16 TransactionsDB::getClUnclCategory  
 

Returns:
the value of the Cl/Uncl category

void TransactionsDB::getDate UInt16    id,
DateType *    pDate
 

get the date of the transaction.

Parameters:
id  record index
pDate  pointer to allocated date structure that will receive the date

UInt32 TransactionsDB::getPeerAcc UInt32    trans_uid,
UInt32    acc_uid
 

get the peer account in the given transaction from the point of view of the given account.

Only makes sense for transactions that are split two ways, i.e. simple transfers.

Parameters:
trans_uid  UID of the transaction
acc_uid  UID of the account
Returns:
UID of the peer account

UInt16 TransactionsDB::getScheduledCategory  
 

Returns:
the value of the Scheduled category

Int32 TransactionsDB::getScheduledTotal UInt32    account_uid
 

returns the total for the scheduled transactions in a given account.

Parameters:
account_uid  uid of the account to be checked
Returns:
the sum of the amounts of all scheduled transaction for that account

Int32 TransactionsDB::getTransactionByPayee Char *    p,
UInt16    start_id = 0,
Boolean    want_cur_acc = false
 

Returns the first transaction with an id equal or higher than the given one which has a payee string which starts the same (case insensitive) as the given string.

Parameters:
p  start of the payee string which is to be mached by an existing transaction
start_id  id from where to start looking for matching transactions; it defaults to 0. Note that the given ID is checked aswell!
Returns:
the UInt16 id of the first matched transaction or -1 if no such transaction was found
Parameters:
want_cur_acc  if true, the function will attempt to return a transaction with the same source account as the current account. If it fails to find such a transaction it returns the first transaction from any acount which matches the given payee

Int32 TransactionsDB::getTransactionByPayeeAndAcc Char *    p,
UInt16    start_id
 

Returns the first transaction with an id equal or higher than the given one which has a payee string which starts the same (case insensitive) as the given string and has as source account the account which is currently used.

Parameters:
p  start of the payee string which is to be mached by an existing transaction
start_id  id from where to start looking for matching transactions; it defaults to 0. Note that the given ID is checked aswell!
Returns:
the UInt16 id of the first matched transaction or -1 if no such transaction was found

UInt16 TransactionsDB::getUnclearedCategory  
 

Returns:
the value of the Uncleared category

void TransactionsDB::initializeTransactions  
 

init the Transactions DB with some default records.

Boolean TransactionsDB::isBalanced UInt32    trans_uid
 

determine if the transaction is balanced.

Parameters:
trans_uid  UID of the transaction
Returns:
true if the transaction is balanced, false otherwise

Boolean TransactionsDB::isCleared UInt16    id
 

checks whether a record is cleared or not.

Parameters:
id  id of the record to be checked
Returns:
true if the record is cleared, false otherwise

Boolean TransactionsDB::isScheduled UInt16    id
 

checks whether a transaction is scheduled or not by checking the record category.

Parameters:
id  the id of the transaction to be checked
Returns:
true if it is scheduled, false othewise

UInt16 TransactionsDB::newRecord transactionStructure   s,
Boolean    cleared,
Boolean    scheduled = false
 

creates a new record and update the balances of the two involved accounts.

Parameters:
s  pointer to the structure containing the transaction data
cleared  boolean which indicates the status of the record. The function will place the record in the right category
scheduled  (which defaults to false if no value is given) indicates whether the transaction is scheduled or not. the cateogry will be set to the right one
Returns:
id of the newly created record

void TransactionsDB::packRecord transactionStructure   trans,
MemHandle    db_entry
[virtual]
 

packs an Transaction record.

Todo:
we should be able to pack the scheduled structure to 0 or 1 bytes. I am not sure how viable this is (as we do not always know whether the transaction is scheduled or not when packing it ) but if it can be done it would save about 14 bytes for each transaction

Implements Database< transactionStructure, packedTransactionStructure >.

void TransactionsDB::purgeTransactions DateType    last_date
 

This function deletes all the transactions earlier than the given date.

This should not change the existing balances for the accounts involved. Both cleared and uncleared transactions are removed, but the scheduled ones are kept

Todo:
message informing the operation is being performed while this function runs
Warning:
should probably set the archived bit on deletion rather than removing the records. this is true for all the destructive operations, but there is really no point in doing so before the conduit reaches a working state
Note:
scheduled transaction are not deleted on purging
Parameters:
last_date  the last date up to which the transactions are to be deleted

UInt32 TransactionsDB::recordScheduledRecord UInt32    record_uid,
bool    mod_date
 

creates a new (unscheduled) record from a scheduled one, leaving the original scheduled transaction unaltered.

Parameters:
record_uid  uid of the scheduled transaction to be recorded
mod_date  if true, the date of the new record is going to be set to today. Otherwise the date is left unaltered
Returns:
uid of the new record that has been created

Boolean TransactionsDB::schedule Boolean    force = false
 

scans through all the scheduled transactions, and if there are any due they are recorded and their next occurance date is updated.

Parameters:
force  if true then the current date is ignored the update is perfomed anyway
Returns:
true if updates were made, false otherwise

Boolean TransactionsDB::scheduleNextRecord  
 

schedule the first scheduled record that is due.

void TransactionsDB::unclearRecord UInt16    id
 

set a record category to uncleared.

Parameters:
id  id of the record to be set

void TransactionsDB::unpackRecord transactionStructure   trans,
packedTransactionStructure   packed_trans
[virtual]
 

unpacks an Transaction record.

Implements Database< transactionStructure, packedTransactionStructure >.

Boolean TransactionsDB::willBeCleared UInt16    id
 

checks whether a record is to be cleared or not.

Parameters:
id  id of the record to be checked
Returns:
true if the record is set to be cleared in the future, false otherwise


The documentation for this class was generated from the following file:
Generated on Thu Jan 16 23:11:15 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002