using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore; namespace Distribution.Models { public class Expense : Template { /// Leaf category (Title). Parent is the user-facing Category group. public Guid FK_CategoryId { get; set; } [ForeignKey("FK_CategoryId")] public ExpenseCategory? Category { get; set; } /// Branch the expense is attributed to. Null = company-wide. public Guid? FK_WarehouseId { get; set; } [ForeignKey("FK_WarehouseId")] public Warehouse? Warehouse { get; set; } [Precision(18, 2)] public decimal Amount { get; set; } public DateTime BillDate { get; set; } public DateTime? DueDate { get; set; } /// First day of the month the expense covers (YYYY-MM-01). public DateTime? PeriodCovered { get; set; } public Guid? FK_VendorId { get; set; } [ForeignKey("FK_VendorId")] public ExpenseVendor? Vendor { get; set; } public string? Payee { get; set; } public string? BillRef { get; set; } public string? Description { get; set; } public ExpenseStatus Status { get; set; } = ExpenseStatus.Draft; /// Payment settlement — null until Status transitions to Paid. public PaymentMethod? Method { get; set; } public Guid? FK_BankAccountId { get; set; } [ForeignKey("FK_BankAccountId")] public BankAccount? BankAccount { get; set; } public Guid? FK_ChequePageId { get; set; } [ForeignKey("FK_ChequePageId")] public ChequePage? ChequePage { get; set; } public DateTime? PaidAt { get; set; } public Guid RecordedByUserId { get; set; } public Guid? PostedByUserId { get; set; } public DateTime? PostedAt { get; set; } public Guid? PaidByUserId { get; set; } public Guid? VoidedByUserId { get; set; } public DateTime? VoidedAt { get; set; } public string? VoidReason { get; set; } /// Null for manually-entered expenses; set when generated by run-due. public Guid? FK_RecurringTemplateId { get; set; } [ForeignKey("FK_RecurringTemplateId")] public RecurringExpenseTemplate? RecurringTemplate { get; set; } public ICollection Attachments { get; set; } = []; } }