public void CalcualteSubsidy()
        {
            int year = 2015;
            string state = "CA";
            decimal income = 24750M;
            int rateAreaId = 4;
            var family = new List<Person>(
                new Person[]
                {
                    new Person() { Dob = DateTime.Today.AddYears(-56), Relationship = Relationship.Self },
                    new Person() { Dob = DateTime.Today.AddYears(-52), Relationship = Relationship.Spouse },
                    new Person() { Dob = DateTime.Today.AddYears(-2), Relationship = Relationship.Dependent },
                    new Person() { Dob = DateTime.Today.AddYears(-21), Relationship = Relationship.Dependent },
                    new Person() { Dob = DateTime.Today.AddYears(-22), Relationship = Relationship.Dependent },
                    new Person() { Dob = DateTime.Today.AddYears(-4), Relationship = Relationship.Dependent },
                    new Person() { Dob = DateTime.Today.AddYears(-6), Relationship = Relationship.Dependent },
                    new Person() { Dob = DateTime.Today.AddYears(-18), Relationship = Relationship.Dependent },
                }
                );

            var calc = GetCalculator();
            var input = new GetFinancialAssistanceRequest() { County = "", EffectiveDate = DateTime.Now.AddMonths(1), FamilyMembers = family, FamilySize = 4, FamilyTaxableIncome = 26000, ZipCode = "94154" };
            var result = calc.CalculateSubsidy(input);

            Assert.IsNotNull(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the subsidy.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException"></exception>
        public SubsidyCalculationResult CalculateSubsidy(GetFinancialAssistanceRequest request)
        {
            int rateAreaId = 0;
            string state = string.Empty;

            request.FamilyMembers = request.FamilyMembers ?? new List<Person>();
            if (rateAreaId == 0)
            {
                rateAreaId = Repository.LookupRateAreaId(request.ZipCode, request.County, out state);
                if (rateAreaId == 0)
                {
                    throw new ArgumentException(string.Format("Subsidy calculator does not have lookup data for zip code = '{0}' and county = '{1}' ", request.ZipCode, request.County));
                }
            }
            Benchmark benchmark = null;
            decimal povertyAmount;
            var result = new SubsidyCalculationResult()
            {
                FamilyPercentPovertyLevel = Math.Round(CalculateFamilyPercentPovertyLevel(state, request.EffectiveDate.Year, request.FamilySize, request.FamilyTaxableIncome, out povertyAmount), 2),
                SilverPlanBenchmarkRate = Math.Round(CalcualteFamilySilverBenchmarkRate(state, request.EffectiveDate.Year, rateAreaId, request.FamilyMembers.ConvertAll<int>(m => m.GetAge(request.EffectiveDate))),
                2),
                Persons = request.FamilyMembers
            };
            result.PovertyDollarAmount = povertyAmount;
            result.CsrLevel = CalcualteCostShareReductionLevel(result.FamilyPercentPovertyLevel, state);

            var applicant = request.FamilyMembers.Where(m => m.Relationship == Relationship.Self).SingleOrDefault();
            if (applicant != null)
            {
                result.MonthlyPremiumAssistanceAmount = CalcualteMonthlyPremiumAssistance(state, request.EffectiveDate.Year, rateAreaId, request.FamilySize, request.FamilyTaxableIncome, applicant.GetAge(request.EffectiveDate), result.FamilyPercentPovertyLevel, out benchmark);
            }
            result.Persons.ForEach(p => SetEligibility(state, request.EffectiveDate, p, result.FamilyPercentPovertyLevel));
            return result;
        }