using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

/// <summary>
/// Loan/Advance (FR-HR-PAY-03) — <see cref="LoanKind"/> discriminates, structurally
/// identical otherwise. <see cref="OutstandingBalance"/> is denormalized (parallel to
/// <c>StockLayer.QtyRemaining</c>). Numbered via <see cref="NumberSequence"/> (docType "LOAN").
/// Model: docs/12-BACKEND-HRM.md Part C.6.
/// </summary>
public class EmployeeLoan
{
    public int EmployeeLoanId { get; set; }
    public string DocNo { get; set; } = string.Empty;
    public int EmployeeId { get; set; }
    public Employee? Employee { get; set; }
    public LoanKind LoanKind { get; set; }

    public decimal PrincipalAmount { get; set; }
    public decimal InterestRate { get; set; }
    public decimal InstallmentAmount { get; set; }
    public int NumberOfInstallments { get; set; }
    public int StartYear { get; set; }
    public int StartMonth { get; set; }
    public decimal OutstandingBalance { get; set; }
    public LoanStatus Status { get; set; } = LoanStatus.Active;

    public int ApprovedBy { get; set; }
    public DateTime ApprovedAt { get; set; }
    public int CreatedBy { get; set; }
    public DateTime CreatedAt { get; set; }
    public uint RowVersion { get; set; }

    public List<LoanInstallment> Installments { get; set; } = new();
}
