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

AccountsDB Class Reference

class to manipulate the accounts database. More...

#include <AccountsDB.h>

Inheritance diagram for AccountsDB:

Database< accountStructure, packedAccountStructure > GenericDB Collaboration diagram for AccountsDB:

Collaboration graph
[legend]
List of all members.

Public Methods

 AccountsDB () DB_SECTION1
 default constructor opens or creates the database (if created populates it with sample records). More...

 AccountsDB (DmOpenRef db_open_ref) DB_SECTION1
 constructor. More...

UInt32 findAccountByName (char *n, UInt16 categ) DB_SECTION1
void getAccountName (UInt32 acc, Char *buf) DB_SECTION1
 returns a formated account name in buf. More...

UInt32 getAccountCurrency (UInt32 acc) DB_SECTION1
 returns the currency used by an account. More...

void getFullNameTruncLeftToFit (UInt32 acc, Int16 width, Char *dest) DB_SECTION1
 Build the account's full path name, truncating the beginning if necessary to fit the given number of pixels. More...

void unpackRecord (accountStructure *account, packedAccountStructure *packedAccount) DB_SECTION1
 unpacks an account record. More...

void packRecord (accountStructure *account, MemHandle accountDBEntry) DB_SECTION1
 packs an account record. More...

void incrementBalance (UInt32 uid, Int32 clr_amt, Int32 amount, Boolean is_parent=false) DB_SECTION1
 Increment the account's balances by specified amounts, notifying the ancestors about the change as well. More...

void updateBalance (UInt32 uid, Int32 newbal, char *payee=NULL) DB_SECTION1
 Updates the balance for an account. More...

Int32 getBalance (UInt32 uid) DB_SECTION1
 fetch the balance of a given account. More...

Int32 getClearedBalance (UInt32 uid) DB_SECTION1
 fetch the cleared balance of a given account. More...

Boolean isDisplayable (UInt16 acc) DB_SECTION1
 checks if a parent of the current account is collapsed @acc account id. More...

UInt16 newRecord (accountStructure *s) DB_SECTION1
 packs and writes the data from s into the database. More...

bool deleteRecord (UInt16 id) DB_SECTION1
 Deletes an account given by its id The function scans through all the transactions and removes the ones which have as source/destinations the account to be deleted and as dest/src an account in the Income or Expense categories. More...

void updateVisibility (void)
 recategorize accounts as visible/invisible depending on user's choice. More...


Static Public Methods

Int16 compareRecords (packedAccountStructure *rec1, packedAccountStructure *rec2, Int16 other, SortRecordInfoPtr sr1, SortRecordInfoPtr sr2, MemHandle app_info) DB_SECTION1
 Compares two records (by the account name). More...


Public Attributes

totalsStruct totals
 structure containing the totals. More...


Private Methods

UInt32 createAccount (char *name, UInt32 parent_uid, AccountType acc_type)
 creates a new account. More...


Detailed Description

class to manipulate the accounts database.

The category field is used to split the accounts into visible and invisible. Onely the visible accounts will be displayed by AccountsTable

Definition at line 126 of file AccountsDB.h.


Constructor & Destructor Documentation

AccountsDB::AccountsDB  
 

default constructor opens or creates the database (if created populates it with sample records).

AccountsDB::AccountsDB DmOpenRef    db_open_ref
 

constructor.

Parameters:
db_open_ref  reference to an *already* opened database


Member Function Documentation

Int16 AccountsDB::compareRecords packedAccountStructure   rec1,
packedAccountStructure   rec2,
Int16    other,
SortRecordInfoPtr    sr1,
SortRecordInfoPtr    sr2,
MemHandle    app_info
[static]
 

Compares two records (by the account name).

UInt32 AccountsDB::createAccount char *    name,
UInt32    parent_uid,
AccountType    acc_type
[private]
 

creates a new account.

Parameters:
name  account name
parent_uid  the uid of the parent for the new account
acc_type  the type of the account

bool AccountsDB::deleteRecord UInt16    id [virtual]
 

Deletes an account given by its id The function scans through all the transactions and removes the ones which have as source/destinations the account to be deleted and as dest/src an account in the Income or Expense categories.

All the transaction involving user defined account will be updated so that the reference to the account to be deleted is replaced with a reference to a Income/Expense account

Parameters:
id  the id of the account to be deleted

Reimplemented from GenericDB.

UInt32 AccountsDB::findAccountByName char *    n,
UInt16    categ
 

Parameters:
n  name of the account to be found
categ  category of the account
Returns:
unique id of the account or 0 if the account could not be found

UInt32 AccountsDB::getAccountCurrency UInt32    acc
 

returns the currency used by an account.

Parameters:
acc  UID of the account to get the currency for
Returns:
UID of the currency used by the account

void AccountsDB::getAccountName UInt32    acc,
Char *    buf
 

returns a formated account name in buf.

Parameters:
acc  account to get the name for
buf  an *allocated* buffer in which the name is to be copied!

Int32 AccountsDB::getBalance UInt32    uid
 

fetch the balance of a given account.

Parameters:
uid  the unique id of the account record
Returns:
the balance in pence

Int32 AccountsDB::getClearedBalance UInt32    uid
 

fetch the cleared balance of a given account.

Parameters:
uid  the unique id of the account record
Returns:
the expected balance in pence

void AccountsDB::getFullNameTruncLeftToFit UInt32    acc,
Int16    width,
Char *    dest
 

Build the account's full path name, truncating the beginning if necessary to fit the given number of pixels.

Parameters:
acc  The account's UID
width  number of pixels
dest  allocated buffer to receive the result. I figure that it should be able to store width/2 characters in the worst case.

void AccountsDB::incrementBalance UInt32    uid,
Int32    clr_amt,
Int32    amount,
Boolean    is_parent = false
 

Increment the account's balances by specified amounts, notifying the ancestors about the change as well.

This is a 'lowlevel' function that modifies the account balance directly.

Parameters:
uid  uid of the account to be affected
clr_amt  amount to be added to the cleared balance
amount  amount to be added to the (total) balance
is_parent  true if the uid is the parent of an account whose balance has already changed. In this case, only the children totals of the given account and its ancestors are updated.

Boolean AccountsDB::isDisplayable UInt16    acc
 

checks if a parent of the current account is collapsed @acc account id.

Returns:
true if no parrent is collapsed, false otherwise

UInt16 AccountsDB::newRecord accountStructure   s [virtual]
 

packs and writes the data from s into the database.

@note: after calling this function the record has to be released

Parameters:
s  pointer to an allocated account which is to be saved
Returns:
the index to the record

Reimplemented from Database< accountStructure, packedAccountStructure >.

void AccountsDB::packRecord accountStructure   account,
MemHandle    accountDBEntry
[virtual]
 

packs an account record.

Implements Database< accountStructure, packedAccountStructure >.

void AccountsDB::unpackRecord accountStructure   account,
packedAccountStructure   packedAccount
[virtual]
 

unpacks an account record.

Implements Database< accountStructure, packedAccountStructure >.

void AccountsDB::updateBalance UInt32    uid,
Int32    newbal,
char *    payee = NULL
 

Updates the balance for an account.

This is a 'highlevel' function that affects the balance by inserting a cleared balance adjustment transaction.

Parameters:
uid  unique id
newbal  the new balance
payee  optional payee description

void AccountsDB::updateVisibility void   
 

recategorize accounts as visible/invisible depending on user's choice.


Member Data Documentation

totalsStruct AccountsDB::totals
 

structure containing the totals.

Definition at line 137 of file AccountsDB.h.


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