package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Email;

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

import java.util.Date;

import static javax.persistence.FetchType.LAZY;

/**
 * @author Salman
 * @version 1.0.0
 * @since 15 Aug 2023
 */
@Getter
@Setter
@Entity
@Table(name = "voucherpaket_m", uniqueConstraints = @UniqueConstraint(columnNames = { "paketfk", "kode" }))
public class VoucherPaket extends BaseTransaction {
	private static final long serialVersionUID = 5847793843382551441L;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "pasienfk")
	@NotNull(message = "Pasien tidak boleh kosong")
	@Caption(value = "Pasien")
	private Pasien pasien;

	@Column(name = "pasienfk", insertable = false, updatable = false, nullable = false)
	private Integer pasienId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "paketfk")
	@NotNull(message = "Paket tidak boleh kosong")
	@Caption(value = "Paket")
	private Produk paket;

	@Column(name = "paketfk", insertable = false, updatable = false, nullable = false)
	private Integer paketId;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "kelasfk")
	@NotNull(message = "Kelas tidak boleh kosong")
	@Caption(value = "Kelas")
	private Kelas kelas;

	@Column(name = "kelasfk", insertable = false, updatable = false, nullable = false)
	private Integer kelasId;

	@Column(length = 7, nullable = false)
	@Size(max = 7, message = "Maksimal kode harus 7 karakter")
	@NotNull(message = "Kode tidak boleh kosong")
	private String kode;

	@Column(nullable = false)
	@NotNull(message = "TMT tidak boleh kosong")
	private Date tmt;

	@Column(nullable = false)
	@NotNull(message = "Tanggal kedaluwarsa tidak boleh kosong")
	private Date tglKedaluwarsa;

	private Boolean isBatal;

	private Boolean isSelesai;

	@Column(name = "tglinput")
	private Date tanggalInput;

	@Column(name = "deposit")
	private Double deposit;

	@Column(length = 150)
	@Email(message = "Email tidak sesuai format")
	@Size(max = 150, message = "Maksimal email harus 150 karakter")
	private String email;

	@ManyToOne(fetch = LAZY)
	@JoinColumn(name = "lastpegawaifk")
	@Caption(value = "Pegawai")
	private Pegawai pegawai;

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

	@Column(name = "tglmodified")
	private Date modifiedDate;
}
