package br.gov.sigefp.treasury.repository;

import br.gov.sigefp.treasury.domain.PaymentBatch;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.UUID;

@Repository
public interface PaymentBatchRepository extends JpaRepository<PaymentBatch, UUID> {
    
    List<PaymentBatch> findByPeriodId(Long periodId);
    
    List<PaymentBatch> findByMinistryId(UUID ministryId);
    
    List<PaymentBatch> findByStatus(String status);
    
    @Query("SELECT pb FROM PaymentBatch pb WHERE pb.periodId = :periodId AND pb.ministryId = :ministryId")
    List<PaymentBatch> findByPeriodIdAndMinistryId(@Param("periodId") Long periodId, @Param("ministryId") UUID ministryId);
    
    @Query("SELECT pb FROM PaymentBatch pb WHERE pb.periodId = :periodId AND pb.status = :status")
    List<PaymentBatch> findByPeriodIdAndStatus(@Param("periodId") Long periodId, @Param("status") String status);
    
    @Query("SELECT pb FROM PaymentBatch pb WHERE pb.ministryId = :ministryId AND pb.status = :status")
    List<PaymentBatch> findByMinistryIdAndStatus(@Param("ministryId") UUID ministryId, @Param("status") String status);
}

