package common.repository;

import common.model.PdIncome;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface PdIncomeRepository extends JpaRepository<PdIncome, Long> {

	@Query(value = "select * from pd_income where contract_code = ? order by input_date desc ", nativeQuery = true)
	List<PdIncome> findByContractCode(String code);


	@Query(value = "select * from pd_income where settlement_date >= ?1 and settlement_date <= ?2", nativeQuery = true)
	List<PdIncome> findByDs(String startDate, String endDate);

	@Query(value = "select contract_code, sum(acceptance_amount) from pd_income where contract_code in ?1 group by contract_code", nativeQuery = true)
	List<Object[]> findGroupWithCode(List codes);
}
