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

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.Items
import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrderLine
import com.ffii.fpsms.modules.user.entity.User
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.math.BigDecimal
import java.time.Instant
import java.time.LocalDate
import java.time.LocalDateTime

@Entity
@Table(name = "stock_in_line")
open class StockInLine : BaseEntity<Long>() {
    @NotNull
    @ManyToOne
    @JoinColumn(name = "itemId", nullable = false)
    open var item: Items? = null

    @Size(max = 20)
    @NotNull
    @Column(name = "itemNo", nullable = false, length = 20)
    open var itemNo: String? = null

    @ManyToOne
    @JoinColumn(name = "purchaseOrderLineId")
    open var purchaseOrderLine: PurchaseOrderLine? = null

    @NotNull
    @ManyToOne
    @JoinColumn(name = "stockInId", nullable = false)
    open var stockIn: StockIn? = null

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

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

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

    @Size(max = 5)
    @Column(name = "priceUnit", length = 5)
    open var priceUnit: String? = null

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

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

    @Column(name = "expiryDate")
    open var expiryDate: LocalDate? = null

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

    @ManyToOne
    @JoinColumn(name = "userId")
    open var user: User? = null

    @OneToOne
    @JoinColumn(name = "inventoryLotId")
    open var inventoryLot: InventoryLot? = null

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

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

}