using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace Fast.Database.Models;

[Table("crude_supply")]
[Index("DealId", "Date", "TransferDealId", "PointId", "MeterId", "PipelineContractId", Name = "idx_26432_IX_CrudeSupply", IsUnique = true)]
[Index("MeterId", Name = "idx_26432_IX_Supply_1")]
[Index("Date", Name = "idx_26432_IX_Supply_2")]
[Index("TransferDealId", Name = "idx_26432_IX_Supply_3")]
[Index("DealId", Name = "idx_26432_IX_Supply_4")]
[Index("PipelineContractId", Name = "idx_26432_IX_Supply_5")]
public partial class CrudeSupply
{
    [Key]
    [Column("id")]
    public int Id { get; set; }

    [Column("deal_id")]
    public int? DealId { get; set; }

    [Column("point_id")]
    public int? PointId { get; set; }

    [Column("meter_id")]
    public int? MeterId { get; set; }

    [Column("transfer_deal_id")]
    public int? TransferDealId { get; set; }

    [Column("rank")]
    public int Rank { get; set; }

    [Column("pipeline_cycle_id")]
    public int PipelineCycleId { get; set; }

    [Column("pipeline_contract_id")]
    public int? PipelineContractId { get; set; }

    [Column("duns_id")]
    public int? DunsId { get; set; }

    [Column("date")]
    public DateOnly Date { get; set; }

    [Column("act_number", TypeName = "citext")]
    public string? ActNumber { get; set; }

    [Column("ptr_delivery_meter_id")]
    public int? PtrDeliveryMeterId { get; set; }

    [Column("ptr_pipeline_contract_id")]
    public int? PtrPipelineContractId { get; set; }

    [Column("ptr")]
    public double? Ptr { get; set; }

    [Column("comment", TypeName = "citext")]
    public string? Comment { get; set; }

    [Column("source_notes", TypeName = "citext")]
    public string? SourceNotes { get; set; }

    [Column("saved_by")]
    public int SavedBy { get; set; }

    [Column("created_by")]
    public int CreatedBy { get; set; }

    [Column("saved_time")]
    public DateTime SavedTime { get; set; }

    [Column("created_time")]
    public DateTime CreatedTime { get; set; }

    [ForeignKey("CreatedBy")]
    [InverseProperty("CrudeSupplyCreatedByNavigations")]
    public virtual AppUser CreatedByNavigation { get; set; } = null!;

    [InverseProperty("SupplyNom")]
    public virtual ICollection<CrudeActual> CrudeActuals { get; set; } = new List<CrudeActual>();

    [InverseProperty("SupplyNom")]
    public virtual ICollection<CrudeMarketSupply> CrudeMarketSupplies { get; set; } = new List<CrudeMarketSupply>();

    [ForeignKey("DealId")]
    [InverseProperty("CrudeSupplies")]
    public virtual Deal? Deal { get; set; }

    [ForeignKey("DunsId")]
    [InverseProperty("CrudeSupplies")]
    public virtual DunsNumber? Duns { get; set; }

    [ForeignKey("MeterId")]
    [InverseProperty("CrudeSupplyMeters")]
    public virtual Meter? Meter { get; set; }

    [ForeignKey("PipelineContractId")]
    [InverseProperty("CrudeSupplyPipelineContracts")]
    public virtual PipelineContract? PipelineContract { get; set; }

    [ForeignKey("PointId")]
    [InverseProperty("CrudeSupplies")]
    public virtual Point? Point { get; set; }

    [ForeignKey("PtrDeliveryMeterId")]
    [InverseProperty("CrudeSupplyPtrDeliveryMeters")]
    public virtual Meter? PtrDeliveryMeter { get; set; }

    [ForeignKey("PtrPipelineContractId")]
    [InverseProperty("CrudeSupplyPtrPipelineContracts")]
    public virtual PipelineContract? PtrPipelineContract { get; set; }

    [ForeignKey("SavedBy")]
    [InverseProperty("CrudeSupplySavedByNavigations")]
    public virtual AppUser SavedByNavigation { get; set; } = null!;

    [ForeignKey("TransferDealId")]
    [InverseProperty("CrudeSupplies")]
    public virtual TransferDeal? TransferDeal { get; set; }
}
