package com.jasamedika.medifirst2000.entities;

import com.jasamedika.medifirst2000.base.BaseTransaction;
import com.jasamedika.medifirst2000.enums.JenisMappingProdukPaket;
import com.jasamedika.medifirst2000.helper.Caption;
import lombok.Getter;
import lombok.Setter;

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

import static javax.persistence.EnumType.STRING;
import static javax.persistence.FetchType.LAZY;

/**
 * @author Salman Manoe
 * @version 1.0.0
 * @since 21 Sep 2023
 */
@Getter
@Setter
@Entity
@Table(name = "mapprodukpaket_m", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "paketfk", "produkPaketfk" }), })
public class MapProdukPaket extends BaseTransaction {

	@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 = "produkpaketfk")
	@NotNull(message = "Produk paket tidak boleh kosong")
	@Caption(value = "Produk paket")
	private Produk produkEntri;

	@Column(name = "produkpaketfk", insertable = false, updatable = false, nullable = false)
	private Integer produkEntriId;

	private Integer jumlah;

	@Column(length = 100)
	@Enumerated(STRING)
	private JenisMappingProdukPaket jenisMapping;

	@Column(name = "isaktif", nullable = false)
	@NotNull(message = "Status aktif tidak boleh kosong")
	@Caption(value = "Status Aktif")
	private Boolean isAktif;

}
