using EventFlow.Aggregates;

namespace Books.Api.Domain.Orders.Events;

/// <summary>
/// Raised when order lines are converted to an invoice.
/// Supports partial invoicing - may only include some lines from the order.
/// </summary>
public class OrderLinesInvoicedEvent(
    string invoiceId,
    string invoiceNumber,
    IReadOnlyList<int> lineNumbers,
    DateTimeOffset invoicedAt,
    string invoicedBy,
    OrderStatus newStatus) : AggregateEvent<OrderAggregate, OrderId>
{
    public string InvoiceId { get; } = invoiceId;
    public string InvoiceNumber { get; } = invoiceNumber;

    /// <summary>
    /// The line numbers that were included in this invoice.
    /// </summary>
    public IReadOnlyList<int> LineNumbers { get; } = lineNumbers;

    /// <summary>
    /// When the lines were invoiced.
    /// </summary>
    public DateTimeOffset InvoicedAt { get; } = invoicedAt;

    /// <summary>
    /// User who performed the invoicing.
    /// </summary>
    public string InvoicedBy { get; } = invoicedBy;

    /// <summary>
    /// The new order status after invoicing (PartiallyInvoiced or FullyInvoiced).
    /// </summary>
    public OrderStatus NewStatus { get; } = newStatus;
}
