using ROLAC.API.Entities.Base;
namespace ROLAC.API.Entities;

/// <summary>
/// A disbursement check issued to a single payee, bundling one or more approved
/// expenses (its <see cref="Lines"/>). The payee name/address are snapshotted at
/// issue time so the printed check is reproducible even if member data later changes.
/// </summary>
public class Check : SoftDeleteEntity, IAuditable
{
    public int      Id          { get; set; }
    public string   CheckNumber { get; set; } = null!;
    public DateOnly CheckDate   { get; set; }
    public decimal  Amount      { get; set; }            // sum of line amounts

    public string   PayeeType   { get; set; } = "Vendor"; // Vendor | Member
    public int?     MemberId    { get; set; }            // set when PayeeType == Member
    public string   PayeeName   { get; set; } = null!;    // snapshot
    public string?  PayeeAddress { get; set; }           // snapshot
    public string?  PayeeCity   { get; set; }
    public string?  PayeeState  { get; set; }
    public string?  PayeeZip    { get; set; }

    public string   Status      { get; set; } = "Issued"; // Issued | Voided
    public string?  Memo        { get; set; }

    public string   IssuedBy    { get; set; } = null!;
    public DateTimeOffset IssuedAt { get; set; }

    public string?  VoidReason  { get; set; }
    public DateTimeOffset? VoidedAt { get; set; }
    public string?  VoidedBy    { get; set; }

    // Receipt e-signature: payee signs in-app on hand-off. "Signed" is derived as
    // ReceiptSignedAt != null.
    public string?  ReceiptSignatureBlobPath { get; set; }
    public string?  ReceiptSignedName        { get; set; }
    public DateTimeOffset? ReceiptSignedAt    { get; set; }
    public string?  ReceiptCapturedBy        { get; set; }

    public Member?           Member { get; set; }
    public ICollection<CheckLine> Lines { get; set; } = [];
}
