package de.assecutor.votianlt.repository;

import de.assecutor.votianlt.model.invoices.InvoiceNumberReservation;
import de.assecutor.votianlt.model.invoices.InvoiceNumberReservationStatus;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface InvoiceNumberReservationRepository extends MongoRepository<InvoiceNumberReservation, ObjectId> {

    Optional<InvoiceNumberReservation> findByUserIdAndNumber(ObjectId userId, String number);

    Optional<InvoiceNumberReservation> findByUserIdAndSequence(ObjectId userId, long sequence);

    List<InvoiceNumberReservation> findByUserIdOrderBySequenceAsc(ObjectId userId);

    List<InvoiceNumberReservation> findByUserIdAndStatusOrderBySequenceAsc(ObjectId userId,
            InvoiceNumberReservationStatus status);
}
