package com.ffii.fpsms.modules.deliveryOrder.entity

import com.ffii.core.entity.BaseEntity
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Table
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.math.BigDecimal
import java.time.LocalDate

@Entity
@Table(name = "do_replenishment")
open class DoReplenishment : BaseEntity<Long>() {

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

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

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

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

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

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

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

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

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

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

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

    @Column(name = "uomId")
    open var uomId: Long? = null

    @Column(name = "shopId")
    open var shopId: Long? = null

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

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

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

    @Column(name = "targetDoId")
    open var targetDoId: Long? = null

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

    @Column(name = "pickOrderLineId")
    open var pickOrderLineId: Long? = null

    @Column(name = "deliveryOrderPickOrderId")
    open var deliveryOrderPickOrderId: Long? = null

    @NotNull
    @Size(max = 20)
    @Column(name = "status", nullable = false, length = 20)
    open var status: String = STATUS_PENDING

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

    companion object {
        const val STATUS_PENDING = "pending"
        const val STATUS_PROCESSING = "processing"
        const val STATUS_COMPLETED = "completed"
    }
}
