using Books.Api.Domain.Invoices;
using EventFlow.Aggregates;

namespace Books.Api.Domain.Invoices.Events;

/// <summary>
/// Raised when a payment is received for an invoice.
/// Creates ledger entries:
/// - Debit: Bank account
/// - Credit: Customer sub-ledger account (1900-XXXX)
/// </summary>
public class InvoicePaymentReceivedEvent(
    decimal amount,
    string? bankTransactionId,
    string? ledgerTransactionId,
    string? paymentReference,
    DateOnly paymentDate,
    string recordedBy,
    decimal newAmountPaid,
    decimal newAmountRemaining,
    InvoiceStatus newStatus) : AggregateEvent<InvoiceAggregate, InvoiceId>
{
    public decimal Amount { get; } = amount;
    public string? BankTransactionId { get; } = bankTransactionId;
    public string? LedgerTransactionId { get; } = ledgerTransactionId;
    public string? PaymentReference { get; } = paymentReference;
    public DateOnly PaymentDate { get; } = paymentDate;
    public string RecordedBy { get; } = recordedBy;
    public decimal NewAmountPaid { get; } = newAmountPaid;
    public decimal NewAmountRemaining { get; } = newAmountRemaining;
    public InvoiceStatus NewStatus { get; } = newStatus;
}
