using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace WarehouseAppSHIPS.Models
{
    public class ProcurementRequest
    {
        [Key]
        public int Id { get; set; }
        public DateTime RequestDate { get; set; } = DateTime.Now;

        [Required, MaxLength(50)]
        public string NomorBatch { get; set; } = string.Empty;

        [ForeignKey("Requester")]
        public int RequesterId { get; set; }
        public virtual AppUser? Requester { get; set; }

        [Required, MaxLength(255)]
        public string ItemRequested { get; set; } = string.Empty;

        public int Qty { get; set; }

        [MaxLength(1000)]
        public string? Purpose { get; set; }

        [MaxLength(255)]
        public string? AttachmentFileName { get; set; }
        public string? DocumentPath { get; set; }

        public ProcurementStatus Status { get; set; } = ProcurementStatus.BelumDibeli;

        // REVISI 1 & 3: Fitur Lampu Indikator Approval & Pengambilan
        public bool? IsApproved { get; set; } // null = Pending, true = Disetujui, false = Ditolak
        public bool IsTaken { get; set; } = false; // true jika sudah diambil oleh CPAN

        [ForeignKey("Material")]
        public int? MaterialId { get; set; }
        public virtual Material? Material { get; set; }

        // === TAMBAHAN BARU: Tracking Waktu Pengadaan ===
        public DateTime? TanggalDiproses { get; set; } // Kapan status "Sedang Dibeli"
        public DateTime? TanggalDatang { get; set; }   // Kapan status "Barang Datang"

        // === TAMBAHAN BARU: Alasan Retur ===
        [MaxLength(500)]
        public string? CatatanRetur { get; set; }
    }
}