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

import com.ffii.core.entity.BaseEntity
import com.ffii.fpsms.modules.master.entity.Shop
import com.ffii.fpsms.modules.purchaseOrder.entity.PurchaseOrder
import com.ffii.fpsms.modules.user.entity.User
import jakarta.persistence.*
import jakarta.validation.constraints.NotNull
import jakarta.validation.constraints.Size
import java.time.Instant

@Entity
@Table(name = "delivery_order")
open class DeliveryOrder: BaseEntity<Long>() {
    @ManyToOne
    @JoinColumn(name = "purchaseOrderId")
    open var purchaseOrder: PurchaseOrder? = null

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

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

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

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

    @ManyToOne
    @JoinColumn(name = "shopId")
    open var shop: Shop? = null

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

    @ManyToOne
    @JoinColumn(name = "handlerId", referencedColumnName = "id")
    open var handler: User? = null
}