namespace ERPCore.Domain.Entities;

/// <summary>
/// A vendor payment made against a confirmed GRN's balance (installments allowed —
/// see GrnPaymentService.PayAsync). Posts its own real GL journal entry (Debit GRN
/// Clearing / Credit the selected bank-or-cash account) before being recorded here.
/// </summary>
public class GrnPayment
{
    public int GrnPaymentId { get; set; }

    public int GrnId { get; set; }
    public Grn? Grn { get; set; }

    public decimal Amount { get; set; }
    public DateTime PaymentDate { get; set; }

    /// <summary>GL's numeric id for the bank/cash account the payment was made from.</summary>
    public long GlBankAccountId { get; set; }
    /// <summary>Snapshot of the account's display name at payment time (GL account lists have no local FK).</summary>
    public string BankAccountName { get; set; } = string.Empty;

    public string? Reference { get; set; }

    /// <summary>Journal number of the real GL journal entry this payment posted.</summary>
    public string? GlJournalNo { get; set; }

    public int CreatedBy { get; set; }
    public User? Creator { get; set; }
    public DateTime CreatedAt { get; set; }
}
