Skip to content

Commit 84859f2

Browse files
committed
fix split type
1 parent 79b8890 commit 84859f2

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

app/src/org/gnucash/android/db/DatabaseHelper.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,26 +285,26 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
285285
+ SplitEntry.COLUMN_AMOUNT + " , "
286286
+ SplitEntry.COLUMN_ACCOUNT_UID + " , "
287287
+ SplitEntry.COLUMN_TRANSACTION_UID + " ) SELECT "
288-
// _ID, autogenerated
289288
+ "LOWER(HEX(RANDOMBLOB(16))) , "
290-
// COLUMN_MEMO, empty
291-
+ "CASE WHEN " + TransactionEntry.TABLE_NAME + "_bak.type IN ( 'CASH' , 'BANK', 'ASSET', 'EXPENSE', 'RECEIVABLE', 'STOCK', 'MUTUAL' ) THEN CASE WHEN "
292-
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'DEBIT' ELSE 'CREDIT' END ELSE CASE WHEN "
293-
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'CREDIT' ELSE 'DEBIT' END END , "
289+
+ "CASE WHEN " + AccountEntry.TABLE_NAME + "." + AccountEntry.COLUMN_TYPE + " IN ( 'CASH' , 'BANK', 'ASSET', 'EXPENSE', 'RECEIVABLE', 'STOCK', 'MUTUAL' ) THEN CASE WHEN "
290+
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'CREDIT' ELSE 'DEBIT' END ELSE CASE WHEN "
291+
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'DEBIT' ELSE 'CREDIT' END END , "
294292
+ "ABS ( " + TransactionEntry.TABLE_NAME + "_bak.amount ) , "
295293
+ TransactionEntry.TABLE_NAME + "_bak.account_uid , "
296294
+ TransactionEntry.TABLE_NAME + "_bak." + TransactionEntry.COLUMN_UID
297-
+ " FROM " + TransactionEntry.TABLE_NAME + "_bak UNION SELECT "
298-
// _ID, autogenerated
295+
+ " FROM " + TransactionEntry.TABLE_NAME + "_bak , " + AccountEntry.TABLE_NAME
296+
+ " ON " + TransactionEntry.TABLE_NAME + "_bak.account_uid = " + AccountEntry.TABLE_NAME + "." + AccountEntry.COLUMN_UID
297+
+ " UNION SELECT "
299298
+ "LOWER(HEX(RANDOMBLOB(16))) AS " + SplitEntry.COLUMN_UID + " , "
300-
// COLUMN_MEMO, empty
301-
+ "CASE WHEN " + TransactionEntry.TABLE_NAME + "_bak.type IN ( 'CASH' , 'BANK', 'ASSET', 'EXPENSE', 'RECEIVABLE', 'STOCK', 'MUTUAL' ) THEN CASE WHEN "
302-
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'CREDIT' ELSE 'DEBIT' END ELSE CASE WHEN "
303-
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'DEBIT' ELSE 'CREDIT' END END , "
299+
+ "CASE WHEN " + AccountEntry.TABLE_NAME + "." + AccountEntry.COLUMN_TYPE + " IN ( 'CASH' , 'BANK', 'ASSET', 'EXPENSE', 'RECEIVABLE', 'STOCK', 'MUTUAL' ) THEN CASE WHEN "
300+
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'DEBIT' ELSE 'CREDIT' END ELSE CASE WHEN "
301+
+ SplitEntry.COLUMN_AMOUNT + " < 0 THEN 'CREDIT' ELSE 'DEBIT' END END , "
304302
+ "ABS ( " + TransactionEntry.TABLE_NAME + "_bak.amount ) , "
305303
+ TransactionEntry.TABLE_NAME + "_bak." + KEY_DOUBLE_ENTRY_ACCOUNT_UID + " , "
306304
+ TransactionEntry.TABLE_NAME + "_baK." + TransactionEntry.COLUMN_UID
307-
+ " FROM " + TransactionEntry.TABLE_NAME + "_bak WHERE " + TransactionEntry.TABLE_NAME + "_bak." + KEY_DOUBLE_ENTRY_ACCOUNT_UID + " IS NOT NULL"
305+
+ " FROM " + TransactionEntry.TABLE_NAME + "_bak , " + AccountEntry.TABLE_NAME
306+
+ " ON " + TransactionEntry.TABLE_NAME + "_bak." + KEY_DOUBLE_ENTRY_ACCOUNT_UID + " = " + AccountEntry.TABLE_NAME + "." + AccountEntry.COLUMN_UID
307+
+ " WHERE " + TransactionEntry.TABLE_NAME + "_bak." + KEY_DOUBLE_ENTRY_ACCOUNT_UID + " IS NOT NULL"
308308
);
309309
// drop backup transaction table
310310
db.execSQL("DROP TABLE " + TransactionEntry.TABLE_NAME + "_bak");

0 commit comments

Comments
 (0)