package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


	
import com.jasamedika.medifirst2000.util.JsonUtil;
import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.SimulasiPendapatanService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.SimulasiPendapatan;
import com.jasamedika.medifirst2000.vo.SimulasiPendapatanVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.SimulasiPendapatanDao;

/**
 * Implement class for SimulasiPendapatanService
 * 
 * @author Generator
 * @param <T>
 */
@Service("simulasiPendapatanService")
public class SimulasiPendapatanServiceImpl extends BaseVoServiceImpl implements SimulasiPendapatanService 
{	
	@Autowired
	private BaseConverterImpl<SimulasiPendapatanVO,SimulasiPendapatan>simulasiPendapatanConverter;
	
	@Autowired
	private SimulasiPendapatanDao simulasiPendapatanDao;	
	
	@Override
	public Map<String, Object> saveSimulasiPendapatan(SimulasiPendapatanVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		SimulasiPendapatan model = new SimulasiPendapatan();
		model = simulasiPendapatanConverter.transferVOToModel(vo,model);
		

		SimulasiPendapatan resultDomain = simulasiPendapatanDao.save(model);
		if (CommonUtil.isNotNullOrEmpty(resultDomain)) {
			result.put("noRec", resultDomain.getNoRec());
		}

		return result;
	}

	@Override
	public Map<String, Object> findByTahun(Integer tahun) {
		 Map<String, Object> result = new HashMap<String, Object>();
		 try {
			result.put("items", simulasiPendapatanDao.findByTahun(tahun));
		} catch (IllegalArgumentException  e) {
			e.printStackTrace();
		}
		return result;
	}
}