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

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.stock.enums.StockTakeStatus
import com.ffii.fpsms.modules.stock.enums.StockTakeStatusConverter
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.time.LocalDateTime

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

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

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

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

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

//    @Size(max = 20)
    @NotNull
    @Column(name = "status", nullable = false, length = 20)
    @Convert(converter = StockTakeStatusConverter::class)
    open var status: StockTakeStatus? = null

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

    /** 同一輪盤點（多 section 多筆 stock_take）共用此 id；由批次建立時依 MAX+1 遞增，不必等於任一筆主鍵 */
    @Column(name = "stockTakeRoundId")
    open var stockTakeRoundId: Long? = null
    @Size(max = 255)
    @Column(name = "stockTakeRoundName", length = 255)
    open var stockTakeRoundName: String? = null
}