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

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

@Entity
@Table(name = "do_pick_order_record")
class DoPickOrderRecord {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null
    
    @Column(name = "store_id", length = 10)
    var storeId: String? = null
    
    @Column(name = "ticket_no", length = 50)
    var ticketNo: String? = null
    @Column(name = "pick_order_id")
    var pickOrderId: Long? = null
    @Enumerated(EnumType.STRING)
    @Column(name = "ticket_status")
    var ticketStatus: DoPickOrderStatus? = null
    
    @Column(name = "truck_id")
    var truckId: Long? = null
    
    @Column(name = "truck_departure_time")
    var truckDepartureTime: LocalTime? = null
    
    @Column(name = "item_id")
    var itemId: Long? = null
    
    @Column(name = "shop_id")
    var shopId: Long? = null
    
    @Column(name = "shop_po_supplier_id")
    var shopPoSupplierId: Long? = null
    
    @Column(name = "handled_by")
    var handledBy: Long? = null
    
    @CreationTimestamp
    @Column(name = "created")
    var created: LocalDateTime? = null
    
    @Column(name = "createdBy", length = 30)
    var createdBy: String? = null
    
    @Version
    var version: Int = 0
    
    @UpdateTimestamp
    @Column(name = "modified")
    var modified: LocalDateTime? = null
    
    @Column(name = "modifiedBy", length = 30)
    var modifiedBy: String? = null
    
    @Column(name = "deleted")
    var deleted: Boolean = false
    
    // Default constructor for Hibernate
    constructor()
    
    // Constructor for creating new instances
    constructor(
        storeId: String,
        ticketNo: String,
        ticketStatus: DoPickOrderStatus,
        truckId: Long? = null,
        truckDepartureTime: LocalTime? = null,
        pickOrderId: Long? = null,
        itemId: Long? = null,
        shopId: Long? = null,
        shopPoSupplierId: Long? = null,
        handledBy: Long? = null,
        createdBy: String? = null,
        modifiedBy: String? = null
    ) {
        this.storeId = storeId
        this.ticketNo = ticketNo
        this.pickOrderId = pickOrderId
        this.ticketStatus = ticketStatus
        this.truckId = truckId
        this.truckDepartureTime = truckDepartureTime
        this.itemId = itemId
        this.shopId = shopId
        this.shopPoSupplierId = shopPoSupplierId
        this.handledBy = handledBy
        this.createdBy = createdBy
        this.modifiedBy = modifiedBy
    }
}