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

import com.ffii.fpsms.modules.deliveryOrder.enums.DoPickOrderStatus
import jakarta.persistence.*
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.UpdateTimestamp
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime

@Entity
@Table(name = "delivery_order_pick_order")
class DeliveryOrderPickOrder {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null

    @Column(name = "ticketNo", length = 50)
    var ticketNo: String? = null

    @Column(name = "storeId", length = 10)
    var storeId: String? = null

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

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

    @Column(name = "truckLanceCode", length = 50)
    var truckLanceCode: String? = null

    @Column(name = "truckDepartureTime")
    var truckDepartureTime: LocalTime? = null

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

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

    @Enumerated(EnumType.STRING)
    @Column(name = "ticketStatus")
    var ticketStatus: DoPickOrderStatus? = null

    @Column(name = "releaseType", length = 100)
    var releaseType: String? = null

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

    @Column(name = "handlerName", length = 100)
    var handlerName: String? = null

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

    @Column(name = "deliveryNoteCode", length = 50)
    var deliveryNoteCode: String? = null

    @Column(name = "cartonQty")
    var cartonQty: Int? = null

    /** Merge lineage: equals own [id] until soft-deleted into a successor [TI-M] header. */
    @Column(name = "relationshipId")
    var relationshipId: Long? = null

    @CreationTimestamp
    @Column(name = "created")
    var created: LocalDateTime? = null

    @UpdateTimestamp
    @Column(name = "modified")
    var modified: LocalDateTime? = null

    @Column(name = "deleted")
    var deleted: Boolean = false

    @Version
    var version: Int = 0
}