Skip to content

Commit

Permalink
For transactions that have only 2 splits, re-creating the splits lose…
Browse files Browse the repository at this point in the history
…s all other attributes.

Fixes #701
  • Loading branch information
pnemonic78 authored and rivaldi8 committed Jul 3, 2017
1 parent badbe14 commit 957ae86
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ private List<Split> extractSplitsFromView(){

BigDecimal amountBigd = mAmountEditText.getValue();
String baseCurrencyCode = mTransactionsDbAdapter.getAccountCurrencyCode(mAccountUID);
Money value = new Money(amountBigd, Commodity.getInstance(baseCurrencyCode)).abs();
Money value = new Money(amountBigd, Commodity.getInstance(baseCurrencyCode));
Money quantity = new Money(value);

String transferAcctUID = getTransferAccountUID();
Expand All @@ -719,9 +719,24 @@ private List<Split> extractSplitsFromView(){
}
}

Split split1 = new Split(value, mAccountUID);
Split split1;
Split split2;
// Try to preserve the other split attributes.
if (mSplitsList.size() >= 2) {
split1 = mSplitsList.get(0);
split1.setValue(value);
split1.setQuantity(value);
split1.setAccountUID(mAccountUID);

split2 = mSplitsList.get(1);
split2.setValue(value);
split2.setQuantity(quantity);
split2.setAccountUID(transferAcctUID);
} else {
split1 = new Split(value, mAccountUID);
split2 = new Split(value, quantity, transferAcctUID);
}
split1.setType(mTransactionTypeSwitch.getTransactionType());
Split split2 = new Split(value, quantity, transferAcctUID);
split2.setType(mTransactionTypeSwitch.getTransactionType().invert());

List<Split> splitList = new ArrayList<>();
Expand Down

0 comments on commit 957ae86

Please sign in to comment.