diff --git a/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java b/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java index e1ce60469..2b2a5654c 100644 --- a/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java +++ b/app/src/main/java/org/gnucash/android/export/qif/QifExporter.java @@ -63,6 +63,7 @@ public void generateExport(Writer writer) throws ExporterException { SplitEntry.TABLE_NAME + "_" + SplitEntry.COLUMN_TYPE + " AS split_type", SplitEntry.TABLE_NAME + "_" + SplitEntry.COLUMN_MEMO + " AS split_memo", "trans_extra_info.trans_acct_balance AS trans_acct_balance", + "trans_extra_info.trans_split_count AS trans_split_count", "account1." + AccountEntry.COLUMN_UID + " AS acct1_uid", "account1." + AccountEntry.COLUMN_FULL_NAME + " AS acct1_full_name", "account1." + AccountEntry.COLUMN_CURRENCY + " AS acct1_currency", @@ -74,7 +75,9 @@ public void generateExport(Writer writer) throws ExporterException { // exclude transactions involving multiple currencies "trans_extra_info.trans_currency_count = 1 AND " + // in qif, split from the one account entry is not recorded (will be auto balanced) - AccountEntry.TABLE_NAME + "_" + AccountEntry.COLUMN_UID + " != account1." + AccountEntry.COLUMN_UID + + "( " + AccountEntry.TABLE_NAME + "_" + AccountEntry.COLUMN_UID + " != account1." + AccountEntry.COLUMN_UID + " OR " + + // or if the transaction has only one split (the whole transaction would be lost if it is not selected) + "trans_split_count == 1 )" + ( mParameters.shouldExportAllTransactions() ? "" : " AND " + TransactionEntry.TABLE_NAME + "_" + TransactionEntry.COLUMN_EXPORTED + "== 0" @@ -140,6 +143,10 @@ public void generateExport(Writer writer) throws ExporterException { .append(newLine); } } + if (cursor.getInt(cursor.getColumnIndexOrThrow("trans_split_count")) == 1) { + // No other splits should be recorded if this is the only split. + continue; + } // all splits // amount associated with the header account will not be exported. // It can be auto balanced when importing to GnuCash