diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e06fdacf..5c6e8367a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ Change Log =============================================================================== +Version 1.4.3 *(2014-09-09)* +---------------------------- +* Fixed: Cannot edit transactions when in single-entry mode +* Fixed: Transaction type button sometimes hidden in single-entry mode +* Fixed: Problems saving new transactions from templates + Version 1.4.2 *(2014-08-30)* ---------------------------- * Fixed: Newly added transactions cannot be exported diff --git a/app/AndroidManifest.xml b/app/AndroidManifest.xml index cc818e0d0..3bf8f69d6 100644 --- a/app/AndroidManifest.xml +++ b/app/AndroidManifest.xml @@ -17,7 +17,7 @@ diff --git a/app/pom.xml b/app/pom.xml index 02505ab33..7f873c846 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -22,7 +22,7 @@ Gnucash Android companion application - 1.4.2-SNAPSHOT + 1.4.3-SNAPSHOT org.gnucash.android gnucash-android-parent diff --git a/app/res/values/strings.xml b/app/res/values/strings.xml index 83ace0a89..3318d3170 100644 --- a/app/res/values/strings.xml +++ b/app/res/values/strings.xml @@ -17,7 +17,7 @@ GnuCash - 1.4.2 + 1.4.3 Create Account Edit Account Info diff --git a/app/src/org/gnucash/android/db/SplitsDbAdapter.java b/app/src/org/gnucash/android/db/SplitsDbAdapter.java index b5437388e..bba50dc39 100644 --- a/app/src/org/gnucash/android/db/SplitsDbAdapter.java +++ b/app/src/org/gnucash/android/db/SplitsDbAdapter.java @@ -286,6 +286,9 @@ public String getUID(long id){ * @return Cursor to splits */ public Cursor fetchSplitsForTransaction(String transactionUID){ + if (transactionUID == null) + throw new IllegalArgumentException("Transaction UID cannot be null"); + Log.v(TAG, "Fetching all splits for transaction UID " + transactionUID); return mDb.query(SplitEntry.TABLE_NAME, null, SplitEntry.COLUMN_TRANSACTION_UID + " = ?", @@ -390,6 +393,17 @@ public boolean deleteRecord(long rowId) { return result; } + /** + * Deletes a split from the database. + * This is a convenience method which essentially calls {@link #deleteRecord(long)} + * @param uid String unique ID of split + * @return true if the split was deleted, false otherwise + */ + public boolean deleteSplit(String uid){ + long id = getID(uid); + return deleteRecord(id); + } + /** * Returns the database record ID for the specified transaction UID * @param transactionUID Unique idendtifier of the transaction diff --git a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java index 2f391b2a2..df9184c6b 100644 --- a/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java +++ b/app/src/org/gnucash/android/ui/transaction/TransactionFormFragment.java @@ -209,7 +209,7 @@ public void onActivityCreated(Bundle savedInstanceState) { actionBar.setDisplayShowTitleEnabled(false); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), true); + mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), false); if (!mUseDoubleEntry){ getView().findViewById(R.id.layout_double_entry).setVisibility(View.GONE); mOpenSplitsButton.setVisibility(View.GONE); @@ -306,7 +306,9 @@ public void onItemClick(AdapterView adapterView, View view, int position, lon mSplitsList.clear(); setAmountEditViewVisible(View.VISIBLE); } else { - setAmountEditViewVisible(View.GONE); + if (mUseDoubleEntry) { //don't hide the view in single entry mode + setAmountEditViewVisible(View.GONE); + } } } mTransaction = null; //we are creating a new transaction after all @@ -346,7 +348,7 @@ private void initializeViewsWithTransaction(){ } else { for (Split split : mTransaction.getSplits()) { //two splits, one belongs to this account and the other to another account - if (!split.getAccountUID().equals(accountUID)) { + if (mUseDoubleEntry && !split.getAccountUID().equals(accountUID)) { setSelectedTransferAccount(mAccountsDbAdapter.getAccountID(split.getAccountUID())); } } @@ -593,15 +595,30 @@ private void saveNewTransaction() { if (mTransaction != null){ if (!mUseDoubleEntry){ + //first remove old splits for this transaction, since there is only one split + SplitsDbAdapter splitsDbAdapter = new SplitsDbAdapter(getActivity()); + for (Split split : mTransaction.getSplits()) { + splitsDbAdapter.deleteSplit(split.getUID()); + } + splitsDbAdapter.close(); + Split split = new Split(amount, accountUID); split.setType(mTransactionTypeButton.getTransactionType()); mTransaction.getSplits().clear(); mTransaction.addSplit(split); - } else + } else { mTransaction.setSplits(mSplitsList); + } mTransaction.setDescription(description); } else { mTransaction = new Transaction(description); + if (!mUseDoubleEntry){ + Split split = new Split(amount, accountUID); + split.setType(mTransactionTypeButton.getTransactionType()); + mSplitsList.clear(); + mSplitsList.add(split); + } + if (mSplitsList.isEmpty()) { //amount entered in the simple interface (not using splits Editor) Split split = new Split(amount, accountUID); split.setType(mTransactionTypeButton.getTransactionType()); @@ -707,8 +724,7 @@ public void setSplitList(List splitList, List removedSplitUIDs){ //once we set the split list, do not allow direct editing of the total if (mSplitsList.size() > 1){ mAmountEditText.setEnabled(false); - mTransactionTypeButton.setVisibility(View.GONE); - getView().findViewById(R.id.layout_double_entry).setVisibility(View.GONE); + setAmountEditViewVisible(View.GONE); } SplitsDbAdapter splitsDbAdapter = new SplitsDbAdapter(getActivity()); diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 60ae29384..cba85f06d 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -17,7 +17,7 @@ 4.0.0 - 1.4.2-SNAPSHOT + 1.4.3-SNAPSHOT org.gnucash.android gnucash-android-parent diff --git a/pom.xml b/pom.xml index 996fc3e84..aa8501da9 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 4.0.0 - 1.4.2-SNAPSHOT + 1.4.3-SNAPSHOT org.gnucash.android gnucash-android-parent GnuCash Android parent