package sikd.sikd5.sikd5ejb.mapper.transaksi;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import sikd.sikd5.sikd5bean.ws.transaksi.Dthbelanja_WS;
import sikd.sikd5.sikd5bean.ws.transaksi.Dthpotongan_WS;

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

	@Delete({
			"delete from transaksi.dthbelanja",
			"where dthbelanjaid = #{dthbelanjaid,jdbcType=BIGINT}"
	})
	int deleteDthBelanjaByPrimaryKey(Long dthbelanjaid);
        
	@Delete({
			"delete from transaksi.dthpotongan",
			"where dthpotonganid = #{dthpotonganid,jdbcType=BIGINT}"
	})
	int deleteDthPotonganByPrimaryKey(Long dthbelanjaid);

	@Select({
			"insert into transaksi.dthpotongan (headerdthid, ",
            "nomorsp2d, nomorspm, kodeakunpotongan, namaakunpotongan, ",
            "kodejenispotongan, namajenispotongan, kodebiling, ntpn, nilaipotongan, keteranganpotongan )",
			"values (#{headerdthid,jdbcType=BIGINT}, ",
			"#{record.nomorsp2d,jdbcType=VARCHAR}, #{record.nomorspm,jdbcType=VARCHAR}, ",
			"#{record.kodeakunpotongan,jdbcType=VARCHAR}, #{record.namaakunpotongan,jdbcType=VARCHAR}, ",
			"#{record.kodejenispotongan,jdbcType=VARCHAR}, #{record.namajenispotongan,jdbcType=VARCHAR}, ",
			"#{record.kodebiling,jdbcType=VARCHAR}, #{record.ntpn,jdbcType=VARCHAR}, ",
			"#{record.nilaipotongan,jdbcType=DOUBLE}, #{record.keteranganpotongan,jdbcType=VARCHAR} ",
			")",
			"returning dthpotonganid"
	})
	long insertDthPotongan(@Param("record") Dthpotongan_WS record, @Param("headerdthid") long headerdthid);

	@Select({
            "insert into transaksi.dthbelanja (headerdthid, ",
        "nomorsp2d, tanggalsp2d, nomorspm, tanggalspm, jenissp2d, ",
        "nilaisp2d, nilaitotalpajak, nilaitotalpotongan, ",
        "npwpbud, npwpskpd, npwppenerima, namapenerima, kodesumberdana, namasumberdana, ",
        "tahapsalurdana, keteranganbelanja, kodefungsi, namafungsi, ",
        "kodeurusanprogram, namaurusanprogram, kodeurusanpelaksana, namaurusanpelaksana, ",
        "kodeskpd, namaskpd, kodeunitskpd, namaunitskpd, kodeprogram, namaprogram, kodekegiatan, namakegiatan, ",
        "kodeakunutama, namaakunutama, kodeakunkelompok, namaakunkelompok, kodeakunjenis, namaakunjenis, ",
        "kodeakunobjek, namaakunobjek, kodeakunrinci, namaakunrinci, kodeakunsubrinci, namaakunsubrinci, ",
        "kodeakunsubsubrinci, namaakunsubsubrinci, nilaibelanja, catatan )",
        "values (#{headerdthid,jdbcType=BIGINT}, ",
        "#{record.nomorsp2d,jdbcType=VARCHAR}, #{record.tanggalsp2d,jdbcType=TIMESTAMP}, ",
        "#{record.nomorspm,jdbcType=VARCHAR}, #{record.tanggalspm,jdbcType=TIMESTAMP}, ",
        "#{record.jenissp2d,jdbcType=INTEGER}, #{record.nilaisp2d,jdbcType=DOUBLE}, ",
        "#{record.nilaitotalpajak,jdbcType=DOUBLE}, #{record.nilaitotalpotongan,jdbcType=DOUBLE}, ",
        "#{record.npwpbud,jdbcType=VARCHAR}, #{record.npwpskpd,jdbcType=VARCHAR}, ",
        "#{record.npwppenerima,jdbcType=VARCHAR}, #{record.namapenerima,jdbcType=VARCHAR}, ",
        "#{record.kodesumberdana,jdbcType=VARCHAR}, #{record.namasumberdana,jdbcType=VARCHAR}, ",
        "#{record.tahapsalurdana,jdbcType=INTEGER}, #{record.keteranganbelanja,jdbcType=VARCHAR}, ",
        "#{record.kodefungsi,jdbcType=VARCHAR}, #{record.namafungsi,jdbcType=VARCHAR}, ",
        "#{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.kodeunitskpd,jdbcType=VARCHAR}, #{record.namaunitskpd,jdbcType=VARCHAR}, ",
        "#{record.kodeprogram,jdbcType=VARCHAR}, #{record.namaprogram,jdbcType=VARCHAR}, ",
        "#{record.kodekegiatan,jdbcType=VARCHAR}, #{record.namakegiatan,jdbcType=VARCHAR}, ",
        "#{record.kodeakunutama,jdbcType=CHAR}, #{record.namaakunutama,jdbcType=VARCHAR}, ",
        "#{record.kodeakunkelompok,jdbcType=CHAR}, #{record.namaakunkelompok,jdbcType=VARCHAR}, ",
        "#{record.kodeakunjenis,jdbcType=CHAR}, #{record.namaakunjenis,jdbcType=VARCHAR}, ",
        "#{record.kodeakunobjek,jdbcType=CHAR}, #{record.namaakunobjek,jdbcType=VARCHAR}, ",
        "#{record.kodeakunrinci,jdbcType=CHAR}, #{record.namaakunrinci,jdbcType=VARCHAR}, ",
        "#{record.kodeakunsubrinci,jdbcType=CHAR}, #{record.namaakunsubrinci,jdbcType=VARCHAR}, ",
        "#{record.kodeakunsubsubrinci,jdbcType=CHAR}, #{record.namaakunsubsubrinci,jdbcType=VARCHAR}, ",
        "#{record.nilaibelanja,jdbcType=DOUBLE}, #{record.catatan,jdbcType=VARCHAR} ",
			")",
			"returning dthbelanjaid"
	})
	long insertDthBelanja(@Param("record") Dthbelanja_WS record, @Param("headerdthid") long headerdthid);

	@Delete({
			"delete from transaksi.dthpotongan",
			"where headerdthid = #{headerdthid,jdbcType=BIGINT}"
	})
	int deleteDthPotonganByHeaderdthid(Long headerdthid);

	@Delete({
			"delete from transaksi.dthbelanja",
			"where headerdthid = #{headerdthid,jdbcType=BIGINT}"
	})
	int deleteDthBelanjaByHeaderdthid(Long headerdthid);
}
