package sikd.sikd5.sikd5ejb.mapper.transaksi;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import sikd.sikd5.sikd5bean.ws.transaksi.Headerjurnal_WS;
import sikd.sikd5.sikd5bean.ws.transaksi.Jurnal_WS;

/**
 * @oleh : agus
 * @tanggal : May 16, 2019
 */
@SuppressWarnings("el-syntax")
public interface JurnalMapper {

	@Delete({
			"delete from transaksi.jurnal",
			"where jurnalid = #{jurnalid,jdbcType=BIGINT}"
	})
	int deleteJurnalByPrimaryKey(Long jurnalid);

	@Select({
			"insert into transaksi.jurnal (headerjurnalid, ",
			"nomorbukti, tanggalbukti, ",
			"kodeurusanprogram, namaurusanprogram, ",
			"kodeurusanpelaksana, namaurusanpelaksana, ",
			"kodeskpd, namaskpd, ",
			"kodeprogram, namaprogram, ",
			"kodekegiatan, namakegiatan, ",
			"kodefungsi, namafungsi, ",
			"kodeakunutama, namaakunutama, ",
			"kodeakunkelompok, namaakunkelompok, ",
			"kodeakunjenis, namaakunjenis, ",
			"kodeakunobjek, namaakunobjek, ",
			"kodeakunrincian, namaakunrincian, ",
			"nilaidebet, nilaikredit, ",
			"kodeposting,saldonormal, ",
			"catatan,keterangan)",
			"values (#{headerjurnalid,jdbcType=BIGINT}, ",
			"#{record.nomorbukti,jdbcType=VARCHAR}, #{record.tanggalbukti,jdbcType=TIMESTAMP}, ",
			"#{record.kodeurusanprogram,jdbcType=VARCHAR}, #{record.namaurusanprogram,jdbcType=VARCHAR}, ",
			"#{record.kodeurusanpelaksana,jdbcType=VARCHAR}, #{record.namaurusanpelaksana,jdbcType=VARCHAR}, ",
			"#{record.kodeskpd,jdbcType=VARCHAR}, #{record.namaskpd,jdbcType=VARCHAR}, ",
			"#{record.kodeprogram,jdbcType=VARCHAR}, #{record.namaprogram,jdbcType=VARCHAR}, ",
			"#{record.kodekegiatan,jdbcType=VARCHAR}, #{record.namakegiatan,jdbcType=VARCHAR}, ",
			"#{record.kodefungsi,jdbcType=VARCHAR}, #{record.namafungsi,jdbcType=VARCHAR}, ",
			"#{record.kodeakunutama,jdbcType=VARCHAR}, #{record.namaakunutama,jdbcType=VARCHAR}, ",
			"#{record.kodeakunkelompok,jdbcType=VARCHAR}, #{record.namaakunkelompok,jdbcType=VARCHAR}, ",
			"#{record.kodeakunjenis,jdbcType=VARCHAR}, #{record.namaakunjenis,jdbcType=VARCHAR}, ",
			"#{record.kodeakunobjek,jdbcType=VARCHAR}, #{record.namaakunobjek,jdbcType=VARCHAR}, ",
			"#{record.kodeakunrincian,jdbcType=VARCHAR}, #{record.namaakunrincian,jdbcType=VARCHAR}, ",
			"#{record.nilaidebet,jdbcType=DOUBLE}, #{record.nilaikredit,jdbcType=DOUBLE}, ",
			"#{record.kodeposting,jdbcType=SMALLINT},#{record.saldonormal,jdbcType=VARCHAR},  ",
			"#{record.catatan,jdbcType=VARCHAR},#{record.keterangan,jdbcType=VARCHAR}",
			")",
			"returning jurnalid"
	})
	long insertJurnal(@Param("record") Jurnal_WS record, @Param("headerjurnalid") long headerjurnalid);

	@Delete({
			"delete from transaksi.jurnal",
			"where headerjurnalid = #{headerjurnalid,jdbcType=BIGINT}"
	})
	int deleteJurnalByHeaderjurnalid(Long headerjurnalid);
}
