package kr.co.accura.wtm.domain.timesheet.entity;

import jakarta.persistence.*;
import kr.co.accura.wbx.spring.common.BaseEntity;
import kr.co.accura.wtm.domain.timesheet.NonProjectCategory;
import kr.co.accura.wtm.domain.timesheet.TimesheetEntryType;
import lombok.*;

import java.math.BigDecimal;
import java.time.LocalDate;

@Entity
@Table(name = "timesheet_entries")
@Getter @Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TimesheetEntry extends BaseEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "timesheet_id", nullable = false)
    private Timesheet timesheet;

    @Enumerated(EnumType.STRING)
    @Column(name = "entry_type", nullable = false, length = 20)
    private TimesheetEntryType entryType;

    @Column(name = "entry_date", nullable = false)
    private LocalDate entryDate;

    @Column(nullable = false, precision = 5, scale = 2)
    @Builder.Default
    private BigDecimal hours = BigDecimal.ZERO;

    // Non-Project fields
    @Column(name = "np_category", length = 100)
    private String npCategory;

    // Other Project fields
    @Column(name = "other_project_id")
    private Long otherProjectId;

    @Column(name = "other_category", length = 100)
    private String otherCategory;

    // EPC Project fields
    @Column(name = "epc_project_id")
    private Long epcProjectId;

    @Column(name = "canonical_wbs_id")
    private Long canonicalWbsId;

    @Column(name = "teal_entry_id")
    private Long tealEntryId;

    @Column(name = "revision_number")
    @Builder.Default
    private Integer revisionNumber = 1;

    @Column(length = 500)
    private String remark;
}
