Diffstat (limited to 'noncore/apps/qashmoney/transaction.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/transaction.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/noncore/apps/qashmoney/transaction.cpp b/noncore/apps/qashmoney/transaction.cpp index af7d18f..5ecc7ed 100755 --- a/noncore/apps/qashmoney/transaction.cpp +++ b/noncore/apps/qashmoney/transaction.cpp | |||
@@ -1,22 +1,23 @@ | |||
1 | // RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN | 1 | // RESERVEDONE COLUMN NAME REPRESENTS THE LINEITEMID AND SHOULD BE CHANGED IN |
2 | // FUTURE VERSIONS OF QASHMONEY | 2 | // FUTURE VERSIONS OF QASHMONEY |
3 | 3 | ||
4 | // RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION | 4 | // RESERVEDTWO REPRESENTS THE TRANSACTION DESCRIPTION |
5 | 5 | ||
6 | #include "transaction.h" | 6 | #include "transaction.h" |
7 | #include "account.h" | 7 | #include "account.h" |
8 | #include "transactiondisplay.h" | 8 | #include "transactiondisplay.h" |
9 | 9 | ||
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <iostream.h> | ||
11 | 12 | ||
12 | extern Account *account; | 13 | extern Account *account; |
13 | extern Preferences *preferences; | 14 | extern Preferences *preferences; |
14 | 15 | ||
15 | Transaction::Transaction () | 16 | Transaction::Transaction () |
16 | { | 17 | { |
17 | tdb = sqlite_open ( "qmtransactions.db", 0, NULL ); | 18 | tdb = sqlite_open ( "qmtransactions.db", 0, NULL ); |
18 | } | 19 | } |
19 | 20 | ||
20 | Transaction::~Transaction () | 21 | Transaction::~Transaction () |
21 | { | 22 | { |
22 | sqlite_close ( tdb ); | 23 | sqlite_close ( tdb ); |
@@ -145,60 +146,55 @@ int Transaction::getMonth ( int id ) | |||
145 | QString monthstring = results [ 1 ]; | 146 | QString monthstring = results [ 1 ]; |
146 | return monthstring.toInt(); | 147 | return monthstring.toInt(); |
147 | } | 148 | } |
148 | 149 | ||
149 | int Transaction::getYear ( int id ) | 150 | int Transaction::getYear ( int id ) |
150 | { | 151 | { |
151 | char **results; | 152 | char **results; |
152 | sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); | 153 | sqlite_get_table_printf ( tdb, "select year from transactions where transid= %i;", &results, NULL, NULL, NULL, id ); |
153 | QString yearstring = results [ 1 ]; | 154 | QString yearstring = results [ 1 ]; |
154 | return yearstring.toInt(); | 155 | return yearstring.toInt(); |
155 | } | 156 | } |
156 | 157 | ||
157 | void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit ) | 158 | void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit, QDate displaydate ) |
158 | { | 159 | { |
159 | int showcleared = preferences->getPreference ( 3 ); | 160 | int showcleared = preferences->getPreference ( 3 ); |
161 | int year = ( displaydate.year() ) - 1; | ||
160 | 162 | ||
161 | // select the transactions to display | 163 | // select the transactions to display |
162 | // two different statements are used based on | 164 | // two different statements are used based on |
163 | // whether we are showing cleared transactions | 165 | // whether we are showing cleared transactions |
164 | char **results; | 166 | char **results; |
165 | int rows, columns; | 167 | int rows, columns; |
166 | if ( showcleared == 0 ) | 168 | if ( showcleared == 0 ) |
167 | { | 169 | { |
168 | if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) | 170 | if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) |
169 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); | 171 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and year >= %i parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); |
170 | else | 172 | else |
171 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 and accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); | 173 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where cleared = 0 year >= %i accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); |
172 | } | 174 | } |
173 | else | 175 | else |
174 | { | 176 | { |
175 | if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) | 177 | if ( account->getParentAccountID ( id ) == -1 && children == TRUE ) |
176 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); | 178 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where year >= %i and parentid = %i and payee like '%q';", &results, &rows, &columns, NULL, year, id, limit ); |
177 | else | 179 | else |
178 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); | 180 | sqlite_get_table_printf ( tdb, "select day, month, year, payee, amount, transid, accountid from transactions where accountid = %i and payee like '%q';", &results, &rows, &columns, NULL, id, limit ); |
179 | } | 181 | } |
180 | 182 | ||
181 | // iterate through the result list and display each item | 183 | // iterate through the result list and display each item |
182 | int counter = 7; | 184 | int counter = 7; |
183 | while ( counter < ( ( rows + 1 ) * columns ) ) | 185 | while ( counter < ( ( rows + 1 ) * columns ) ) |
184 | { | 186 | { |
185 | // construct the date | 187 | QDate displaydate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); |
186 | //QString daystring = results [ counter ]; | 188 | QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); |
187 | //int day = results [ counter ].toInt (); | ||
188 | //QString monthstring = results [ counter + 1 ]; | ||
189 | //int month = results [ counter + 1 ].toInt (); | ||
190 | //QString yearstring = results [ counter + 2 ]; | ||
191 | //int year = results [ counter + 2 ].toInt (); | ||
192 | QString date = preferences->getDate ( atoi ( results [ counter + 2 ] ), atoi ( results [ counter + 1 ] ), atoi ( results [ counter ] ) ); | ||
193 | 189 | ||
194 | // construct transaction name, amount, id | 190 | // construct transaction name, amount, id |
195 | QString payee = results [ counter + 3 ]; | 191 | QString payee = results [ counter + 3 ]; |
196 | QString amount = results [ counter + 4 ]; | 192 | QString amount = results [ counter + 4 ]; |
197 | QString transferid = results [ counter + 5 ]; | 193 | QString transferid = results [ counter + 5 ]; |
198 | 194 | ||
199 | //determine the account name of the child accounts that we're displaying | 195 | //determine the account name of the child accounts that we're displaying |
200 | QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) ); | 196 | QString accountname = account->getAccountName ( atoi ( results [ counter + 6 ] ) ); |
201 | 197 | ||
202 | // fill in values | 198 | // fill in values |
203 | if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account | 199 | if ( account->getParentAccountID ( id ) != -1 ) // use these constructors if we're showing a child account |
204 | { | 200 | { |