summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transaction.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/transaction.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transaction.cpp20
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
@@ -8,6 +8,7 @@
8#include "transactiondisplay.h" 8#include "transactiondisplay.h"
9 9
10#include <stdlib.h> 10#include <stdlib.h>
11#include <iostream.h>
11 12
12extern Account *account; 13extern Account *account;
13extern Preferences *preferences; 14extern Preferences *preferences;
@@ -154,9 +155,10 @@ int Transaction::getYear ( int id )
154 return yearstring.toInt(); 155 return yearstring.toInt();
155 } 156 }
156 157
157void Transaction::displayTransactions ( QListView *listview, int id, bool children, const char *limit ) 158void 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
@@ -166,14 +168,14 @@ void Transaction::displayTransactions ( QListView *listview, int id, bool childr
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 }
@@ -182,14 +184,8 @@ void Transaction::displayTransactions ( QListView *listview, int id, bool childr
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 ];