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.GenerationType.SEQUENCE;

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

	public JenisProduk(String jenisProduk, String kdJenisProduk, Integer id) {
		super();
		this.jenisProduk = jenisProduk;
		this.kdJenisProduk = kdJenisProduk;
		this.id = id;
	}

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

	@NotNull(message = "Jenis Produk tidak boleh kosong")
	@Column(name = "JenisProduk", nullable = false, length = 80)
	@Caption(value = "Jenis Produk")
	private String jenisProduk;

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

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

	@ManyToOne
	@JoinColumn(name = "ObjectDepartemenFk")
	@NotNull(message = "Object Departemen Harus Diisi")
	@Caption(value = "Object Departemen")
	private Departemen departemen;

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

	@NotNull(message = "Kd Jenis Produk tidak boleh kosong")
	@Column(name = "KdJenisProduk", nullable = false, length = 2)
	@Caption(value = "Kode Jenis Produk")
	private String kdJenisProduk;

	@ManyToOne
	@JoinColumn(name = "ObjectJenisProdukHeadFk")
	@Caption(value = "Object Jenis Produk Head")
	private JenisProduk jenisProdukHead;

	@Column(name = "ObjectJenisProdukHeadFk", insertable = false, updatable = false)
	private Integer jenisProdukHeadId;

	@ManyToOne
	@JoinColumn(name = "ObjectKelompokProdukFk")
	@NotNull(message = "Object Kelompok Produk Harus Diisi")
	@Caption(value = "Object Kelompok Produk")
	private KelompokProduk kelompokProduk;

	@Column(name = "ObjectKelompokProdukFk", insertable = false, updatable = false)
	private Integer kelompokProdukId;

	@NotNull(message = "QJenis Produk tidak boleh kosong")
	@Column(name = "QJenisProduk", nullable = false)
	@Caption(value = "QJenis Produk")
	private short qJenisProduk;

}