summaryrefslogtreecommitdiff
path: root/noncore/apps/qashmoney/transfer.cpp
Unidiff
Diffstat (limited to 'noncore/apps/qashmoney/transfer.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-xnoncore/apps/qashmoney/transfer.cpp61
1 files changed, 34 insertions, 27 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
@@ -56,25 +56,25 @@ int Transfer::getNumberOfTransfers ()
56 } 56 }
57 57
58int Transfer::getNumberOfTransfers ( int accountid ) 58int Transfer::getNumberOfTransfers ( int accountid )
59 { 59 {
60 char **results; 60 char **results;
61 sqlite_get_table_printf ( db, "select count() from transfers where fromaccount = %i;", &results, 0, 0, 0, accountid ); 61 sqlite_get_table_printf ( db, "select count() from transfers where fromaccount = %i;", &results, 0, 0, 0, accountid );
62 int transfers = atoi ( results [ 1 ] ); 62 int transfers = atoi ( results [ 1 ] );
63 sqlite_get_table_printf ( db, "select count() from transfers where toaccount = %i;", &results, 0, 0, 0, accountid ); 63 sqlite_get_table_printf ( db, "select count() from transfers where toaccount = %i;", &results, 0, 0, 0, accountid );
64 transfers = transfers + atoi ( results [ 1 ] ); 64 transfers = transfers + atoi ( results [ 1 ] );
65 return transfers; 65 return transfers;
66 } 66 }
67 67
68void Transfer::displayTransfers ( QListView *listview, int accountid, bool children ) 68void Transfer::displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate )
69 { 69 {
70 int showcleared = preferences->getPreference ( 3 ); 70 int showcleared = preferences->getPreference ( 3 );
71 71
72 // select the from transfers to display 72 // select the from transfers to display
73 char **results; 73 char **results;
74 int rows, columns; 74 int rows, columns;
75 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE ) 75 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
76 { 76 {
77 if ( showcleared == 0 ) 77 if ( showcleared == 0 )
78 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 ); 78 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 );
79 else 79 else
80 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toparent = %i;", &results, &rows, &columns, 0, accountid ); 80 sqlite_get_table_printf ( db, "select day, month, year, amount, transferid, fromaccount, toaccount from transfers where toparent = %i;", &results, &rows, &columns, 0, accountid );
@@ -91,52 +91,55 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
91 int counter = 7; 91 int counter = 7;
92 int position = 0; 92 int position = 0;
93 while ( counter < ( ( rows + 1 ) * columns ) ) 93 while ( counter < ( ( rows + 1 ) * columns ) )
94 { 94 {
95 // construct the date 95 // construct the date
96 QString daystring = results [ counter ]; 96 QString daystring = results [ counter ];
97 int day = daystring.toInt (); 97 int day = daystring.toInt ();
98 QString monthstring = results [ counter + 1 ]; 98 QString monthstring = results [ counter + 1 ];
99 int month = monthstring.toInt (); 99 int month = monthstring.toInt ();
100 QString yearstring = results [ counter + 2 ]; 100 QString yearstring = results [ counter + 2 ];
101 int year = yearstring.toInt (); 101 int year = yearstring.toInt ();
102 QString date = preferences->getDate ( year, month, day ); 102 QString date = preferences->getDate ( year, month, day );
103 QDate testdate ( year, month, day );
103 104
104 //construct the amount and id strings 105 //construct the amount and id strings
105 QString amount = results [ counter + 3 ]; 106 QString amount = results [ counter + 3 ];
106 QString id = results [ counter + 4 ]; 107 QString id = results [ counter + 4 ];
107 108
108 // construct the transaction name 109 // construct the transaction name
109 QString transactionname = "FROM: "; 110 QString transactionname = "FROM: ";
110 QString temp1 = results [ counter + 5 ]; 111 QString temp1 = results [ counter + 5 ];
111 transactionname.append ( account->getAccountName ( temp1.toInt() ) ); 112 transactionname.append ( account->getAccountName ( temp1.toInt() ) );
112 113
113 QString toaccount = account->getAccountName ( atol ( results [ counter + 6 ] ) ); 114 QString toaccount = account->getAccountName ( atol ( results [ counter + 6 ] ) );
114 115
115 // display this transfer 116 if ( testdate >= displaydate || showcleared == 0 )
116 if ( account->getParentAccountID ( accountid ) == -1 )
117 { 117 {
118 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 ) 118 // display this transfer
119 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, toaccount ); 119 if ( account->getParentAccountID ( accountid ) == -1 )
120 {
121 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
122 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, toaccount );
123 else
124 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, toaccount );
125 }
120 else 126 else
121 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, toaccount ); 127 {
128 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
129 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
130 else
131 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
132 }
122 } 133 }
123 else
124 {
125 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
126 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
127 else
128 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
129 }
130
131 counter = counter + 7; 134 counter = counter + 7;
132 } 135 }
133 136
134 // select the to transfers to display 137 // select the to transfers to display
135 char **toresults; 138 char **toresults;
136 rows = 0; 139 rows = 0;
137 columns = 0; 140 columns = 0;
138 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE ) 141 if ( account->getParentAccountID ( accountid ) == -1 && children == TRUE )
139 { 142 {
140 if ( showcleared == 0 ) 143 if ( showcleared == 0 )
141 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 ); 144 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 );
142 else 145 else
@@ -154,51 +157,55 @@ void Transfer::displayTransfers ( QListView *listview, int accountid, bool child
154 counter = 7; 157 counter = 7;
155 position = 0; 158 position = 0;
156 while ( counter < ( ( rows + 1 ) * columns ) ) 159 while ( counter < ( ( rows + 1 ) * columns ) )
157 { 160 {
158 // construct the date 161 // construct the date
159 QString daystring = toresults [ counter ]; 162 QString daystring = toresults [ counter ];
160 int day = daystring.toInt (); 163 int day = daystring.toInt ();
161 QString monthstring = toresults [ counter + 1 ]; 164 QString monthstring = toresults [ counter + 1 ];
162 int month = monthstring.toInt (); 165 int month = monthstring.toInt ();
163 QString yearstring = toresults [ counter + 2 ]; 166 QString yearstring = toresults [ counter + 2 ];
164 int year = yearstring.toInt (); 167 int year = yearstring.toInt ();
165 QString date = preferences->getDate ( year, month, day ); 168 QString date = preferences->getDate ( year, month, day );
169 QDate testdate ( year, month, day );
166 170
167 //construct the amount and id strings 171 //construct the amount and id strings
168 QString amount = toresults [ counter + 3 ]; 172 QString amount = toresults [ counter + 3 ];
169 amount.prepend ( "-" ); 173 amount.prepend ( "-" );
170 QString id = toresults [ counter + 4 ]; 174 QString id = toresults [ counter + 4 ];
171 175
172 // construct the transaction name 176 // construct the transaction name
173 QString transactionname = "TO: "; 177 QString transactionname = "TO: ";
174 QString temp1 = toresults [ counter + 6 ]; 178 QString temp1 = toresults [ counter + 6 ];
175 transactionname.append ( account->getAccountName ( temp1.toInt() ) ); 179 transactionname.append ( account->getAccountName ( temp1.toInt() ) );
176 180
177 QString fromaccount = account->getAccountName ( atol ( toresults [ counter + 5 ] ) ); 181 QString fromaccount = account->getAccountName ( atol ( toresults [ counter + 5 ] ) );
178 182
179 // display this transfer 183 if ( testdate >= displaydate || showcleared == 0 )
180 if ( account->getParentAccountID ( accountid ) == -1 ) 184 {
181 { 185 // display this transfer
182 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 ) 186 if ( account->getParentAccountID ( accountid ) == -1 )
183 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, fromaccount ); 187 {
184 else 188 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
185 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, fromaccount ); 189 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id, fromaccount );
186 } 190 else
187 else 191 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id, fromaccount );
188 { 192 }
189 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
190 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
191 else 193 else
192 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id ); 194 {
195 if ( showcleared == 1 && getCleared ( id.toInt() ) == 1 )
196 ColorListItem *item = new ColorListItem ( listview, date, transactionname, amount, id );
197 else
198 QListViewItem *item = new QListViewItem ( listview, date, transactionname, amount, id );
199 }
193 } 200 }
194 201
195 counter = counter + 7; 202 counter = counter + 7;
196 } 203 }
197 } 204 }
198 205
199int Transfer::getCleared ( int id ) 206int Transfer::getCleared ( int id )
200 { 207 {
201 char **results; 208 char **results;
202 sqlite_get_table_printf ( db, "select cleared from transfers where transferid= %i;", &results, 0, 0, 0, id ); 209 sqlite_get_table_printf ( db, "select cleared from transfers where transferid= %i;", &results, 0, 0, 0, id );
203 return atoi ( results [ 1 ] ); 210 return atoi ( results [ 1 ] );
204 } 211 }