package com.jasamedika.medifirst2000.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.jasamedika.medifirst2000.base.BaseMaster;
import com.jasamedika.medifirst2000.helper.Caption;


@Entity
@Table(name = "Rekanan_M")
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class Rekanan extends BaseMaster {

	public Rekanan(Integer id, String namaRekanan) {
		super();
		this.id = id;
		this.namaRekanan = namaRekanan;
	}

	public Rekanan() {
	}

	@Column(name = "AlamatLengkap", nullable = true, length = 200)
	@Caption(value = "Alamat Lengkap")
	private String alamatLengkap;

	@Column(name = "BankRekeningAtasNama", nullable = true, length = 75)
	@Caption(value = "Bank Rekening Atas Nama")
	private String bankRekeningAtasNama;

	@Column(name = "BankRekeningNama", nullable = true, length = 50)
	@Caption(value = "Bank Rekening Nama")
	private String bankRekeningNama;

	@Column(name = "BankRekeningNomor", nullable = true, length = 30)
	@Caption(value = "Bank Rekening Nomor")
	private String bankRekeningNomor;

	@Column(name = "ContactPerson", nullable = true, length = 50)
	@Caption(value = "Contact Person")
	private String contactPerson;

	@Column(name = "DesaKelurahan", nullable = true, length = 50)
	@Caption(value = "Desa Kelurahan")
	private String namaDesaKelurahan;

	@Column(name = "Email", nullable = true, length = 50)
	@Caption(value = "Email")
	private String email;

	@Column(name = "Faksimile", nullable = true, length = 30)
	@Caption(value = "Faksimile")
	private String faksimile;

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

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

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectDesaKelurahanFk")
	@Caption(value = "Object Desa Kelurahan")
	private DesaKelurahan desaKelurahan;

	@Column(name = "ObjectDesaKelurahanFk", insertable = false, updatable = false)
	private Integer desaKelurahanId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectJenisRekananFk")
	@NotNull(message = "Kd Jenis Rekanan tidak boleh kosong")
	@Caption(value = "Object Jenis Rekanan")
	private JenisRekanan jenisRekanan;

	@Column(name = "ObjectJenisRekananFk", insertable = false, updatable = false)
	private Integer jenisRekananId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectKecamatanFk")
	@Caption(value = "Object Kecamatan")
	private Kecamatan kecamatan;

	@Column(name = "ObjectKecamatanFk", insertable = false, updatable = false, nullable = false)
	private Integer kecamatanId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectKotaKabupatenFk")
	@Caption(value = "Object Kota Kabupaten")
	private KotaKabupaten kotaKabupaten;

	@Column(name = "ObjectKotaKabupatenFk", insertable = false, updatable = false)
	private Integer kotaKabupatenId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectPegawaiFk")
	@Caption(value = "Object Pegawai")
	private Pegawai pegawai;

	@Column(name = "ObjectPegawaiFk", insertable = false, updatable = false)
	private Integer pegawaiId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectPropinsiFk")
	@Caption(value = "Object Propinsi")
	private Propinsi propinsi;

	@Column(name = "ObjectPropinsiFk", insertable = false, updatable = false)
	private Integer propinsiId;

	@NotNull(message = "Kd Rekanan tidak boleh kosong")
	@Column(name = "KdRekanan", nullable = false)
	@Caption(value = "Kode Rekanan")
	private short kdRekanan;

	@JsonManagedReference
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "rekananHead")
	private Set<Rekanan> renanans = new HashSet<Rekanan>();

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ObjectRekananHeadFk")
	@Caption(value = "Object Rekanan Head")
	@JsonBackReference
	private Rekanan rekananHead;

	@Column(name = "ObjectRekananHeadFk", insertable = false, updatable = false)
	private Integer rekananHeadId;

	@Column(name = "Kecamatan", nullable = true, length = 50)
	@Caption(value = "Kecamatan")
	private String namaKecamatan;

	@Column(name = "KodePos", nullable = true, length = 10)
	@Caption(value = "Kode Pos")
	private String kodePos;

	@Column(name = "KotaKabupaten", nullable = true, length = 50)
	@Caption(value = "Kota Kabupaten")
	private String namaKotaKabupaten;

	@NotNull(message = "Nama Rekanan tidak boleh kosong")
	@Column(name = "NamaRekanan", nullable = false, length = 75)
	@Caption(value = "Nama Rekanan")
	private String namaRekanan;

	@Column(name = "NoPKP", nullable = true, length = 40)
	@Caption(value = "No P K P")
	private String noPKP;

	@Column(name = "NPWP", nullable = true, length = 30)
	@Caption(value = "NP W P")
	private String nPWP;

	@NotNull(message = "QRekanan tidak boleh kosong")
	@Column(name = "QRekanan", nullable = false)
	@Caption(value = "QRekanan")
	private short qRekanan;

	@Column(name = "RTRW", nullable = true, length = 7)
	@Caption(value = "RT R W")
	private String rTRW;

	@Column(name = "Telepon", nullable = true, length = 30)
	@Caption(value = "Telepon")
	private String telepon;

	@Column(name = "Website", nullable = true, length = 50)
	@Caption(value = "Website")
	private String website;

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

	public String getAlamatLengkap() {
		return alamatLengkap;
	}

	public void setAlamatLengkap(String alamatLengkap) {
		this.alamatLengkap = alamatLengkap;
	}

	public String getBankRekeningAtasNama() {
		return bankRekeningAtasNama;
	}

	public void setBankRekeningAtasNama(String bankRekeningAtasNama) {
		this.bankRekeningAtasNama = bankRekeningAtasNama;
	}

	public String getBankRekeningNama() {
		return bankRekeningNama;
	}

	public void setBankRekeningNama(String bankRekeningNama) {
		this.bankRekeningNama = bankRekeningNama;
	}

	public String getBankRekeningNomor() {
		return bankRekeningNomor;
	}

	public void setBankRekeningNomor(String bankRekeningNomor) {
		this.bankRekeningNomor = bankRekeningNomor;
	}

	public String getContactPerson() {
		return contactPerson;
	}

	public void setContactPerson(String contactPerson) {
		this.contactPerson = contactPerson;
	}

	public String getNamaDesaKelurahan() {
		return namaDesaKelurahan;
	}

	public void setNamaDesaKelurahan(String namaDesaKelurahan) {
		this.namaDesaKelurahan = namaDesaKelurahan;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getFaksimile() {
		return faksimile;
	}

	public void setFaksimile(String faksimile) {
		this.faksimile = faksimile;
	}

	public ChartOfAccount getAccount() {
		return account;
	}

	public void setAccount(ChartOfAccount account) {
		this.account = account;
	}

	public Integer getAccountId() {
		return accountId;
	}

	public void setAccountId(Integer accountId) {
		this.accountId = accountId;
	}

	public DesaKelurahan getDesaKelurahan() {
		return desaKelurahan;
	}

	public void setDesaKelurahan(DesaKelurahan desaKelurahan) {
		this.desaKelurahan = desaKelurahan;
	}

	public Integer getDesaKelurahanId() {
		return desaKelurahanId;
	}

	public void setDesaKelurahanId(Integer desaKelurahanId) {
		this.desaKelurahanId = desaKelurahanId;
	}

	public JenisRekanan getJenisRekanan() {
		return jenisRekanan;
	}

	public void setJenisRekanan(JenisRekanan jenisRekanan) {
		this.jenisRekanan = jenisRekanan;
	}

	public Integer getJenisRekananId() {
		return jenisRekananId;
	}

	public void setJenisRekananId(Integer jenisRekananId) {
		this.jenisRekananId = jenisRekananId;
	}

	public Kecamatan getKecamatan() {
		return kecamatan;
	}

	public void setKecamatan(Kecamatan kecamatan) {
		this.kecamatan = kecamatan;
	}

	public Integer getKecamatanId() {
		return kecamatanId;
	}

	public void setKecamatanId(Integer kecamatanId) {
		this.kecamatanId = kecamatanId;
	}

	public KotaKabupaten getKotaKabupaten() {
		return kotaKabupaten;
	}

	public void setKotaKabupaten(KotaKabupaten kotaKabupaten) {
		this.kotaKabupaten = kotaKabupaten;
	}

	public Integer getKotaKabupatenId() {
		return kotaKabupatenId;
	}

	public void setKotaKabupatenId(Integer kotaKabupatenId) {
		this.kotaKabupatenId = kotaKabupatenId;
	}

	public Pegawai getPegawai() {
		return pegawai;
	}

	public void setPegawai(Pegawai pegawai) {
		this.pegawai = pegawai;
	}

	public Integer getPegawaiId() {
		return pegawaiId;
	}

	public void setPegawaiId(Integer pegawaiId) {
		this.pegawaiId = pegawaiId;
	}

	public Propinsi getPropinsi() {
		return propinsi;
	}

	public void setPropinsi(Propinsi propinsi) {
		this.propinsi = propinsi;
	}

	public Integer getPropinsiId() {
		return propinsiId;
	}

	public void setPropinsiId(Integer propinsiId) {
		this.propinsiId = propinsiId;
	}

	public short getKdRekanan() {
		return kdRekanan;
	}

	public void setKdRekanan(short kdRekanan) {
		this.kdRekanan = kdRekanan;
	}

	public Set<Rekanan> getRenanans() {
		return renanans;
	}

	public void setRenanans(Set<Rekanan> renanans) {
		this.renanans = renanans;
	}

	public Rekanan getRekananHead() {
		return rekananHead;
	}

	public void setRekananHead(Rekanan rekananHead) {
		this.rekananHead = rekananHead;
	}

	public Integer getRekananHeadId() {
		return rekananHeadId;
	}

	public void setRekananHeadId(Integer rekananHeadId) {
		this.rekananHeadId = rekananHeadId;
	}

	public String getNamaKecamatan() {
		return namaKecamatan;
	}

	public void setNamaKecamatan(String namaKecamatan) {
		this.namaKecamatan = namaKecamatan;
	}

	public String getKodePos() {
		return kodePos;
	}

	public void setKodePos(String kodePos) {
		this.kodePos = kodePos;
	}

	public String getNamaKotaKabupaten() {
		return namaKotaKabupaten;
	}

	public void setNamaKotaKabupaten(String namaKotaKabupaten) {
		this.namaKotaKabupaten = namaKotaKabupaten;
	}

	public String getNamaRekanan() {
		return namaRekanan;
	}

	public void setNamaRekanan(String namaRekanan) {
		this.namaRekanan = namaRekanan;
	}

	public String getNoPKP() {
		return noPKP;
	}

	public void setNoPKP(String noPKP) {
		this.noPKP = noPKP;
	}

	public String getnPWP() {
		return nPWP;
	}

	public void setnPWP(String nPWP) {
		this.nPWP = nPWP;
	}

	public short getqRekanan() {
		return qRekanan;
	}

	public void setqRekanan(short qRekanan) {
		this.qRekanan = qRekanan;
	}

	public String getrTRW() {
		return rTRW;
	}

	public void setrTRW(String rTRW) {
		this.rTRW = rTRW;
	}

	public String getTelepon() {
		return telepon;
	}

	public void setTelepon(String telepon) {
		this.telepon = telepon;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

}