package com.ffii.fpsms.modules.stock.entity

import com.fasterxml.jackson.annotation.JsonBackReference
import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.ItemUom
import com.ffii.fpsms.modules.master.entity.Warehouse
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStatus
import com.ffii.fpsms.modules.stock.entity.enum.InventoryLotLineStringConverter
import jakarta.persistence.Column
import jakarta.persistence.Convert
import jakarta.persistence.Entity
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import jakarta.validation.constraints.NotNull
import org.hibernate.annotations.JdbcTypeCode
import org.hibernate.type.SqlTypes
import java.math.BigDecimal
import jakarta.persistence.FetchType
@Entity
@Table(name = "inventory_lot_line")
open class InventoryLotLine : BaseEntity<Long>() {
//    @JsonBackReference
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "inventoryLotId")
    open var inventoryLot: InventoryLot? = null

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "warehouseId")
    open var warehouse: Warehouse? = null

    @Column(name = "inQty")
    open var inQty: BigDecimal? = null

    @Column(name = "outQty")
    open var outQty: BigDecimal? = null

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "stockItemUomId")
    open var stockUom: ItemUom? = null

    @Column(name = "holdQty")
    open var holdQty: BigDecimal? = null

    @Column(name = "issueQty")
    open var issueQty: BigDecimal? = null

    @Convert(converter = InventoryLotLineStringConverter::class)
    @Column(name = "status")
    open var status: InventoryLotLineStatus? = null

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

//    @JdbcTypeCode(SqlTypes.JSON)
//    @Column(name = "qrCode")
//    open var qrCode: MutableMap<String, Any?>? = null
}