namespace ERPCore.Domain.Entities;

/// <summary>
/// A customer payment made against a Posted sales invoice's balance (installments
/// allowed — see SalesInvoicePaymentService.PayAsync). Posts its own real GL journal
/// entry (Debit the selected bank-or-cash account / Credit Accounts Receivable) before
/// being recorded here — the mirror image of <see cref="GrnPayment"/>.
/// </summary>
public class SalesInvoicePayment
{
    public int SalesInvoicePaymentId { get; set; }

    public int SalesInvoiceId { get; set; }
    public SalesInvoice? SalesInvoice { 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 received into.</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; }
}
