Diffstat (limited to 'noncore/apps/qashmoney/transfer.cpp') (more/less context) (ignore whitespace changes)
-rwxr-xr-x | noncore/apps/qashmoney/transfer.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/apps/qashmoney/transfer.cpp b/noncore/apps/qashmoney/transfer.cpp index 568d584..c4bbaf9 100755 --- a/noncore/apps/qashmoney/transfer.cpp +++ b/noncore/apps/qashmoney/transfer.cpp | |||
@@ -1,85 +1,85 @@ | |||
1 | #include "transfer.h" | 1 | #include "transfer.h" |
2 | #include "account.h" | 2 | #include "account.h" |
3 | #include "transactiondisplay.h" | 3 | #include "transactiondisplay.h" |
4 | #include <stdlib.h> | 4 | #include <stdlib.h> |
5 | #include <iostream.h> | 5 | #include <iostream.h> |
6 | 6 | ||
7 | extern Account *account; | 7 | extern Account *account; |
8 | extern Preferences *preferences; | 8 | extern Preferences *preferences; |
9 | 9 | ||
10 | Transfer::Transfer () | 10 | Transfer::Transfer () |
11 | { | 11 | { |
12 | db = sqlite_open ( "qmtransfers.db", 0, 0 ); | 12 | db = sqlite_open ( "qmtransfers.db", 0, 0 ); |
13 | } | 13 | } |
14 | 14 | ||
15 | Transfer::~Transfer () | 15 | Transfer::~Transfer () |
16 | { | 16 | { |
17 | sqlite_close ( db ); | 17 | sqlite_close ( db ); |
18 | } | 18 | } |
19 | 19 | ||
20 | void Transfer::addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared ) | 20 | void Transfer::addTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared ) |
21 | { | 21 | { |
22 | int nextrowid = -1; | 22 | int nextrowid = -1; |
23 | char **results; | 23 | char **results; |
24 | sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 ); | 24 | sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 ); |
25 | if ( atoi ( results [ 1 ] ) != 0 ) | 25 | if ( atoi ( results [ 1 ] ) != 0 ) |
26 | { | 26 | { |
27 | char **results; | 27 | char **results; |
28 | sqlite_get_table ( db, "select min ( rowid ) from transfers;", &results, 0, 0, 0 ); | 28 | sqlite_get_table ( db, "select min ( rowid ) from transfers;", &results, 0, 0, 0 ); |
29 | nextrowid = ( atoi ( results [ 1 ] ) ) - 1; | 29 | nextrowid = ( atoi ( results [ 1 ] ) ) - 1; |
30 | } | 30 | } |
31 | sqlite_exec_printf ( db, "insert into transfers values ( %i, %i, %i, %i, %i, %i, %i, 0, 0, %.2f, %i, 0, 0, 0, 0, 0, %i );", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, nextrowid ); | 31 | sqlite_exec_printf ( db, "insert into transfers values ( %i, %i, %i, %i, %i, %i, %i, 0, 0, %.2f, %i, 0, 0, 0, 0, 0, %i );", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, nextrowid ); |
32 | } | 32 | } |
33 | 33 | ||
34 | void Transfer::updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid ) | 34 | void Transfer::updateTransfer ( int fromaccount, int fromparent, int toaccount, int toparent, int day, int month, int year, float amount, int cleared, int transferid ) |
35 | { | 35 | { |
36 | sqlite_exec_printf ( db, "update transfers set fromaccount = %i, fromparent = %i, toaccount = %i, toparent = %i, day = %i, month = %i, year = %i, | 36 | sqlite_exec_printf ( db, "update transfers set fromaccount = %i, fromparent = %i, toaccount = %i, toparent = %i, day = %i, month = %i, year = %i," |
37 | amount = %.2f, cleared = %i where transferid = %i;", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, transferid ); | 37 | "amount = %.2f, cleared = %i where transferid = %i;", 0, 0, 0, fromaccount, fromparent, toaccount, toparent, day, month, year, amount, cleared, transferid ); |
38 | } | 38 | } |
39 | 39 | ||
40 | void Transfer::deleteTransfer ( int transferid ) | 40 | void Transfer::deleteTransfer ( int transferid ) |
41 | { | 41 | { |
42 | sqlite_exec_printf ( db, "delete from transfers where transferid = %i;", 0, 0, 0, transferid ); | 42 | sqlite_exec_printf ( db, "delete from transfers where transferid = %i;", 0, 0, 0, transferid ); |
43 | } | 43 | } |
44 | 44 | ||
45 | void Transfer::deleteAllTransfers ( int accountid ) | 45 | void Transfer::deleteAllTransfers ( int accountid ) |
46 | { | 46 | { |
47 | sqlite_exec_printf ( db, "delete from transfers where fromaccount = %i;", 0, 0, 0, accountid ); | 47 | sqlite_exec_printf ( db, "delete from transfers where fromaccount = %i;", 0, 0, 0, accountid ); |
48 | sqlite_exec_printf ( db, "delete from transfers where toaccount = %i;", 0, 0, 0, accountid ); | 48 | sqlite_exec_printf ( db, "delete from transfers where toaccount = %i;", 0, 0, 0, accountid ); |
49 | } | 49 | } |
50 | 50 | ||
51 | int Transfer::getNumberOfTransfers () | 51 | int Transfer::getNumberOfTransfers () |
52 | { | 52 | { |
53 | char **results; | 53 | char **results; |
54 | sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 ); | 54 | sqlite_get_table ( db, "select count() from transfers;", &results, 0, 0, 0 ); |
55 | return atoi ( results [ 1 ] ); | 55 | return atoi ( results [ 1 ] ); |
56 | } | 56 | } |
57 | 57 | ||
58 | int Transfer::getNumberOfTransfers ( int accountid ) | 58 | int 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 | ||
68 | void Transfer::displayTransfers ( QListView *listview, int accountid, bool children, QDate displaydate ) | 68 | void 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 ); |
81 | } | 81 | } |
82 | else | 82 | else |
83 | { | 83 | { |
84 | if ( showcleared == 0 ) | 84 | if ( showcleared == 0 ) |
85 | 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 ); | 85 | 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 ); |