using ERPCore.Domain.Enums;

namespace ERPCore.Domain.Entities;

/// <summary>
/// Payroll run (FR-HR-PAY-05/06) — the transactional document. Numbered via
/// <see cref="NumberSequence"/> (docType "PAY"). Model: docs/12-BACKEND-HRM.md Part C.6.
/// </summary>
public class PayrollRun
{
    public int PayrollRunId { get; set; }
    public string DocNo { get; set; } = string.Empty;
    public int PeriodYear { get; set; }
    public int PeriodMonth { get; set; }
    /// <summary>Null = company-wide run.</summary>
    public int? BranchId { get; set; }
    public Branch? Branch { get; set; }
    public PayrollRunStatus Status { get; set; } = PayrollRunStatus.Draft;

    public int GeneratedBy { get; set; }
    public DateTime GeneratedAt { get; set; }
    public int? ApprovedBy { get; set; }
    public DateTime? ApprovedAt { get; set; }
    public int? LockedBy { get; set; }
    public DateTime? LockedAt { get; set; }
    public int? UnlockedBy { get; set; }
    public DateTime? UnlockedAt { get; set; }
    public string? UnlockReason { get; set; }

    public uint RowVersion { get; set; }

    public List<PayrollLine> Lines { get; set; } = new();
}
