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

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.Bom
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.LocalDateTime

@Entity
@Table(name = "job_order")
open class JobOrder : BaseEntity<Long>() {
    @Size(max = 100)
    @NotNull
    @Column(name = "code", nullable = false, length = 100)
    open var code: String? = null

    @NotNull
    @ManyToOne
    @JoinColumn(name = "bomId", nullable = false)
    open var bom: Bom? = null

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

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

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

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

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

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

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

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

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

    @ManyToOne
    @JoinColumn(name = "approverId", referencedColumnName = "id")
    open var approver: User? = null

    //    @ManyToOne
//    @JoinColumn(name = "jobPlanningLogId")
    @Column(name = "jobPlanningLogId")
    open var jobPlanningLogId: Long? = null
}