package com.jasamedika.medifirst2000.dao;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.jasamedika.medifirst2000.entities.DetailPengadaan;
import com.jasamedika.medifirst2000.entities.Pengadaan;

@Repository("DetailPengadaanDao")
public interface DetailPengadaanDao extends PagingAndSortingRepository<DetailPengadaan, String> {

	@Query("Select detailPengadaan From KartuPengendaliDetail kartuPengendaliDetail "
			+ "join kartuPengendaliDetail.detailRup rup,DetailPengadaan detailPengadaan "
			+ "where detailPengadaan.detailRupId=rup.noRec and kartuPengendaliDetail.noRec=:noRec "
			+ "group by detailPengadaan.noRec")
	DetailPengadaan findByParent(@Param("noRec") String noRec);
	
	@Query("Select pengadaan from KartuPengendaliDetail kartuPengendaliDetail "
			+ "join kartuPengendaliDetail.detailRup rup,DetailPengadaan detailPengadaan  "
			+ "left join detailPengadaan.pengadaan pengadaan "
			+ "where detailPengadaan.detailRupId=rup.noRec  "
			+ "and kartuPengendaliDetail.kartuPengendali.noRec=:noRec  "
			+ "group by pengadaan")
	Pengadaan findByKartuPengendaliHeader(@Param("noRec") String noRec);


}
