package com.ffii.fpsms.modules.jobOrder.entity

import jakarta.persistence.*
import java.time.LocalDateTime
import com.ffii.fpsms.modules.jobOrder.enums.JoPickOrderStatus
import org.hibernate.annotations.CreationTimestamp
import org.hibernate.annotations.UpdateTimestamp

@Entity
@Table(name = "jo_pick_order_record")
class JoPickOrderRecord {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null
    
    @Column(name = "pick_order_id")
    var pickOrderId: Long? = null
    
    @Column(name = "item_id")
    var itemId: Long? = null
    
    @Enumerated(EnumType.STRING)
    @Column(name = "match_status")
    var matchStatus: JoPickOrderStatus? = null
    
    @Column(name = "match_by")
    var matchBy: Long? = null
    
    @Column(name = "match_qty")
    var matchQty: Int? = null
    
    @Column(name = "handled_by")
    var handledBy: Long? = null
    
    // New columns
    @Column(name = "jobOrderId")
    var jobOrderId: Long? = null
    
    @Column(name = "jobOrderCode")
    var jobOrderCode: String? = null
    
    @Column(name = "targetDate")
    var targetDate: LocalDateTime? = null
    
    @Column(name = "itemCode")
    var itemCode: String? = null
    
    @Column(name = "ticketReleaseTime")
    var ticketReleaseTime: LocalDateTime? = null
    
    @Column(name = "ticketCompleteTime")
    var ticketCompleteTime: LocalDateTime? = null
    
    @Column(name = "pickOrderCode")
    var pickOrderCode: String? = 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(
        pickOrderId: Long? = null,
        itemId: Long? = null,
        matchStatus: JoPickOrderStatus? = null,
        matchBy: Long? = null,
        matchQty: Int? = null,
        handledBy: Long? = null,
        jobOrderId: Long? = null,
        jobOrderCode: String? = null,
        targetDate: LocalDateTime? = null,
        itemCode: String? = null,
        ticketReleaseTime: LocalDateTime? = null,
        ticketCompleteTime: LocalDateTime? = null,
        pickOrderCode: String? = null,
        createdBy: String? = null,
        modifiedBy: String? = null
    ) {
        this.pickOrderId = pickOrderId
        this.itemId = itemId
        this.matchStatus = matchStatus
        this.matchBy = matchBy
        this.matchQty = matchQty
        this.handledBy = handledBy
        this.jobOrderId = jobOrderId
        this.jobOrderCode = jobOrderCode
        this.targetDate = targetDate
        this.itemCode = itemCode
        this.ticketReleaseTime = ticketReleaseTime
        this.ticketCompleteTime = ticketCompleteTime
        this.pickOrderCode = pickOrderCode
        this.createdBy = createdBy
        this.modifiedBy = modifiedBy
    }
}