Simplify payment column display in transactions table
Condensed the verbose payment method labels to show only the essential information: - Card transactions: Show just the card name (e.g., "AJ's Debit Card") - Direct account transactions: Show just the account name - Transfers: Show "Transfer → [Destination]" Removed duplicate display of account information since cards are already linked to accounts. This makes the Payment/Account column much less crowded and easier to read. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@ using System.Transactions;
|
||||
|
||||
namespace MoneyMap.Models;
|
||||
|
||||
[Index(nameof(Date), nameof(Amount), nameof(Name), nameof(Memo), nameof(CardId), nameof(AccountId), IsUnique = true)]
|
||||
[Index(nameof(Date), nameof(Amount), nameof(Name), nameof(Memo), nameof(AccountId), nameof(CardId), IsUnique = true)]
|
||||
public class Transaction
|
||||
{
|
||||
[Key]
|
||||
@@ -31,37 +31,51 @@ public class Transaction
|
||||
|
||||
public string Notes { get; set; } = string.Empty;
|
||||
|
||||
// Payment method - EITHER Card OR Account (not both)
|
||||
// For credit/debit card transactions
|
||||
// Primary container: Every transaction belongs to an Account (the source of CSV)
|
||||
[Required]
|
||||
[ForeignKey(nameof(Account))]
|
||||
public int AccountId { get; set; }
|
||||
public Account Account { get; set; } = null!;
|
||||
|
||||
// Optional: Card used for this transaction (if it was a card payment)
|
||||
[ForeignKey(nameof(Card))]
|
||||
public int? CardId { get; set; }
|
||||
public Card? Card { get; set; }
|
||||
|
||||
// For bank account transactions (checking, savings)
|
||||
[ForeignKey(nameof(Account))]
|
||||
public int? AccountId { get; set; }
|
||||
public Account? Account { get; set; }
|
||||
// Optional: For transfers between accounts, this links to the destination account
|
||||
// This transaction is the "source" side of the transfer (debit)
|
||||
// The matching transaction in the destination account has this AccountId as its TransferToAccountId
|
||||
[ForeignKey(nameof(TransferToAccount))]
|
||||
public int? TransferToAccountId { get; set; }
|
||||
public Account? TransferToAccount { get; set; }
|
||||
|
||||
[MaxLength(4)]
|
||||
public string? Last4 { get; set; } // parsed from Memo if present (replaces CardLast4)
|
||||
public string? Last4 { get; set; } // parsed from Memo if present
|
||||
|
||||
public ICollection<Receipt> Receipts { get; set; } = new List<Receipt>();
|
||||
|
||||
[NotMapped] public bool IsCredit => Amount > 0;
|
||||
[NotMapped] public bool IsDebit => Amount < 0;
|
||||
[NotMapped] public bool IsTransfer => TransferToAccountId.HasValue;
|
||||
|
||||
[NotMapped]
|
||||
public string PaymentMethodLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
// Handle transfers
|
||||
if (IsTransfer)
|
||||
{
|
||||
var toLabel = TransferToAccount?.DisplayLabel ?? "Unknown";
|
||||
return $"Transfer → {toLabel}";
|
||||
}
|
||||
|
||||
// If card was used, show just the card (since account is implied)
|
||||
if (Card != null)
|
||||
return $"{Card.Issuer} {Card.Last4}";
|
||||
if (Account != null)
|
||||
return $"{Account.Institution} {Account.Last4}";
|
||||
if (!string.IsNullOrEmpty(Last4))
|
||||
return $"···· {Last4}";
|
||||
return "Unknown";
|
||||
return Card.DisplayLabel;
|
||||
|
||||
// Direct account transaction (no card)
|
||||
return Account?.DisplayLabel ?? $"···· {Last4}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<th>Memo</th>
|
||||
<th style="width: 110px;" class="text-end">Amount</th>
|
||||
<th style="width: 160px;">Category</th>
|
||||
<th style="width: 110px;">Card</th>
|
||||
<th style="width: 140px;">Payment/Account</th>
|
||||
<th style="width: 120px;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -164,7 +164,9 @@
|
||||
@t.Category
|
||||
}
|
||||
</td>
|
||||
<td>@t.CardLabel</td>
|
||||
<td class="small">
|
||||
@t.CardLabel
|
||||
</td>
|
||||
<td>
|
||||
<a asp-page="/EditTransaction" asp-route-id="@t.Id" class="btn btn-sm btn-outline-primary" title="Edit">
|
||||
Edit
|
||||
|
||||
Reference in New Issue
Block a user