/// <summary>
 /// Calcualtes the monthly premium assistance.
 /// </summary>
 /// <param name="state">The state.</param>
 /// <param name="year">The year.</param>
 /// <param name="rateAreaId">The rate area identifier.</param>
 /// <param name="householdSize">Size of the household.</param>
 /// <param name="annualHouseholdTaxableIncome">The annual household taxable income.</param>
 /// <param name="applicantAge">The applicant age.</param>
 /// <param name="familyPercentPovertyLevel">The family percent poverty level.</param>
 /// <param name="benchmark">The benchmark.</param>
 /// <returns>
 /// Monthly premium assistance dollar amount
 /// </returns>
 public decimal CalcualteMonthlyPremiumAssistance(string state, int year, int rateAreaId, int householdSize, decimal annualHouseholdTaxableIncome, int applicantAge, out decimal familyPercentPovertyLevel, out Benchmark benchmark)
 {
     benchmark = null;
     decimal povertyAmount;
     familyPercentPovertyLevel = CalculateFamilyPercentPovertyLevel(state, year, householdSize, annualHouseholdTaxableIncome, out povertyAmount);
     return CalcualteMonthlyPremiumAssistance(state, year, rateAreaId, householdSize, annualHouseholdTaxableIncome, applicantAge, familyPercentPovertyLevel, out benchmark);
 }
 /// <summary>
 /// Calcualtes the monthly premium assistance.
 /// </summary>
 /// <param name="state">The state.</param>
 /// <param name="year">The year.</param>
 /// <param name="rateAreaId">The rate area identifier.</param>
 /// <param name="householdSize">Size of the household.</param>
 /// <param name="annualHouseholdTaxableIncome">The annual household taxable income.</param>
 /// <param name="applicantAge">The applicant age.</param>
 /// <param name="familyPercentPovertyLevel">The family percent poverty level.</param>
 /// <param name="benchmark">The benchmark.</param>
 /// <returns></returns>
 public decimal CalcualteMonthlyPremiumAssistance(string state, int year, int rateAreaId, int householdSize, decimal annualHouseholdTaxableIncome, int applicantAge, decimal familyPercentPovertyLevel, out Benchmark benchmark)
 {
     benchmark = Repository.Benchmarks.Where(b => b.State == state && b.Year == year && b.Age == applicantAge && b.RateAreaId == rateAreaId).SingleOrDefault();
     benchmark = benchmark ?? new Benchmark() { Rate = 0M };
     return CalcualteMonthlyPremiumAssistance(state, year, annualHouseholdTaxableIncome, familyPercentPovertyLevel, benchmark);
 }
        /// <summary>
        /// Calcualtes the monthly premium assistance.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <param name="year">The year.</param>
        /// <param name="annualHouseholdTaxableIncome">The annual household taxable income.</param>
        /// <param name="familyPercentPovertyLevel">The family percent poverty level.</param>
        /// <param name="benchmark">The benchmark.</param>
        /// <returns>Monthly premium assistance dollar amount</returns>
        public decimal CalcualteMonthlyPremiumAssistance(string state, int year, decimal annualHouseholdTaxableIncome, decimal familyPercentPovertyLevel, Benchmark benchmark)
        {
            var incomeCap = Repository.IncomePercentContributions.Where(i => i.IncomePercentRangeStart <= familyPercentPovertyLevel && familyPercentPovertyLevel < i.IncomePercentRangeEnd).SingleOrDefault();
            if (incomeCap == null)
                return 0;

            var incomeFplRange = (familyPercentPovertyLevel - incomeCap.IncomePercentRangeStart) / (incomeCap.IncomePercentRangeEnd - incomeCap.IncomePercentRangeStart);

            var annualFamilyTaxableIncomePercent = incomeCap.InitialPremiumPercent + (incomeFplRange * (incomeCap.FinalPremiumPercent - incomeCap.InitialPremiumPercent));

            var annualFamilyTaxableIncomeCap = annualFamilyTaxableIncomePercent * annualHouseholdTaxableIncome / 100;

            return benchmark.Rate - (annualFamilyTaxableIncomeCap / 12);
        }