summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transfer.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/qashmoney/transfer.cpp') (more/less context) (show whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transfer.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/noncore/apps/qashmoney/transfer.cpp b/noncore/apps/qashmoney/transfer.cpp
index 77cbb4e..568d584 100755
--- a/noncore/apps/qashmoney/transfer.cpp
+++ b/noncore/apps/qashmoney/transfer.cpp
@@ -44,174 +44,181 @@ void Transfer::deleteTransfer ( int transferid )
void Transfer::deleteAllTransfers ( int accountid )
{
sqlite_exec_printf ( db, "delete from transfers where fromaccount = %i;", 0, 0, 0, accountid );
sqlite_exec_printf ( db, "delete from transfers where toaccount = %i;", 0, 0, 0, accountid );
}
int Transfer::getNumberOfTransfers ()
{
char **results;
sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 );
return atoi ( results [ 1 ] );
}
int Transfer::getNumberOfTransfers ( int accountid )
{
char **results;
sqlite_get_table_printf ( db, "select count() from transfers where fromaccount = %i;", &results, 0, 0, 0, accountid );
int transfers = atoi ( results [ 1 ] );
sqlite_get_table_printf ( db, "select count() from transfers where toaccount = %i;", &results, 0, 0, 0, accountid );
transfers = transfers + atoi ( results [ 1 ] );
return transfers;
}
-void Transfer::displayTransfers ( QListView *listview, int accountid, bool children )
+void Transfer::displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate )
{
int showcleared = preferences->getPreference ( 3 );
// select the from transfers to display
char **results;
int rows, columns;
if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
{
if ( showcleared == 0 )
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and toparent = %i;", &results, &rows, &columns, 0, accountid );
else
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toparent = %i;", &results, &rows, &columns, 0, accountid );
}
else
{
if ( showcleared == 0 )
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and toaccount = %i;", &results, &rows, &columns, 0, accountid );
else
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toaccount = %i;", &results, &rows, &columns, 0, accountid );
}
// iterate through the list and display the from items
int counter = 7;
int position = 0;
while ( counter < ( ( rows + 1 ) * columns ) )
{
// construct the date
QString daystring = results [ counter ];
int day = daystring.toInt ();
QString monthstring = results [ counter + 1 ];
int month = monthstring.toInt ();
QString yearstring = results [ counter + 2 ];
int year = yearstring.toInt ();
QString date = preferences->getDate ( year, month, day );
+ QDate testdate ( year, month, day );
//construct the amount and id strings
QString amount = results [ counter + 3 ];
QString id = results [ counter + 4 ];
// construct the transaction name
QString transactionname = "FROM: ";
QString temp1 = results [ counter + 5 ];
transactionname.append ( account->getAccountName ( temp1.toInt() ) );
QString toaccount = account->getAccountName ( atol ( results [ counter + 6 ] ) );
+ if ( testdate >= displaydate || showcleared == 0 )
+ {
// display this transfer
if ( account->getParentAccountID ( accountid ) == -1 )
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, toaccount );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, toaccount );
}
else
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
}
-
+ }
counter = counter + 7;
}
// select the to transfers to display
char **toresults;
rows = 0;
columns = 0;
if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
{
if ( showcleared == 0 )
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and fromparent = %i;", &toresults, &rows, &columns, 0, accountid );
else
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where fromparent = %i;", &toresults, &rows, &columns, 0, accountid );
}
else
{
if ( showcleared == 0 )
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where cleared = 0 and fromaccount = %i;", &toresults, &rows, &columns, 0, accountid );
else
sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where fromaccount = %i;", &toresults, &rows, &columns, 0, accountid );
}
// iterate through the list and display the from items
counter = 7;
position = 0;
while ( counter < ( ( rows + 1 ) * columns ) )
{
// construct the date
QString daystring = toresults [ counter ];
int day = daystring.toInt ();
QString monthstring = toresults [ counter + 1 ];
int month = monthstring.toInt ();
QString yearstring = toresults [ counter + 2 ];
int year = yearstring.toInt ();
QString date = preferences->getDate ( year, month, day );
+ QDate testdate ( year, month, day );
//construct the amount and id strings
QString amount = toresults [ counter + 3 ];
amount.prepend ( "-" );
QString id = toresults [ counter + 4 ];
// construct the transaction name
QString transactionname = "TO: ";
QString temp1 = toresults [ counter + 6 ];
transactionname.append ( account->getAccountName ( temp1.toInt() ) );
QString fromaccount = account->getAccountName ( atol ( toresults [ counter + 5 ] ) );
+ if ( testdate >= displaydate || showcleared == 0 )
+ {
// display this transfer
if ( account->getParentAccountID ( accountid ) == -1 )
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, fromaccount );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, fromaccount );
}
else
{
if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
else
QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
}
+ }
counter = counter + 7;
}
}
int Transfer::getCleared ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select cleared from transfers where transferid= %i;", &results, 0, 0, 0, id );
return atoi ( results [ 1 ] );
}
void Transfer::setCleared ( int id, int cleared )
{
sqlite_exec_printf ( db, "update transfers set cleared = %i where transferid = %i;", 0, 0, 0, cleared, id );
}
int Transfer::getFromAccountID ( int id )
{
char **results;
sqlite_get_table_printf ( db, "select fromaccount from transfers where transferid= %i;", &results, 0, 0, 0, id );
return atoi ( results [ 1 ] );
}