From ff1d7ff0b0979e71c80222954e04ddf01d71c8dd Mon Sep 17 00:00:00 2001 From: AJ Date: Sun, 19 Oct 2025 16:57:29 -0400 Subject: [PATCH] Feature: add Unmap button to prevent accidental receipt deletion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add safer workflow for fixing incorrectly mapped receipts: - Add OnPostUnmapReceiptAsync handler that sets TransactionId to null - Add "Unmap" button (warning color) before Delete button - Update Delete confirmation to emphasize PERMANENT deletion - Unmap success message guides user to Receipts page This prevents accidental loss of receipt files when users just want to remap them to a different transaction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- MoneyMap/Pages/EditTransaction.cshtml | 7 +++++-- MoneyMap/Pages/EditTransaction.cshtml.cs | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/MoneyMap/Pages/EditTransaction.cshtml b/MoneyMap/Pages/EditTransaction.cshtml index f7cca2b..952d999 100644 --- a/MoneyMap/Pages/EditTransaction.cshtml +++ b/MoneyMap/Pages/EditTransaction.cshtml @@ -159,7 +159,7 @@ @((item.Receipt.FileSizeBytes / 1024.0).ToString("F1")) KB - · @item.Receipt.UploadedAtUtc.ToLocalTime().ToString("MMM d, yyyy") + � @item.Receipt.UploadedAtUtc.ToLocalTime().ToString("MMM d, yyyy") @if (!string.IsNullOrWhiteSpace(item.Receipt.Merchant)) { @@ -208,8 +208,11 @@ } +
+ +
+ onsubmit="return confirm('Are you sure? This will PERMANENTLY DELETE the receipt file!')" class="d-inline">
diff --git a/MoneyMap/Pages/EditTransaction.cshtml.cs b/MoneyMap/Pages/EditTransaction.cshtml.cs index 9c86c2f..d7d856a 100644 --- a/MoneyMap/Pages/EditTransaction.cshtml.cs +++ b/MoneyMap/Pages/EditTransaction.cshtml.cs @@ -181,13 +181,30 @@ namespace MoneyMap.Pages return RedirectToPage(new { id = Transaction.Id }); } + public async Task OnPostUnmapReceiptAsync(long receiptId) + { + var receipt = await _db.Receipts.FindAsync(receiptId); + if (receipt != null) + { + receipt.TransactionId = null; + await _db.SaveChangesAsync(); + SuccessMessage = "Receipt unmapped successfully! You can now find it on the Receipts page."; + } + else + { + ErrorMessage = "Receipt not found."; + } + + return RedirectToPage(new { id = Transaction.Id }); + } + public async Task OnPostDeleteReceiptAsync(long receiptId) { var success = await _receiptManager.DeleteReceiptAsync(receiptId); if (success) { - SuccessMessage = "Receipt deleted successfully!"; + SuccessMessage = "Receipt deleted permanently!"; } else {