summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qashmoney/account.h
blob: 5bad4a166e2df1a8a6a0945dd3b45072dc946e86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef ACCOUNT_H
#define ACCOUNT_H

#include <qstring.h>
#include <qlistview.h>
#include <qcombobox.h>
#include <sqlite3.h>

class Account
  {
    public:

      Account ();
      ~Account ();

      // This function adds a new account to the database.  It takes the account name, parent,
      // initial balance and the account type, description, credit limit, statementbalancedate
      // as three integers, and the statementbalance amount
      // The parent is an integer account id.  Its -1 if there is no parent
      // The account types (so far)  are 0=not defined 1=parent checking 2=child checking
      void addAccount ( QString, int, float, int, QString, float, int, int, int, float, const char * );

      // updates certain parts of an account
      void updateAccount ( QString name, QString description, QString currencycode, int accountid );

      void setAccountExpanded ( int expanded, int accountid );
      int getAccountExpanded ( int id );

      // Deletes an account
      // Takes the accountid as its parameter
      void deleteAccount ( int );

      // Returns the number of accounts
      int getNumberOfAccounts ();

      // returns number of child accounts for a given parent
      // this function is useless for child accounts.  It will
      // always return 0
      int getNumberOfChildAccounts ( int );

      // This function retrieves all transactions for an account and updates the
      // account balance based on the transactions
      void updateAccountBalance ( int accountid );
      //void changeAccountBalance ( int accountid, float amount );

      // updates a parent account
      void changeParentAccountBalance ( int parentid );

      // Returns the parent account ID for an account
      // Takes the account name as its parameter or the account id
      int getParentAccountID ( QString accountname );
      int getParentAccountID ( int id );

      // This takes a QListView and puts parents and children memorys
      // into the list view
      void displayAccounts ( QListView * );

      // This function displays a sorted list of account names in a combobox
      // Takes the combobox address for its parameter
      int displayParentAccountNames ( QComboBox *, QString );

      int getAccountType ( int );  // returns account type for given account id

      // The next three collectively return a date or balance
      // They take the accountid as their parameters
      int getStatementDay ( int );
      int getStatementMonth ( int );
      int getStatementYear ( int );
      float getStatementBalance ( int );

      // Returns account description and name
      QString getAccountDescription ( int accountid );
      QString getCurrencyCode ( int accountid );
      QString getAccountName ( int accountid );
      QStringList getAccountNames ();
      QStringList getAccountIDs ();
      QString getAccountBalance ( int accountid );

      // returns account credit limit
      float getAccountCreditLimit ( int );

      // The primary database that stores all our data
      sqlite3 *adb;
  };

class GreyBackgroundItem : public QListViewItem
  {
    public:

      GreyBackgroundItem ( QListView *parent );
      GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3 );
      GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4 );
      GreyBackgroundItem ( QListView *parent, QString label1, QString label2, QString label3, QString label4, QString label5 );

      virtual void paintCell ( QPainter *p, const QColorGroup &cg, int column, int width, int alignment );

  };

#endif