package br.gov.sigefp.treasury.repository;

import br.gov.sigefp.treasury.domain.CashAccount;
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.Optional;
import java.util.UUID;

@Repository
public interface CashAccountRepository extends JpaRepository<CashAccount, UUID> {
    
    Optional<CashAccount> findByCode(String code);
    
    List<CashAccount> findByType(String type);
    
    List<CashAccount> findByIsActiveTrue();
    
    List<CashAccount> findByBankId(UUID bankId);
    
    @Query("SELECT ca FROM CashAccount ca WHERE ca.type = 'BANK_ACCOUNT' AND ca.isActive = true")
    List<CashAccount> findActiveBankAccounts();
    
    @Query("SELECT ca FROM CashAccount ca WHERE ca.type = 'CASH' AND ca.isActive = true")
    List<CashAccount> findActiveCashAccounts();
}
