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

namespace MilitaryTrainingManagement.Models.Entities;

/// <summary>
/// 消耗上报记录
/// </summary>
public class ConsumptionReport
{
    [Key]
    public int Id { get; set; }

    /// <summary>
    /// 配额分配ID
    /// </summary>
    [Required]
    public int AllocationDistributionId { get; set; }

    /// <summary>
    /// 配额分配
    /// </summary>
    [ForeignKey(nameof(AllocationDistributionId))]
    public AllocationDistribution AllocationDistribution { get; set; } = null!;

    /// <summary>
    /// 配额分配（别名，用于兼容）
    /// </summary>
    [NotMapped]
    public AllocationDistribution Distribution => AllocationDistribution;

    /// <summary>
    /// 本次上报数量
    /// </summary>
    [Required]
    [Column(TypeName = "decimal(18,2)")]
    public decimal ReportedAmount { get; set; }

    /// <summary>
    /// 上报后累计数量
    /// </summary>
    [Required]
    [Column(TypeName = "decimal(18,2)")]
    public decimal CumulativeAmount { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [MaxLength(500)]
    public string? Remarks { get; set; }

    /// <summary>
    /// 上报人ID
    /// </summary>
    [Required]
    public int ReportedByUserId { get; set; }

    /// <summary>
    /// 上报人
    /// </summary>
    [ForeignKey(nameof(ReportedByUserId))]
    public UserAccount ReportedByUser { get; set; } = null!;

    /// <summary>
    /// 上报单位ID
    /// </summary>
    [Required]
    public int ReportedByUnitId { get; set; }

    /// <summary>
    /// 上报单位
    /// </summary>
    [ForeignKey(nameof(ReportedByUnitId))]
    public OrganizationalUnit ReportedByUnit { get; set; } = null!;

    /// <summary>
    /// 上报时间
    /// </summary>
    [Required]
    public DateTime ReportedAt { get; set; }
}
