/** * Converts all expenses into OFX XML format and adds them to the XML document * * @param doc DOM document of the OFX expenses. * @param parent Parent node for all expenses in report */ private void generateOfx(Document doc, Element parent) { Element transactionUid = doc.createElement(OfxHelper.TAG_TRANSACTION_UID); // unsolicited because the data exported is not as a result of a request transactionUid.appendChild(doc.createTextNode(OfxHelper.UNSOLICITED_TRANSACTION_ID)); Element statementTransactionResponse = doc.createElement(OfxHelper.TAG_STATEMENT_TRANSACTION_RESPONSE); statementTransactionResponse.appendChild(transactionUid); Element bankmsgs = doc.createElement(OfxHelper.TAG_BANK_MESSAGES_V1); bankmsgs.appendChild(statementTransactionResponse); parent.appendChild(bankmsgs); AccountsDbAdapter accountsDbAdapter = mAccountsDbAdapter; for (Account account : mAccountsList) { if (account.getTransactionCount() == 0) continue; // do not export imbalance accounts for OFX transactions and double-entry disabled if (!GnuCashApplication.isDoubleEntryEnabled() && account.getName().contains(mContext.getString(R.string.imbalance_account_name))) continue; // add account details (transactions) to the XML document account.toOfx(doc, statementTransactionResponse, mExportParams.getExportStartTime()); // mark as exported accountsDbAdapter.markAsExported(account.getUID()); } }
@Test public void simpleAccountListShouldNotContainTransactions() { Account account = new Account("Test"); Transaction transaction = new Transaction("Test description"); Split split = new Split(Money.getZeroInstance(), account.getUID()); transaction.addSplit(split); Account account1 = new Account("Transfer"); transaction.addSplit(split.createPair(account1.getUID())); mAccountsDbAdapter.addRecord(account); mAccountsDbAdapter.addRecord(account1); List<Account> accounts = mAccountsDbAdapter.getSimpleAccountList(); for (Account testAcct : accounts) { assertThat(testAcct.getTransactionCount()).isZero(); } }