Skip to content

Commit

Permalink
codinguser#876 - Fix NPE when type switching on a new transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanGarf committed May 28, 2020
1 parent b59e69b commit eb0f00d
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,11 @@ private void setListeners() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {

// Compute balance signed value of saved transaction
final Money signedTransactionBalance = mTransaction.getBalance(mAccountUID);
// UI to Transaction
Transaction transaction = extractTransactionFromView();

// Compute balance signed value of transaction
final Money signedTransactionBalance = transaction.getBalance(mAccountUID);

// Update Amount Signum
updateAmountEditText(signedTransactionBalance);
Expand Down Expand Up @@ -984,6 +987,13 @@ private List<Split> extractSplitsFromView() {
transaction.setSplits(splits);
transaction.setExported(false); //not necessary as exports use timestamps now. Because, legacy

if (mEditMode) {
// Editing an existing transaction

// reset the transaction UID
transaction.setUID(mTransaction.getUID());
}

return transaction;
}

Expand Down Expand Up @@ -1029,13 +1039,16 @@ private void saveNewTransaction() {
return;
}

Transaction transaction = extractTransactionFromView();
//
// UI to Transaction, with same UID if transaction edit mode
//

mTransaction = extractTransactionFromView();

if (mEditMode) { //if editing an existing transaction
transaction.setUID(mTransaction.getUID());
}
//
// Save transaction in DB
//

mTransaction = transaction;
mAccountsDbAdapter.beginTransaction();

try {
Expand Down

0 comments on commit eb0f00d

Please sign in to comment.