package com.ffii.fpsms.modules.master.entity

import com.fasterxml.jackson.annotation.JsonManagedReference
import com.ffii.core.entity.BaseEntity
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import java.time.LocalDateTime

@Entity
@Table(name = "items")
open class Items : BaseEntity<Long>() {
    @NotNull
    @Column(name = "code")
    open var code: String? = null

    @NotNull
    @Column(name = "name")
    open var name: String? = null

    @Column(name = "description")
    open var description: String? = null

    @Column(name = "remarks")
    open var remarks: String? = null

    @NotNull
    @Column(name = "type")
    open var type: String? = null

    @Column(name = "shelfLife")
    open var shelfLife: Double? = null

    @Column(name = "countryOfOrigin")
    open var countryOfOrigin: String? = null

    @Column(name = "maxQty")
    open var maxQty: Double? = null

    @Column(name = "m18Id")
    open var m18Id: Long? = null

    @Column(name = "m18LastModifyDate")
    open var m18LastModifyDate: LocalDateTime? = null

    @JsonManagedReference
    @OneToMany(mappedBy = "item", cascade = [CascadeType.ALL], orphanRemoval = true)
    open var itemUoms: MutableList<ItemUom> = mutableListOf()
}