package br.gov.sigefp.treasury.repository;

import br.gov.sigefp.treasury.domain.PaymentOrder;
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 PaymentOrderRepository extends JpaRepository<PaymentOrder, UUID> {

    List<PaymentOrder> findByPaymentBatchId(UUID paymentBatchId);

    List<PaymentOrder> findByStatus(String status);

    @Query("SELECT po FROM PaymentOrder po WHERE po.paymentBatch.id = :batchId AND po.status = :status")
    List<PaymentOrder> findByPaymentBatchIdAndStatus(@Param("batchId") UUID batchId, @Param("status") String status);

    @Query("SELECT po FROM PaymentOrder po WHERE po.payrollRunId = :payrollRunId")
    List<PaymentOrder> findByPayrollRunId(@Param("payrollRunId") UUID payrollRunId);
}
