package com.mvrent.carrental.repository;

import com.mvrent.carrental.model.DriverDocument;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.LocalDate;
import java.util.List;

public interface DriverDocumentRepository extends JpaRepository<DriverDocument, Long> {

    @Query("""
            SELECT d FROM DriverDocument d
            WHERE d.expiryDate IS NOT NULL AND d.expiryDate <= :cutoff
            ORDER BY d.expiryDate ASC
            """)
    List<DriverDocument> findExpiringOrExpired(@Param("cutoff") LocalDate cutoff);
}
