Skip to content

Commit

Permalink
Fixed: QIF export always exports all transactions (not only new ones)
Browse files Browse the repository at this point in the history
Fixed: Exported QIF does not contain transaction description
Improved: Internationalized imbalance account name
Improved: Reliability of export. Progress dialog now displayed during export
  • Loading branch information
codinguser committed Dec 6, 2013
1 parent 4807991 commit 06875ff
Show file tree
Hide file tree
Showing 21 changed files with 561 additions and 267 deletions.
2 changes: 1 addition & 1 deletion app/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.gnucash.android"
android:versionCode="20"
android:versionCode="21"
android:versionName="1.2.6" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Ausgleichskonto</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d Unterkonto</item>
<item quantity="other">%d Unterkonten</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d υπο-λογαριασμός</item>
<item quantity="other">%d υπο-λογαριασμοί</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-es-rMX/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d subcuenta</item>
<item quantity="other">%d subcuentas</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sub-cuenta</item>
<item quantity="other">%d sub-cuentas</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sous-compte</item>
<item quantity="other">%d sous-comptes</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sub-account</item>
<item quantity="other">%d sub-accounts</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sotto-conto</item>
<item quantity="other">%d sotto-conti</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ format og importeres i regnskapsprogrammet GnuCash for PC.</string>
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d under-konto</item>
<item quantity="other">%d under-kontoer</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sub-account</item>
<item quantity="other">%d sub-accounts</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sub-contas</item>
<item quantity="other">%d sub-contas</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d дочерний счёт</item>
<item quantity="other">%d шт. дочерних счетов</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@
<string name="title_default_export_format">Default Export Format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d 子科目</item>
<item quantity="other">%d 子科目</item>
Expand Down
3 changes: 3 additions & 0 deletions app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@
<string name="key_default_export_format">default_export_format</string>
<string name="summary_default_export_format">File format to use by default when exporting transactions</string>
<string name="menu_export_transactions">Export transactions...</string>
<!-- This should be the same name used by GnuCash desktop for imbalance accounts -->
<string name="imbalance_account_name">Imbalance</string>
<string name="title_progress_exporting_transactions">Exporting transactions</string>
<plurals name="label_sub_accounts">
<item quantity="one">%d sub-account</item>
<item quantity="other">%d sub-accounts</item>
Expand Down
16 changes: 10 additions & 6 deletions app/src/org/gnucash/android/data/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.UUID;

