package com.jasamedika.medifirst2000.dao;

import java.util.List;
import java.util.Map;

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.PenawaranHargaSupplier;

@Repository("PenawaranHargaSupplierDao")
public interface PenawaranHargaSupplierDao extends PagingAndSortingRepository<PenawaranHargaSupplier, String>{
	
	@Query(" select new Map ( "+
	" penawaranHargaSupplier.noRec as noRecPenawaranHargaSupplier, "+
	" kartuPengendaliDetail.noRec as noRecKartuPengendaliDetail,"+
	" supplier.id as supplierId,"+
	" supplier.namaRekanan as namaSupplier,"+
	" penawaranHargaSupplier.hargaSatuanTerkecil as hargaSatuanTerkecil,"+
	" penawaranHargaSupplier.spesifikasi as spesifikasi,"+
	" penawaranHargaSupplier.namaDagang as namaDagang,"+
	" penawaranHargaSupplier.tipeObat as tipeObat,"+
	" penawaranHargaSupplier.kemasan as kemasan,"+
	" penawaranHargaSupplier.isiKemasan as isiKemasan,"+
	" penawaranHargaSupplier.hargaSatuanTerkecil as hargaSatuanTerkecil,"+
	" penawaranHarga.tanggal as tanggal )"+
	" from PenawaranHargaSupplier penawaranHargaSupplier "+
	" left join penawaranHargaSupplier.kartuPengendaliDetail kartuPengendaliDetail "+
	" left join penawaranHargaSupplier.penawaranHarga penawaranHarga "+
	" left join penawaranHarga.supplier supplier "+
	" where kartuPengendaliDetail.noRec=:noRec order by penawaranHargaSupplier.hargaSatuanTerkecil asc ")
	List<Map<String,Object>> findByKartuPengendaliDetail(@Param("noRec") String noRec);
}
