using System;
using Volpe.Cafe.MarketData.BaselineInfo;
using Volpe.Cafe.MarketData.Design;

namespace Volpe.Cafe.DfsSrModels
{
    /// <summary>
    /// Represents the forecast vehicle data for a single model year and associated with a specific vehicle revision.
    /// </summary>
    [Serializable]
    public class ForecastVehicleData
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ForecastVehicleData"/> class, using information obtained from
        /// the specified revision of a vehicle.
        /// </summary>
        public ForecastVehicleData(IVehicleRevision vehRevision)
        {
            this.RevisionInfo = vehRevision;
            this.Sales = vehRevision.Sales;
        }

        /// <summary>
        /// Gets the vehicle revision associated with the forecast vehicle data for a specific model year.
        /// </summary>
        public IVehicleRevision RevisionInfo { get; }

        /// <inheritdoc cref="IVehicleInfo.RegClass"/>
        public RegulatoryClass RegClass => this.RevisionInfo.RegClass;
        /// <inheritdoc cref="IVehicleInfo.VehicleClass"/>
        public VehicleClass VehClass => this.RevisionInfo.VehicleClass;
        /// <inheritdoc cref="IVehicleInfo.Style"/>
        public VehicleStyle VehStyle => this.RevisionInfo.Style;

        /// <inheritdoc cref="IVehicleInfo.FuelEconomy"/>
        public FuelValue FuelEconomy => this.RevisionInfo.FuelEconomy;
        /// <inheritdoc cref="IVehicleInfo.FuelShare"/>
        public FuelValue FuelShare => this.RevisionInfo.FuelShare;
        /// <inheritdoc cref="IVehicleInfo.FuelType"/>
        public FuelType FuelType => this.RevisionInfo.FuelType;

        /// <inheritdoc cref="IVehicleInfo.CurbWeight"/>
        public double CurbWeight => this.RevisionInfo.CurbWeight;
        /// <inheritdoc cref="BaselineVehicle.VehiclePower"/>
        public double VehiclePower => this.RevisionInfo.BaselineInfo.VehiclePower;

        /// <summary>
        /// Gets the regulatory costs attributed to a combination of fuel improving technology application and civil
        /// penalties paid by a manufacturer for non-compliance.
        /// </summary>
        public double RegCost => this.RevisionInfo.ComplianceCosts.RegCost;

        /// <summary>
        /// Gets the amount of additional vehicle tax credits accumulated by the vehicle, computed as the difference
        /// between the vehicle's "final" state during a specific model year and its unaltered state (before any new
        /// technology application).
        /// </summary>
        public double TaxCredit
        {
            get {
                double deltaTaxCredit = this.RevisionInfo.AuxiliaryHevCosts.TaxCredit
                                      - this.RevisionInfo.InitAuxiliaryHevCosts.TaxCredit;
                return deltaTaxCredit;
            }
        }

        /// <summary>
        /// Gets the amount of additional battery tax credits accumulated by the vehicle, computed as the difference
        /// between the vehicle's "final" state during a specific model year and its unaltered state (before any new
        /// technology application).
        /// </summary>
        public double BatteryTaxCredit
        {
            get {
                double deltaBatteryTaxCredit = this.RevisionInfo.AuxiliaryHevCosts.BatteryTaxCredit
                                             - this.RevisionInfo.InitAuxiliaryHevCosts.BatteryTaxCredit;
                return deltaBatteryTaxCredit;
            }
        }

        /// <summary>
        /// Gets or sets the sales forecast estimated for a vehicle during a specific model year.
        /// </summary>
        public double Sales { get; set; }

    }
}
