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.vo.JenisGajiVO;
import com.jasamedika.medifirst2000.vo.TahunUmrVO;
import com.jasamedika.medifirst2000.vo.NamaAsuransiVO;

	import com.jasamedika.medifirst2000.entities.JenisGaji;
import com.jasamedika.medifirst2000.entities.TahunUmr;
import com.jasamedika.medifirst2000.entities.NamaAsuransi;


import com.jasamedika.medifirst2000.exception.ServiceVOException;
import com.jasamedika.medifirst2000.service.PerhitunganPremiBPJSKetenagaKerjaanService;
import com.jasamedika.medifirst2000.util.CommonUtil;
import com.jasamedika.medifirst2000.entities.PerhitunganPremiBPJSKetenagaKerjaan;
import com.jasamedika.medifirst2000.vo.PerhitunganPremiBPJSKetenagaKerjaanVO;
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
import com.jasamedika.medifirst2000.dao.PerhitunganPremiBPJSKetenagaKerjaanDao;

/**
 * Implement class for PerhitunganPremiBPJSKetenagaKerjaanService
 * 
 * @author Generator
 * @param <T>
 */
@Service("perhitunganPremiBPJSKetenagaKerjaanService")
public class PerhitunganPremiBPJSKetenagaKerjaanServiceImpl extends BaseVoServiceImpl implements PerhitunganPremiBPJSKetenagaKerjaanService 
{	
	@Autowired
	private BaseConverterImpl<PerhitunganPremiBPJSKetenagaKerjaanVO,PerhitunganPremiBPJSKetenagaKerjaan>perhitunganPremiBPJSKetenagaKerjaanConverter;
	@Autowired
private BaseConverterImpl<JenisGajiVO,JenisGaji>jenisGajiConverter;

@Autowired
private BaseConverterImpl<TahunUmrVO,TahunUmr>tahunUmrConverter;

@Autowired
private BaseConverterImpl<NamaAsuransiVO,NamaAsuransi>namaAsuransiConverter;


	@Autowired
	private PerhitunganPremiBPJSKetenagaKerjaanDao perhitunganPremiBPJSKetenagaKerjaanDao;

	
	@Override
	public Map<String, Object> savePerhitunganPremiBPJSKetenagaKerjaan(PerhitunganPremiBPJSKetenagaKerjaanVO vo) {
		Map<String, Object> result = new HashMap<String, Object>();
		PerhitunganPremiBPJSKetenagaKerjaan model = new PerhitunganPremiBPJSKetenagaKerjaan();
		model = perhitunganPremiBPJSKetenagaKerjaanConverter.transferVOToModel(vo,model);
		
		if (CommonUtil.isNotNullOrEmpty(vo.getJenisGaji()))
		{
				model.setJenisGaji(jenisGajiConverter.transferVOToModel(vo.getJenisGaji(), new JenisGaji()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getTahunUMR()))
		{
				model.setTahunUMR(tahunUmrConverter.transferVOToModel(vo.getTahunUMR(), new TahunUmr()));
		}
		if (CommonUtil.isNotNullOrEmpty(vo.getNamaAsuransi()))
		{
				model.setNamaAsuransi(namaAsuransiConverter.transferVOToModel(vo.getNamaAsuransi(), new NamaAsuransi()));
		}

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

		return result;
	}
}