package com.jasamedika.medifirst2000.entities;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

import static javax.persistence.FetchType.LAZY;
import static javax.persistence.GenerationType.SEQUENCE;

@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "DetailJenisProduk_M")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class DetailJenisProduk extends BaseMaster {

	public DetailJenisProduk(String detailJenisProduk, String kdDetailJenisProduk, Integer id) {
		super();
		this.id = id;
		this.detailJenisProduk = detailJenisProduk;
		this.kdDetailJenisProduk = kdDetailJenisProduk;
	}

	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "public.detailjenisproduk_m_id_seq")
	@SequenceGenerator(name = "public.detailjenisproduk_m_id_seq", sequenceName = "public.detailjenisproduk_m_id_seq", allocationSize = 1)
	@Column(name = "id")
	protected Integer id;

	@NotNull(message = "Detail Jenis Produk tidak boleh kosong")
	@Column(name = "DetailJenisProduk", nullable = false, length = 50)
	@Caption(value = "Detail Jenis Produk")
	private String detailJenisProduk;

	@Column(name = "isRegistrasiAset")
	@Caption(value = "Is Registrasi Aset")
	private Byte isRegistrasiAset;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectAccountFk")
	@Caption(value = "Object Account")
	private ChartOfAccount account;

	@Column(name = "ObjectAccountFk", insertable = false, updatable = false)
	private Integer accountId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectDepartemenFk")
	@NotNull(message = "Kd Departemen tidak boleh kosong")
	@Caption(value = "Object Departemen")
	private Departemen departemen;

	@Column(name = "ObjectDepartemenFk", insertable = false, updatable = false)
	private Integer departemenId;

	@NotNull(message = "Kd Detail Jenis Produk tidak boleh kosong")
	@Column(name = "KdDetailJenisProduk", nullable = false, length = 4)
	@Caption(value = "Kode Detail Jenis Produk")
	private String kdDetailJenisProduk;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "ObjectJenisProdukFk")
	@NotNull(message = "Kd Jenis Produk tidak boleh kosong")

	@Caption(value = "Object Jenis Produk")
	private JenisProduk jenisProduk;

	@Column(name = "ObjectJenisProdukFk", insertable = false, updatable = false, nullable = false)
	private Integer jenisProdukId;

	@NotNull(message = "Persen Harga Cito tidak boleh kosong")
	@Column(name = "PersenHargaCito", nullable = false)
	@Caption(value = "Persen Harga Cito")
	private Double persenHargaCito;

	@NotNull(message = "QDetail Jenis Produk tidak boleh kosong")
	@Column(name = "QDetailJenisProduk", nullable = false)
	@Caption(value = "QDetail Jenis Produk")
	private short qDetailJenisProduk;

}