package de.assecutor.votianlt.model.invoices;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDateTime;

/**
 * Records that a system invoice has been sent to a customer by email. Used to
 * filter the monthly invoice list into open and already sent invoices.
 */
@Data
@NoArgsConstructor
@Document(collection = "system_invoice_dispatch")
public class SystemInvoiceDispatch {

    @Id
    private ObjectId id;

    /** Invoice number, e.g. SYS-202607-42; one dispatch record per invoice. */
    @Indexed(unique = true)
    @Field("invoice_number")
    private String invoiceNumber;

    @Field("user_id")
    private ObjectId userId;

    /** Billing month in ISO format, e.g. 2026-07. */
    @Field("billing_month")
    private String billingMonth;

    @Field("sent_at")
    private LocalDateTime sentAt;

    @Field("sent_to")
    private String sentTo;
}
