Skip to content

Commit

Permalink
Fix exception after canceling creation of a new Recurring Transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAxelander committed Dec 6, 2023
1 parent f195882 commit 424f062
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [Fixed] Mapping Rules using the Account Name instead of Account Id [#199](https://github.com/TheAxelander/OpenBudgeteer/pull/199) Thanks [Lucaber](https://github.com/Lucaber)
* [Fixed] Adding a Mapping Rule to an existing Rule Set failed [#200](https://github.com/TheAxelander/OpenBudgeteer/pull/200) Thanks [Lucaber](https://github.com/Lucaber)
* [Fixed] Builds for ARM64 are available again [#131](https://github.com/TheAxelander/OpenBudgeteer/issues/131)
* [Fixed] Exception after canceling creation of a new Recurring Transactions [#210](https://github.com/TheAxelander/OpenBudgeteer/issues/210)

### 1.7.1 (2023-10-16)

Expand Down
8 changes: 7 additions & 1 deletion OpenBudgeteer.Blazor/Shared/RecurringTransactionDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<td><input class="form-control form-control-sm number-input" type="number" @bind="transaction.Amount" /></td>
<td class="col-buttons">
<button class="btn btn-sm btn-primary bi bi-check-lg" @onclick="@(() => SaveTransaction(transaction))"></button>
<button class="btn btn-sm btn-danger bi bi-x-lg" @onclick="@(() => transaction.CancelModification())"></button>
<button class="btn btn-sm btn-danger bi bi-x-lg" @onclick="@(() => CancelTransaction(transaction))"></button>
</td>
</tr>
}
Expand Down Expand Up @@ -165,6 +165,12 @@
await HandleResult(transaction.CreateOrUpdateTransaction());
}

void CancelTransaction(RecurringTransactionViewModel transaction)
{
transaction.CancelModification();
if (transaction.RecurringTransactionId == Guid.Empty) DataContext.Transactions.Remove(transaction);
}

void TransactionRecurrenceType_SelectionChanged(string? value, RecurringTransactionViewModel transaction)
{
if (string.IsNullOrEmpty(value)) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,17 @@ public void StartModification()
/// </summary>
public void CancelModification()
{
AccountId = _oldRecurringTransactionViewModelItem!.AccountId;
RecurrenceType = _oldRecurringTransactionViewModelItem!.RecurrenceType;
RecurrenceAmount = _oldRecurringTransactionViewModelItem!.RecurrenceAmount;
Payee = _oldRecurringTransactionViewModelItem!.Payee;
Memo = _oldRecurringTransactionViewModelItem!.Memo;
Amount = _oldRecurringTransactionViewModelItem!.Amount;
FirstOccurrenceDate = _oldRecurringTransactionViewModelItem!.FirstOccurrenceDate;
SelectedAccount = _oldRecurringTransactionViewModelItem.SelectedAccount;
if (_oldRecurringTransactionViewModelItem != null)
{
AccountId = _oldRecurringTransactionViewModelItem.AccountId;
RecurrenceType = _oldRecurringTransactionViewModelItem.RecurrenceType;
RecurrenceAmount = _oldRecurringTransactionViewModelItem.RecurrenceAmount;
Payee = _oldRecurringTransactionViewModelItem.Payee;
Memo = _oldRecurringTransactionViewModelItem.Memo;
Amount = _oldRecurringTransactionViewModelItem.Amount;
FirstOccurrenceDate = _oldRecurringTransactionViewModelItem.FirstOccurrenceDate;
SelectedAccount = _oldRecurringTransactionViewModelItem.SelectedAccount;
}
InModification = false;
_oldRecurringTransactionViewModelItem = null;
}
Expand Down

0 comments on commit 424f062

Please sign in to comment.