File tree Expand file tree Collapse file tree
app/src/org/gnucash/android/db Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,6 +279,9 @@ public boolean destructiveDeleteAccount(long rowId){
279279 }
280280 }
281281 }
282+ // TODO: with "ON DELETE CASCADE", the first two delete will not be necessary.
283+ // deleteRecord(AccountEntry.TABLE_NAME, rowId); will delete related
284+ // transactions and splits
282285 //delete splits in this account
283286 mDb .delete (SplitEntry .TABLE_NAME ,
284287 SplitEntry .COLUMN_TRANSACTION_UID + " IN ( SELECT DISTINCT "
@@ -287,6 +290,14 @@ public boolean destructiveDeleteAccount(long rowId){
287290 + AccountEntry .TABLE_NAME + "_" + AccountEntry .COLUMN_UID
288291 + " = ? )" ,
289292 new String []{getAccountUID (rowId )});
293+ // delete empty transactions
294+ // trans_split_acct is an inner joint, empty transactions will
295+ // not be selected in this view
296+ mDb .delete (TransactionEntry .TABLE_NAME ,
297+ TransactionEntry .COLUMN_UID + " NOT IN ( SELECT DISTINCT "
298+ + TransactionEntry .TABLE_NAME + "_" + TransactionEntry .COLUMN_UID
299+ + " FROM trans_split_acct" ,
300+ null );
290301 deleteRecord (AccountEntry .TABLE_NAME , rowId );
291302 mDb .setTransactionSuccessful ();
292303 return true ;
You can’t perform that action at this time.
0 commit comments