Skip to content

Commit

Permalink
Fixed: opening split dialog but without adding splits causes transfer…
Browse files Browse the repository at this point in the history
… account to be ignored when saving a transaction
  • Loading branch information
codinguser committed Aug 9, 2015
1 parent 9642d76 commit 7cd4386
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,17 @@ private void saveNewTransaction() {
Currency currency = Currency.getInstance(mTransactionsDbAdapter.getAccountCurrencyCode(mAccountUID));
Money amount = new Money(amountBigd, currency).absolute();

if (mSplitsList.size() == 1){ //means split editor was opened but no split was added
String transferAcctUID;
if (mUseDoubleEntry) {
long transferAcctId = mDoubleAccountSpinner.getSelectedItemId();
transferAcctUID = mAccountsDbAdapter.getUID(transferAcctId);
} else {
transferAcctUID = mAccountsDbAdapter.getOrCreateImbalanceAccountUID(currency);
}
mSplitsList.add(mSplitsList.get(0).createPair(transferAcctUID));
}

//capture any edits which were done directly (not using split editor)
if (mSplitsList.size() == 2 && mSplitsList.get(0).isPairOf(mSplitsList.get(1))) {
//if it is a simple transfer where the editor was not used, then respect the button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onActivityCreated(Bundle savedInstanceState) {

getDialog().setTitle(R.string.title_transaction_splits);

mSplitItemViewList = new ArrayList<View>();
mSplitItemViewList = new ArrayList<>();
mSplitsDbAdapter = SplitsDbAdapter.getInstance();

//we are editing splits for a new transaction.
Expand Down

0 comments on commit 7cd4386

Please sign in to comment.