-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataadapter.h
119 lines (101 loc) · 4.37 KB
/
dataadapter.h
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*!
* \author Kaveen Hyacinth
* \copyright Kaveen Hyacinth Digital © 2020
*/
#ifndef DATAADAPTER_H
#define DATAADAPTER_H
#include <QTableView>
#include <QComboBox>
/*!
* \brief The DataAdapter class does basic database operations
*/
class DataAdapter
{
public:
DataAdapter();
public:
/*!
* \brief ReadAccounts loads account details to the QTableView model
* \param tbl is the QTableView model that displays the account data
*/
void ReadAccounts(QTableView *tbl);
/*!
* \brief ReadTransactions loads transaction details to the QTableView model
* \param tbl is the QTableView model that displays the transaction data
*/
void ReadTransactions(QTableView *tbl);
/*!
* \brief ReadAccounts loads the account names to the given QComboBox
* \param cmb is the QComboBox that displays the account names
*/
void ReadAccounts(QComboBox *cmb);
/*!
* \brief ReadCategories loads the category names that grouped by ref to the given QComboBox
* \param cmb is the QComboBox model that displays the category names
* \param ref is the type of the category, income or expense
*/
void ReadCategories(QComboBox *cmb, QString ref);
/*!
* \brief LoadAccountData load account details to the QTableView and account names to the QComboBox at the same time
* \param tbl is the QTableView that displays the account details
* \param cmb is the QComboBox model that displays the account names
*/
void LoadAccountData(QTableView *tbl, QComboBox *cmb);
/*!
* \brief LoadTransactionData loads all the transactions that are happen within the database
* \param tbl is the table view model to display transaction data model
* \param cmbInAcc is the QComboBox model to load accounts in add income area
* \param cmbInCat is the QComboBox model to load categories in add income area
* \param cmbExAcc is the QComboBox model to load accounts in add expense area
* \param cmbExCat is the QComboBox model to load categories in add expense area
*/
void LoadTransactionData(QTableView *tbl, QComboBox *cmbInAcc, QComboBox *cmbInCat, QComboBox *cmbExAcc, QComboBox *cmbExCat);
/*!
* \brief UpdateAccountIncome updates the relevant account when an income is added
* \param accountId is the relevant account id
* \param incomeBalance is the transaction amount
* \return true or false based on the success of the operation
*/
bool UpdateAccountIncome(int accountId, int incomeBalance);
/*!
* \brief UpdateAccountExpense updates the relevant account when an expense is added
* \param accountId is the relevant account id
* \param expenseBalance is the transaction amount
* \return true or false based on the success of the operation
*/
bool UpdateAccountExpense(int accountId, int expenseBalance);
/*!
* \brief FetchTotalByType sum up total transaction amount based on the given type
* \param recordType is the type, income or expense
* \return total balance as an int type
*/
int FetchTotalByType(QString recordType);
/*!
* \brief FetchTotalOfTypeByDate sum up total transaction amount based on the given type and date range
* \param recordType is the type, income or expense
* \param startDate is the start point of the date range
* \param endDate is the end point of the date range
* \return total balance as an int type
*/
int FetchTotalOfTypeByDate(QString recordType, QDate startDate, QDate endDate);
/*!
* \brief FetchTotalStringByType sum up total transaction amount based on the given type
* \param recordType is the type, income or expense
* \return total balance as a string type
*/
QString FetchTotalStringByType(QString recordType);
/*!
* \brief FetchTotalStringOfTypeByDate sum up total transaction amount based on the given type and date range
* \param recordType is the type, income or expense
* \param startDate is the start point of the date range
* \param endDate is the end point of the date range
* \return total balance as a string type
*/
QString FetchTotalStringOfTypeByDate(QString recordType, QDate startDate, QDate endDate);
/*!
* \brief FetchTotalBalance sum up total acount balance
* \return total balance as a string type
*/
QString FetchTotalBalance();
};
#endif // DATAADAPTER_H