import android.content.Context;
import org.gnucash.android.app.GnuCashApplication;
import org.gnucash.android.db.AccountsDbAdapter;
import org.gnucash.android.export.ofx.OfxExporter;
import org.gnucash.android.export.qif.QifHelper;
Expand Down Expand Up @@ -402,7 +403,7 @@ public static OfxAccountType convertToOfxAccountType(AccountType accountType){
* @param doc XML DOM document for the OFX data
* @param parent Parent node to which to add this account's transactions in XML
*/
public void toOfx(Document doc, Element parent, boolean allTransactions){
public void toOfx(Document doc, Element parent, boolean exportAllTransactions){
Element currency = doc.createElement("CURDEF");
currency.appendChild(doc.createTextNode(mCurrency.getCurrencyCode()));

Expand Down Expand Up @@ -459,7 +460,7 @@ public void toOfx(Document doc, Element parent, boolean allTransactions){
bankTransactionsList.appendChild(dtend);

for (Transaction transaction : mTransactionsList) {
if (!allTransactions && transaction.isExported())
if (!exportAllTransactions && transaction.isExported())
continue;

bankTransactionsList.appendChild(transaction.toOfx(doc, mUID));
Expand All @@ -478,14 +479,14 @@ public void toOfx(Document doc, Element parent, boolean allTransactions){

/**
* Exports the account info and transactions in the QIF format
* @param exportAll Flag to determine whether to export all transactions, or only new transactions since last export
* @param exportAllTransactions Flag to determine whether to export all transactions, or only new transactions since last export
* @return QIF representation of the account information
*/
public String toQIF(boolean exportAll, Context context) {
public String toQIF(boolean exportAllTransactions) {
StringBuffer accountQifBuffer = new StringBuffer();
final String newLine = "\n";

AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(context);
AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(GnuCashApplication.getAppContext());
String fullyQualifiedAccountName = accountsDbAdapter.getFullyQualifiedAccountName(mUID);
accountsDbAdapter.close();

Expand All @@ -502,7 +503,10 @@ public String toQIF(boolean exportAll, Context context) {
if (!transaction.getAccountUID().equals(mUID))
continue;

accountQifBuffer.append(transaction.toQIF(context) + newLine);
if (!exportAllTransactions && transaction.isExported())
continue;

accountQifBuffer.append(transaction.toQIF() + newLine);
}
return accountQifBuffer.toString();
}
Expand Down
34 changes: 15 additions & 19 deletions app/src/org/gnucash/android/data/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -434,33 +434,29 @@ public Element toOfx(Document doc, String accountUID){

/**
* Builds a QIF entry representing this transaction
* @param context Application context
* @return String QIF representation of this transaction
*/
public String toQIF(Context context){
public String toQIF(){
final String newLine = "\n";

AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(context);
AccountsDbAdapter accountsDbAdapter = new AccountsDbAdapter(GnuCashApplication.getAppContext());

//all transactions are double transactions
String splitAccountFullName = QifHelper.getImbalanceAccountName(mAmount.getCurrency());
if (mDoubleEntryAccountUID != null && mDoubleEntryAccountUID.length() > 0){
splitAccountFullName = accountsDbAdapter.getFullyQualifiedAccountName(mDoubleEntryAccountUID);
}

StringBuffer transactionQifBuffer = new StringBuffer();
transactionQifBuffer.append(QifHelper.DATE_PREFIX + QifHelper.formatDate(mTimestamp) + newLine);
transactionQifBuffer.append(QifHelper.DATE_PREFIX).append(QifHelper.formatDate(mTimestamp)).append(newLine);
transactionQifBuffer.append(QifHelper.MEMO_PREFIX).append(mName).append(newLine);

if (mDoubleEntryAccountUID != null && !mDoubleEntryAccountUID.isEmpty()){
String splitAccountFullName = accountsDbAdapter.getFullyQualifiedAccountName(mDoubleEntryAccountUID);
transactionQifBuffer.append(QifHelper.SPLIT_CATEGORY_PREFIX + splitAccountFullName + newLine);
if (mDescription != null || mDescription.isEmpty()){
transactionQifBuffer.append(QifHelper.SPLIT_MEMO_PREFIX + mDescription + newLine);
}
transactionQifBuffer.append(QifHelper.SPLIT_AMOUNT_PREFIX + mAmount.asString() + newLine);
} else {
transactionQifBuffer.append(QifHelper.AMOUNT_PREFIX + mAmount.asString() + newLine);
if (mDescription != null && !mDescription.isEmpty()){
transactionQifBuffer.append(QifHelper.MEMO_PREFIX + mDescription + newLine);
}
transactionQifBuffer.append(QifHelper.CATEGORY_PREFIX + QifHelper.getImbalanceAccountName(mAmount.getCurrency()) + newLine);
transactionQifBuffer.append(QifHelper.SPLIT_CATEGORY_PREFIX).append(splitAccountFullName).append(newLine);
if (mDescription != null && mDescription.length() > 0){
transactionQifBuffer.append(QifHelper.SPLIT_MEMO_PREFIX).append(mDescription).append(newLine);
}

transactionQifBuffer.append(QifHelper.ENTRY_TERMINATOR + newLine);
transactionQifBuffer.append(QifHelper.SPLIT_AMOUNT_PREFIX).append(mAmount.asString()).append(newLine);
transactionQifBuffer.append(QifHelper.ENTRY_TERMINATOR).append(newLine);

accountsDbAdapter.close();
return transactionQifBuffer.toString();
Expand Down
Loading

0 comments on commit 06875ff

Please sign in to comment.