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

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

@Entity
@Table(name = "item_uom")
open class ItemUom : BaseEntity<Long>() {
    @NotNull
    @ManyToOne
    @JoinColumn(name = "uomId", nullable = false)
    @JsonBackReference
    open var uom: UomConversion? = null

    @NotNull
    @ManyToOne
    @JoinColumn(name = "itemId", nullable = false)
    @JsonBackReference
    open var item: Items? = null

    @NotNull
    @Column(name = "baseUnit", nullable = false)
    open var baseUnit: Boolean? = null

    @NotNull
    @Column(name = "stockUnit", nullable = false)
    open var stockUnit: Boolean? = null

    @NotNull
    @Column(name = "pickingUnit", nullable = false)
    open var pickingUnit: Boolean? = null

    @NotNull
    @Column(name = "salesUnit", nullable = false)
    open var salesUnit: Boolean? = null

    @NotNull
    @Column(name = "purchaseUnit", nullable = false)
    open var purchaseUnit: Boolean? = null

    @Column(name = "price", precision = 14, scale = 2)
    open var price: BigDecimal? = null

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "currencyId")
    open var currency: Currency? = null

    @NotNull
    @Column(name = "m18Id", nullable = false)
    open var m18Id: Long? = null

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