using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace MoneyMap.Models; public class Transfer { [Key] public long Id { get; set; } [Required] public DateTime Date { get; set; } [Required] [Column(TypeName = "decimal(18,2)")] public decimal Amount { get; set; } // Always positive [MaxLength(500)] public string Description { get; set; } = string.Empty; public string Notes { get; set; } = string.Empty; // Source account (where money comes from) - nullable for "Unknown" [ForeignKey(nameof(SourceAccount))] public int? SourceAccountId { get; set; } public Account? SourceAccount { get; set; } // Destination account (where money goes to) - nullable for "Unknown" [ForeignKey(nameof(DestinationAccount))] public int? DestinationAccountId { get; set; } public Account? DestinationAccount { get; set; } // Optional link to original transaction if imported from CSV [ForeignKey(nameof(OriginalTransaction))] public long? OriginalTransactionId { get; set; } public Transaction? OriginalTransaction { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; [NotMapped] public string SourceLabel => SourceAccount != null ? $"{SourceAccount.Institution} {SourceAccount.Last4}" : "Unknown"; [NotMapped] public string DestinationLabel => DestinationAccount != null ? $"{DestinationAccount.Institution} {DestinationAccount.Last4}" : "Unknown"; }