package com.ffii.fpsms.modules.jobOrder.entity

import com.fasterxml.jackson.annotation.JsonBackReference
import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.jobOrder.enums.JobOrderBomMaterialStatus
import com.ffii.fpsms.modules.jobOrder.enums.JobOrderBomMaterialStatusConverter
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.master.entity.UomConversion
import com.ffii.fpsms.modules.stock.entity.InventoryLotLine
import com.ffii.fpsms.modules.stock.entity.StockOutLine
import com.ffii.fpsms.modules.stock.entity.SuggestedPickLot
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.math.BigDecimal

@Entity
@Table(name = "job_order_bom_material")
open class JobOrderBomMaterial : BaseEntity<Long>() {
    @JsonBackReference
    @NotNull
    @ManyToOne
    @JoinColumn(name = "jobOrderId", nullable = false)
    open var jobOrder: JobOrder? = null

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

    @NotNull
    @Column(name = "reqQty", nullable = false, precision = 14, scale = 2)
    open var reqQty: BigDecimal? = null

//    @NotNull
    @ManyToOne
    @JoinColumn(name = "uomId", nullable = false)
    open var uom: UomConversion? = null

//    @Size(max = 255)
    @NotNull
    @Column(name = "status", nullable = false)
    @Convert(converter = JobOrderBomMaterialStatusConverter::class)
    open var status: JobOrderBomMaterialStatus? = null

    @ManyToOne
    @JoinColumn(name = "stockOutLineId")
    open var stockOutLine: StockOutLine? = null
}