public void GetIndependentEfcProfile_HasDependentsLowValues_Calculated() { var args = new IndependentEfcCalculatorArguments { Student = new HouseholdMember { IsWorking = false, WorkIncome = 0 }, Spouse = new HouseholdMember { IsWorking = false, WorkIncome = 0 }, AdjustedGrossIncome = 0, AreTaxFilers = false, IncomeTaxPaid = 0, UntaxedIncomeAndBenefits = 10000, AdditionalFinancialInfo = 0, CashSavingsCheckings = 0, InvestmentNetWorth = 0, BusinessFarmNetWorth = 0, HasDependents = true, MaritalStatus = MaritalStatus.MarriedRemarried, StateOfResidency = UnitedStatesStateOrTerritory.AmericanSamoa, NumberInHousehold = 3, NumberInCollege = 1, Age = 25, MonthsOfEnrollment = 9 }; EfcProfile profile = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(0, profile.ExpectedFamilyContribution); }
public void GetIndependentEfcProfile_ThreeMonthsEnrollment_Calculated() { var args = new IndependentEfcCalculatorArguments { Student = new HouseholdMember { IsWorking = true, WorkIncome = 60000 }, Spouse = null, AdjustedGrossIncome = 60000, AreTaxFilers = true, IncomeTaxPaid = 6000, UntaxedIncomeAndBenefits = 1000, AdditionalFinancialInfo = 200, CashSavingsCheckings = 80000, InvestmentNetWorth = 5000, BusinessFarmNetWorth = 0, HasDependents = false, MaritalStatus = MaritalStatus.SingleSeparatedDivorced, StateOfResidency = UnitedStatesStateOrTerritory.Alabama, NumberInHousehold = 1, NumberInCollege = 1, Age = 25, MonthsOfEnrollment = 3 }; EfcProfile profile = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(12060, profile.ExpectedFamilyContribution); }
public void GetIndependentEfcProfile_DifferentSpouseIncome_Calculated() { var args = new IndependentEfcCalculatorArguments { Student = new HouseholdMember { IsWorking = true, WorkIncome = 600000 }, Spouse = new HouseholdMember { IsWorking = true, WorkIncome = 900000 }, AdjustedGrossIncome = 1200000, AreTaxFilers = true, IncomeTaxPaid = 6000, UntaxedIncomeAndBenefits = 10000, AdditionalFinancialInfo = 2000, CashSavingsCheckings = 100000, InvestmentNetWorth = 8000, BusinessFarmNetWorth = 350000, HasDependents = true, MaritalStatus = MaritalStatus.MarriedRemarried, StateOfResidency = UnitedStatesStateOrTerritory.Alaska, NumberInHousehold = 20, NumberInCollege = 10, Age = 30, MonthsOfEnrollment = 9 }; EfcProfile profile = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(48706, profile.ExpectedFamilyContribution); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Collect user input RawIndependentEfcCalculatorArguments rawArgs = new RawIndependentEfcCalculatorArguments(); rawArgs.StudentAge = inputStudentAge.Text; rawArgs.MaritalStatus = inputMaritalStatus.SelectedValue; rawArgs.StateOfResidency = inputStateOfResidency.SelectedValue; rawArgs.IsStudentWorking = inputStudentWorking.SelectedValue; rawArgs.StudentWorkIncome = inputStudentWorkIncome.Text; rawArgs.IsSpouseWorking = inputSpouseWorking.SelectedValue; rawArgs.SpouseWorkIncome = inputSpouseWorkIncome.Text; rawArgs.StudentAgi = inputStudentAgi.Text; rawArgs.IsStudentTaxFiler = inputStudentTaxFiler.SelectedValue; rawArgs.StudentIncomeTax = inputStudentIncomeTax.Text; rawArgs.StudentUntaxedIncomeAndBenefits = inputStudentUntaxedIncomeAndBenefits.Text; rawArgs.StudentAdditionalFinancialInfo = inputStudentAdditionalFinancialInfo.Text; rawArgs.StudentCashSavingsChecking = inputStudentCashSavingsChecking.Text; rawArgs.StudentInvestmentNetWorth = inputStudentInvestmentNetWorth.Text; rawArgs.StudentBusinessFarmNetWorth = inputStudentBusinessFarmNetWorth.Text; rawArgs.HasDependents = inputHasDependents.SelectedValue; rawArgs.NumberInHousehold = inputNumberInHousehold.Text; rawArgs.NumberInCollege = inputNumberInCollege.Text; rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); IndependentEfcCalculatorArguments args = validator.ValidateIndependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Count > 0) { errorList.DataSource = validator.Errors; errorList.DataBind(); return; } // Calculate EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("2122"); EfcProfile profile = calculator.GetIndependentEfcProfile(args); // Display Results formPlaceholder.Visible = false; resultsPlaceholder.Visible = true; studentContributionOutput.Text = profile.StudentContribution.ToString(); expectedFamilyContributionOutput.Text = profile.ExpectedFamilyContribution.ToString(); } }
public void GetIndependentEfcProfile_NoStudent_ZeroEfc() { IndependentEfcCalculatorArguments args = new IndependentEfcCalculatorArguments { NumberInCollege = 3, Student = null }; EfcProfile result = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(0, result.ExpectedFamilyContribution); }
public void GetIndependentEfcProfile_NegativeNumberInCollege_ZeroEfc() { IndependentEfcCalculatorArguments args = new IndependentEfcCalculatorArguments { NumberInCollege = -1, Student = new HouseholdMember() }; EfcProfile result = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(0, result.ExpectedFamilyContribution); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Collect user input RawSimpleIndependentEfcCalculatorArguments rawArgs = new RawSimpleIndependentEfcCalculatorArguments(); rawArgs.MaritalStatus = inputMaritalStatus.SelectedValue; rawArgs.StudentAge = inputStudentAge.Text; rawArgs.StateOfResidency = inputStateOfResidency.SelectedValue; rawArgs.HasDependents = inputHasDependents.SelectedValue; rawArgs.StudentIncome = inputStudentIncome.Text; rawArgs.StudentIncomeEarnedBy = inputStudentIncomeEarnedBy.SelectedValue; rawArgs.StudentOtherIncome = inputStudentOtherIncome.Text; rawArgs.StudentIncomeTax = inputStudentIncomeTax.Text; rawArgs.StudentAssets = inputStudentAssets.Text; rawArgs.NumberInCollege = inputNumberInCollege.Text; rawArgs.NumberInHousehold = inputNumberInHousehold.Text; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); IndependentEfcCalculatorArguments args = validator.ValidateSimpleIndependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Any()) { errorList.DataSource = validator.Errors; errorList.DataBind(); return; } // Calculate EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("2021"); EfcProfile profile = calculator.GetIndependentEfcProfile(args); // Display Results formPlaceholder.Visible = false; resultsPlaceholder.Visible = true; studentContributionOutput.Text = profile.StudentContribution.ToString(); expectedFamilyContributionOutput.Text = profile.ExpectedFamilyContribution.ToString(); } }
public void GetIndependentEfcProfile_SimplifiedHighAssets_Calculated() { var args = new IndependentEfcCalculatorArguments { Student = new HouseholdMember { IsWorking = true, WorkIncome = 25000 }, Spouse = new HouseholdMember { IsWorking = true, WorkIncome = 24999 }, AdjustedGrossIncome = 49999, AreTaxFilers = false, IncomeTaxPaid = 6000, UntaxedIncomeAndBenefits = 0, AdditionalFinancialInfo = 0, CashSavingsCheckings = 123456789, InvestmentNetWorth = 123456789, BusinessFarmNetWorth = 350000, HasDependents = true, MaritalStatus = MaritalStatus.MarriedRemarried, StateOfResidency = UnitedStatesStateOrTerritory.Alaska, NumberInHousehold = 3, NumberInCollege = 1, Age = 30, IsQualifiedForSimplified = true, MonthsOfEnrollment = 9 }; EfcProfile profile = _efcCalculator.GetIndependentEfcProfile(args); Assert.AreEqual(467, profile.ExpectedFamilyContribution); }
public IndependentEfcCalculatorArguments ValidateSimpleIndependentEfcCalculatorArguments(RawSimpleIndependentEfcCalculatorArguments args) { if (args == null) { throw new ArgumentException("No raw arguments provided"); } // Marital Status MaritalStatus maritalStatus = _validator.ValidateMaritalStatus( args.MaritalStatus, LabelIndStudentMaritalStatus, ParamMaritalStatus); // Student Age int studentAge = _validator.ValidateNonZeroInteger( args.StudentAge, LabelIndStudentAge, ParamIndStudentAge); // Student Income double studentIncome = _validator.ValidatePositiveMoneyValue( args.StudentIncome, LabelIndStudentIncome, ParamIndStudentIncome); // Student Other Income double studentOtherIncome = _validator.ValidatePositiveMoneyValue( args.StudentOtherIncome, LabelIndStudentOtherIncome, ParamIndStudentOtherIncome); // Student Income Earned By IncomeEarnedBy incomeEarnedBy = _validator.ValidateIncomeEarnedBy( args.StudentIncomeEarnedBy, LabelIndStudentIncomeEarnedBy, ParamIndStudentIncomeEarnedBy); // CHECK: If Single/Separated/Divorced, "Student's Income Earned By" can not be "Both" if (maritalStatus == MaritalStatus.SingleSeparatedDivorced && incomeEarnedBy == IncomeEarnedBy.Both) { _validator.Errors.Add(new ValidationError(ParamIndStudentIncomeEarnedBy, String.Format(@"{0} was ""Single/Separated/Divorced"", but {1} was marked as earned by both student and spouse", LabelIndStudentMaritalStatus, LabelIndStudentIncomeEarnedBy))); } // CHECK: If "Student's Income Earned By" is "None", then "Parent Income" must be 0 if (incomeEarnedBy == IncomeEarnedBy.None && studentIncome > 0) { _validator.Errors.Add(new ValidationError(ParamParentIncome, String.Format(@"{0} was marked as earned by neither student nor spouse, but {1} was greater than 0", LabelIndStudentIncomeEarnedBy, LabelIndStudentIncome))); } // Student Income Tax Paid double studentIncomeTaxPaid = _validator.ValidatePositiveMoneyValue( args.StudentIncomeTax, LabelIndStudentIncomeTax, ParamIndStudentIncomeTax); // Student Assets double studentAssets = _validator.ValidatePositiveMoneyValue( args.StudentAssets, LabelIndStudentAssets, ParamIndStudentAssets); // Number in Household int numberInHousehold = _validator.ValidateNonZeroInteger( args.NumberInHousehold, LabelNumInHousehold, ParamNumInHousehold); // Number in College int numberInCollege = _validator.ValidateNonZeroInteger( args.NumberInCollege, LabelNumInCollege, ParamNumInCollege); // CHECK: Number in Household must be greater than or equal to Number in College if (numberInCollege > numberInHousehold) { _validator.Errors.Add(new ValidationError(ParamNumInCollege, String.Format(@"{0} must be less than or equal to {1}", LabelNumInCollege, LabelNumInHousehold))); } // Has Dependents bool hasDependents = _validator.ValidateBoolean( args.HasDependents, LabelIndStudentHasDep, ParamIndStudentHasDep); // CHECK: If student has dependents, Number in Household can not be less than two if (hasDependents && numberInHousehold < 2) { _validator.Errors.Add(new ValidationError(ParamIndStudentHasDep, String.Format(@"Student has dependents, but {0} was less than two.", LabelNumInHousehold))); } // State of Residency UnitedStatesStateOrTerritory stateOfResidency = _validator.ValidateUnitedStatesStateOrTerritory( args.StateOfResidency, LabelStateOfResidency, ParamStateOfResidency); if (_validator.Errors.Count > 0) { return(null); } // Build a list of arguments for the full EFC calculation using assumed // values gleaned from the "simplified" values provided bool isStudentWorking = false; bool isSpouseWorking = false; double studentWorkIncome = 0; double spouseWorkIncome = 0; if (incomeEarnedBy == IncomeEarnedBy.One) { isStudentWorking = true; studentWorkIncome = studentIncome; } if (incomeEarnedBy == IncomeEarnedBy.Both) { isStudentWorking = isSpouseWorking = true; studentWorkIncome = spouseWorkIncome = (studentIncome / 2); } HouseholdMember student = new HouseholdMember { IsWorking = isStudentWorking, WorkIncome = studentWorkIncome }; HouseholdMember spouse = null; if (maritalStatus == MaritalStatus.MarriedRemarried) { spouse = new HouseholdMember { IsWorking = isSpouseWorking, WorkIncome = spouseWorkIncome }; } IndependentEfcCalculatorArguments parsedArgs = new IndependentEfcCalculatorArguments { Student = student, Spouse = spouse, // ASSUME: "Student and Spouse's Income" == "Student and Spouse's AGI" AdjustedGrossIncome = studentIncome, // ASSUME: Student and Spouse are tax filers AreTaxFilers = true, IncomeTaxPaid = studentIncomeTaxPaid, // ASSUME: "Student and Spouse's Untaxed Income and Benefits" == "Student and Spouse's Other Income" UntaxedIncomeAndBenefits = studentOtherIncome, // ASSUME: "Student and Spouse's Additional Financial Information" is zero AdditionalFinancialInfo = 0, // ASSUME: "Student's and Spouse's Cash, Savings, and Checking" == "Student and Spouse's Assets" CashSavingsCheckings = studentAssets, // ASSUME: "Student and Spouse's Net Worth of Investments" is zero InvestmentNetWorth = 0, // ASSUME: "Student and Spouse's Net Worth of Business and/or Investment Farm" is zero BusinessFarmNetWorth = 0, HasDependents = hasDependents, MaritalStatus = maritalStatus, StateOfResidency = stateOfResidency, NumberInHousehold = numberInHousehold, NumberInCollege = numberInCollege, Age = studentAge, // ASSUME: Student is NOT qualified for simplified formula IsQualifiedForSimplified = false, // ASSUME: Nine months of enrollment MonthsOfEnrollment = 9 }; return(parsedArgs); }
public IActionResult Estimate(int NumberInHousehold, int NumberInCollege, string StateOfResidency, string Housing, int StudentAge, string MaritalStatus, bool StudentWorking, decimal StudentWorkIncome, bool StudentTaxFiler, decimal StudentAgi, bool StudentDependents, decimal StudentIncomeTax, decimal StudentUntaxedIncomeAndBenefits, decimal StudentAdditionalFinancialInfo, decimal StudentCashSavingsChecking, decimal StudentInvestmentNetWorth, decimal StudentBusinessFarmNetWorth, bool SpouseWorking, decimal SpouseWorkIncome) { ViewData["Title"] = "Independent Estimate "; ViewData["EstimateHeaderText"] = "PLACEHOLDER Estimate Header Text"; // Collect user input RawIndependentEfcCalculatorArguments rawArgs = new RawIndependentEfcCalculatorArguments(); rawArgs.StudentAge = StudentAge.ToString(); rawArgs.MaritalStatus = MaritalStatus; rawArgs.StateOfResidency = StateOfResidency; rawArgs.IsStudentWorking = StudentWorking.ToString(); rawArgs.StudentWorkIncome = StudentWorkIncome.ToString(); rawArgs.StudentAgi = StudentAgi.ToString(); rawArgs.IsStudentTaxFiler = StudentTaxFiler.ToString(); rawArgs.StudentIncomeTax = StudentIncomeTax.ToString(); rawArgs.StudentUntaxedIncomeAndBenefits = StudentUntaxedIncomeAndBenefits.ToString(); rawArgs.StudentAdditionalFinancialInfo = StudentAdditionalFinancialInfo.ToString(); rawArgs.StudentCashSavingsChecking = StudentCashSavingsChecking.ToString(); rawArgs.StudentInvestmentNetWorth = StudentInvestmentNetWorth.ToString(); rawArgs.StudentBusinessFarmNetWorth = StudentBusinessFarmNetWorth.ToString(); rawArgs.NumberInHousehold = NumberInHousehold.ToString(); rawArgs.NumberInCollege = NumberInCollege.ToString(); rawArgs.IsSpouseWorking = SpouseWorking.ToString(); rawArgs.SpouseWorkIncome = SpouseWorkIncome.ToString(); rawArgs.HasDependents = StudentDependents.ToString(); rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); IndependentEfcCalculatorArguments args = validator.ValidateIndependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Any()) { string errors = "Errors found: <ul>"; foreach (ValidationError err in validator.Errors) { errors += "<li>" + err.Message + "</li>"; } errors += "</ul>"; ViewData["Errors"] = errors; ViewData["HeaderText"] = "PLACEHOLDER Header Text"; Dictionary <string, string> FormValues = GetModelDictionary(NumberInHousehold, NumberInCollege, StateOfResidency, Housing, StudentAge, MaritalStatus, StudentWorking, StudentWorkIncome, StudentTaxFiler, StudentAgi, StudentDependents, StudentIncomeTax, StudentUntaxedIncomeAndBenefits, StudentAdditionalFinancialInfo, StudentCashSavingsChecking, StudentInvestmentNetWorth, StudentBusinessFarmNetWorth, SpouseWorking, SpouseWorkIncome); return(View("Index", FormValues)); } else { ViewData["Errors"] = ""; EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("1920", AppSettings.EfcCalculationConstants); EfcProfile profile = calculator.GetIndependentEfcProfile(args); CostOfAttendanceEstimator coaEstimator = CostOfAttendanceEstimatorConfigurationManager.GetCostOfAttendanceEstimator("1920", AppSettings.AidEstimationConstants); HousingOption ho = (HousingOption)Enum.Parse(typeof(HousingOption), Housing.ToString()); CostOfAttendance coa = coaEstimator.GetCostOfAttendance(EducationLevel.Undergraduate, ho); double grantAward = 0; double selfHelp = Math.Max(0, AppSettings.SelfHelpConstant - profile.ExpectedFamilyContribution); double maxCosts = profile.ExpectedFamilyContribution + selfHelp + AppSettings.MaxLoanAmount; double subCosts = Math.Min(maxCosts, coa.Total); string AY = AppSettings.AidYear; if (StateOfResidency == "California") { grantAward = coa.Total - subCosts; ViewData["ShowOutOfState"] = false; } else { grantAward = GetGrantAmount(AY, profile.ExpectedFamilyContribution, coa.Total + coa.OutOfStateFees); ViewData["ShowOutOfState"] = true; } double parentLoan = Math.Max(0, coa.Total - grantAward - selfHelp); double netCosts = coa.Total - grantAward; double totalCOA = coa.Total; if (StateOfResidency != "California") { parentLoan += coa.OutOfStateFees; netCosts += coa.OutOfStateFees; totalCOA += coa.OutOfStateFees; } Dictionary <string, string> EstimatedAwards = new Dictionary <string, string>(); EstimatedAwards.Add("GrantAwards", grantAward.ToString("C0")); EstimatedAwards.Add("SelfHelp", selfHelp.ToString("C0")); EstimatedAwards.Add("ParentLoans", parentLoan.ToString("C0")); EstimatedAwards.Add("GrantAwardsPct", AppSettings.PercentageGrantIndependant); EstimatedAwards.Add("NetCost", Math.Max(0, netCosts).ToString("C0")); EstimatedAwards.Add("OutOfStateFee", coa.OutOfStateFees.ToString("C0")); EstimatedAwards.Add("TotalCOA", totalCOA.ToString("C0")); ViewData["EstimatedAwards"] = EstimatedAwards; var tuple = (EfcProfile : profile, CostOfAttendance : coa); return(View(tuple)); } }
public IndependentEfcCalculatorArguments ValidateIndependentEfcCalculatorArguments(RawIndependentEfcCalculatorArguments args) { if (args == null) { throw new ArgumentException("No raw arguments provided"); } // Age int age = _validator.ValidateNonZeroInteger( args.StudentAge, LabelIndStudentAge, ParamIndStudentAge); // Marital Status MaritalStatus maritalStatus = _validator.ValidateMaritalStatus( args.MaritalStatus, LabelIndStudentMaritalStatus, ParamMaritalStatus); // Is Student Working? bool isStudentWorking = _validator.ValidateBoolean( args.IsStudentWorking, LabelIsStudentWorking, ParamIsStudentWorking); // Student Work Income double studentWorkIncome = isStudentWorking ? _validator.ValidatePositiveMoneyValue( args.StudentWorkIncome, LabelStudentWorkIncome, ParamStudentWorkIncome) : 0; HouseholdMember student = new HouseholdMember { IsWorking = isStudentWorking, WorkIncome = studentWorkIncome }; HouseholdMember spouse = null; if (maritalStatus == MaritalStatus.MarriedRemarried) { // Is Spouse Working? bool isSpouseWorking = _validator.ValidateBoolean( args.IsSpouseWorking, LabelIsSpouseWorking, ParamIsSpouseWorking); // Spouse Work Income double spouseWorkIncome = isSpouseWorking ? _validator.ValidatePositiveMoneyValue( args.SpouseWorkIncome, LabelSpouseWorkIncome, ParamSpouseWorkIncome) : 0; spouse = new HouseholdMember { IsWorking = isSpouseWorking, WorkIncome = spouseWorkIncome }; } // Student and Spouse's AGI double agi = _validator.ValidateMoneyValue( args.StudentAgi, LabelIndStudentAgi, ParamIndStudentAgi); // Are Tax Filers? bool areTaxFilers = _validator.ValidateBoolean( args.IsStudentTaxFiler, LabelIsIndStudentTaxFiler, ParamIsIndStudentTaxFiler); // Income Tax Paid double incomeTaxPaid = _validator.ValidateMoneyValue( args.StudentIncomeTax, LabelIndStudentIncomeTax, ParamIndStudentIncomeTax); // Untaxed Income And Benefits double untaxedIncomeAndBenefits = _validator.ValidatePositiveMoneyValue( args.StudentUntaxedIncomeAndBenefits, LabelIndStudentUntaxedIncomeAndBenefits, ParamIndStudentUntaxedIncomeAndBenefits); // Additional Financial Information double additionalFinancialInfo = _validator.ValidatePositiveMoneyValue( args.StudentAdditionalFinancialInfo, LabelIndStudentAdditionalFinancialInfo, ParamIndStudentAdditionalFinancialInfo); // Cash, Savings, Checking double cashSavingsChecking = _validator.ValidatePositiveMoneyValue( args.StudentCashSavingsChecking, LabelIndStudentCashSavingsChecking, ParamIndStudentCashSavingsChecking); // Investment Net Worth double investmentNetWorth = _validator.ValidateMoneyValue( args.StudentInvestmentNetWorth, LabelIndStudentInvestmentNetWorth, ParamIndStudentInvestmentNetWorth); // Business Farm Net Worth double businessFarmNetWorth = _validator.ValidateMoneyValue( args.StudentBusinessFarmNetWorth, LabelIndStudentBusinessFarmNetWorth, ParamIndStudentBusinessFarmNetWorth); // Has Dependents? bool hasDependents = _validator.ValidateBoolean( args.HasDependents, LabelIndStudentHasDep, ParamIndStudentHasDep); // State of Residency UnitedStatesStateOrTerritory stateOfResidency = _validator.ValidateUnitedStatesStateOrTerritory( args.StateOfResidency, LabelStateOfResidency, ParamStateOfResidency); // Number in Household int numberInHousehold = _validator.ValidateNonZeroInteger( args.NumberInHousehold, LabelNumInHousehold, ParamNumInHousehold); // Number in College int numberInCollege = _validator.ValidateNonZeroInteger( args.NumberInCollege, LabelNumInCollege, ParamNumInCollege); // CHECK: Number in Household must be greater than or equal to Number in College if (numberInCollege > numberInHousehold) { _validator.Errors.Add(new ValidationError(ParamNumInCollege, String.Format(@"{0} must be less than or equal to {1}", LabelNumInCollege, LabelNumInHousehold))); } // CHECK: If student has dependents, Number in Household can not be less than two if (hasDependents && numberInHousehold < 2) { _validator.Errors.Add(new ValidationError(ParamIndStudentHasDep, String.Format(@"Student has dependents, but {0} was less than two.", LabelNumInHousehold))); } // Is Qualified for Simplified bool isQualifiedForSimplified = _validator.ValidateBoolean( args.IsQualifiedForSimplified, LabelIsQualifiedForSimplified, ParamIsQualifiedForSimplified); // Months of Enrollment int monthsOfEnrollment = _validator.ValidateNonZeroInteger( args.MonthsOfEnrollment, LabelMonthsOfEnrollment, ParamMonthsOfEnrollment); if (_validator.Errors.Count > 0) { return(null); } // Build calculation arguments IndependentEfcCalculatorArguments parsedArgs = new IndependentEfcCalculatorArguments { Student = student, Spouse = spouse, AdjustedGrossIncome = agi, AreTaxFilers = areTaxFilers, IncomeTaxPaid = incomeTaxPaid, UntaxedIncomeAndBenefits = untaxedIncomeAndBenefits, AdditionalFinancialInfo = additionalFinancialInfo, CashSavingsCheckings = cashSavingsChecking, InvestmentNetWorth = investmentNetWorth, BusinessFarmNetWorth = businessFarmNetWorth, HasDependents = hasDependents, MaritalStatus = maritalStatus, StateOfResidency = stateOfResidency, NumberInHousehold = numberInHousehold, NumberInCollege = numberInCollege, Age = age, IsQualifiedForSimplified = isQualifiedForSimplified, MonthsOfEnrollment = monthsOfEnrollment }; return(parsedArgs); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { // Collect user input RawIndependentEfcCalculatorArguments rawArgs = new RawIndependentEfcCalculatorArguments(); rawArgs.StudentAge = inputStudentAge.Text; rawArgs.MaritalStatus = inputMaritalStatus.SelectedValue; rawArgs.StateOfResidency = inputStateOfResidency.SelectedValue; rawArgs.IsStudentWorking = inputStudentWorking.SelectedValue; rawArgs.StudentWorkIncome = inputStudentWorkIncome.Text; rawArgs.IsSpouseWorking = inputSpouseWorking.SelectedValue; rawArgs.SpouseWorkIncome = inputSpouseWorkIncome.Text; rawArgs.StudentAgi = inputStudentAgi.Text; rawArgs.IsStudentTaxFiler = inputStudentTaxFiler.SelectedValue; rawArgs.StudentIncomeTax = inputStudentIncomeTax.Text; rawArgs.StudentUntaxedIncomeAndBenefits = inputStudentUntaxedIncomeAndBenefits.Text; rawArgs.StudentAdditionalFinancialInfo = inputStudentAdditionalFinancialInfo.Text; rawArgs.StudentCashSavingsChecking = inputStudentCashSavingsChecking.Text; rawArgs.StudentInvestmentNetWorth = inputStudentInvestmentNetWorth.Text; rawArgs.StudentBusinessFarmNetWorth = inputStudentBusinessFarmNetWorth.Text; rawArgs.HasDependents = inputHasDependents.SelectedValue; rawArgs.NumberInHousehold = inputNumberInHousehold.Text; rawArgs.NumberInCollege = inputNumberInCollege.Text; rawArgs.MonthsOfEnrollment = "9"; rawArgs.IsQualifiedForSimplified = "false"; // Validate user input AidEstimationValidator validator = new AidEstimationValidator(); IndependentEfcCalculatorArguments args = validator.ValidateIndependentEfcCalculatorArguments(rawArgs); // If validation fails, display errors if (validator.Errors.Any()) { errorList.DataSource = validator.Errors; errorList.DataBind(); return; } // Calculate EfcCalculator calculator = EfcCalculatorConfigurationManager.GetEfcCalculator("2021"); EfcProfile profile = calculator.GetIndependentEfcProfile(args); // Display Results formPlaceholder.Visible = false; resultsPlaceholder.Visible = true; studentContributionOutput.Text = profile.StudentContribution.ToString("C0"); expectedFamilyContributionOutput.Text = profile.ExpectedFamilyContribution.ToString("C0"); CostOfAttendanceEstimator coaEstimator = CostOfAttendanceEstimatorConfigurationManager.GetCostOfAttendanceEstimator("2021"); CostOfAttendance coa = coaEstimator.GetCostOfAttendance(EducationLevel.Undergraduate, (HousingOption)Enum.Parse(typeof(HousingOption), inputHousing.SelectedValue)); tuitionFeesOutput.Text = coa.Items[0].Value.ToString("C0"); roomBoardOutput.Text = coa.Items[1].Value.ToString("C0"); booksSuppliesOutput.Text = coa.Items[2].Value.ToString("C0"); otherExpensesOutput.Text = coa.Items[3].Value.ToString("C0"); healthInsuranceOutput.Text = coa.Items[4].Value.ToString("C0"); totalCostOutput.Text = coa.Total.ToString("C0"); grantAwardOutput.Text = "$99,999"; // placeholder selfHelpAwardOutput.Text = "$99,999"; // placeholder familyHelpAwardOutput.Text = "$99,999"; // placeholder estimatedGrantOutput.Text = "$99,999"; // placeholder estimatedNetCostOutput.Text = "$99,999"; // placeholder percentageGrantOutput.Text = ConfigurationManager.AppSettings["PercentageGrant.Independent.1920"]; } else { //Enable client-side validators where no default value is defined inputStudentAge.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputStudentAge.ClientID + "').Validators[0]);"); inputSpouseWorkIncome.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputSpouseWorkIncome.ClientID + "').Validators[0]);"); inputStudentWorkIncome.Attributes.Add("onblur", "ValidatorValidate(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0]);"); // enable or disable validators linked to radio button lists inputStudentWorking.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0], true); "); inputStudentWorking.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentWorkIncome.ClientID + "').Validators[0], false); "); inputSpouseWorking.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputSpouseWorkIncome.ClientID + "').Validators[0], true); "); inputSpouseWorking.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputSpouseWorkIncome.ClientID + "').Validators[0], false); "); inputStudentTaxFiler.Items[0].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentAgi.ClientID + "').Validators[0], true); ValidatorEnable(document.getElementById('" + inputStudentIncomeTax.ClientID + "').Validators[0], true);"); inputStudentTaxFiler.Items[1].Attributes.Add("onclick", "ValidatorEnable(document.getElementById('" + inputStudentAgi.ClientID + "').Validators[0], false); ValidatorEnable(document.getElementById('" + inputStudentIncomeTax.ClientID + "').Validators[0], false);"); } }
/// <summary> /// Calculates student contribution (PC) and expected family contribution (EFC) for an independent student /// </summary> /// <param name="args">Parameters for the calculation</param> /// <returns>Student contribution (PC) and expected family contribution (EFC) for an independent student</returns> public EfcProfile GetIndependentEfcProfile(IndependentEfcCalculatorArguments args) { if (args.NumberInCollege <= 0 || args.MonthsOfEnrollment <= 0 || args.Student == null) { return(new EfcProfile(0, 0, 0, 0)); } EfcCalculationRole role = (args.HasDependents) ? EfcCalculationRole.IndependentStudentWithDependents : EfcCalculationRole.IndependentStudentWithoutDependents; double workIncome = 0; List <HouseholdMember> householdMembers = new List <HouseholdMember> { args.Student }; workIncome += args.Student.IsWorking ? args.Student.WorkIncome : 0; if (args.Spouse != null) { if (args.Spouse.IsWorking) { workIncome += args.Spouse.WorkIncome; } householdMembers.Add(args.Spouse); } double simpleIncome = (args.AreTaxFilers) ? args.AdjustedGrossIncome : workIncome; // Determine Auto Zero EFC eligibility if (args.IsQualifiedForSimplified && role == EfcCalculationRole.IndependentStudentWithDependents && simpleIncome <= _constants.AutoZeroEfcMax) { return(new EfcProfile(0, 0, 0, 0)); } // Student's Total Income double totalIncome = _incomeCalculator.CalculateTotalIncome( args.AdjustedGrossIncome, workIncome, args.AreTaxFilers, args.UntaxedIncomeAndBenefits, args.AdditionalFinancialInfo); // Student's Total Allowances double totalAllowances = _allowanceCalculator.CalculateTotalAllowances( role, args.MaritalStatus, args.StateOfResidency, args.NumberInCollege, args.NumberInHousehold, householdMembers, totalIncome, args.IncomeTaxPaid); // Student's Available Income (Contribution from Available Income) double availableIncome = _incomeCalculator.CalculateAvailableIncome(role, totalIncome, totalAllowances); // Determine Simplified EFC Equation Eligibility bool useSimplified = (args.IsQualifiedForSimplified && simpleIncome <= _constants.SimplifiedEfcMax); // Student's Contribution From Assets double assetContribution = 0; if (!useSimplified) { assetContribution = _assetContributionCalculator.CalculateContributionFromAssets( role, args.MaritalStatus, args.Age, args.CashSavingsCheckings, args.InvestmentNetWorth, args.BusinessFarmNetWorth); } // Student's Adjusted Available Income double adjustedAvailableIncome = availableIncome + assetContribution; // Student Contribution From AAI double studentContributionFromAai = _aaiContributionCalculator.CalculateContributionFromAai(role, adjustedAvailableIncome); // Student's Contribution double studentContribution = Math.Round(studentContributionFromAai / args.NumberInCollege, MidpointRounding.AwayFromZero); // Modify Student's Available Income based on months of enrollment if (args.MonthsOfEnrollment < DefaultMonthsOfEnrollment) { // LESS than default months of enrollment double monthlyContribution = Math.Round(studentContribution / DefaultMonthsOfEnrollment); studentContribution = monthlyContribution * args.MonthsOfEnrollment; } // For MORE than default months of enrollment, the standard contribution is used EfcProfile profile = new EfcProfile(studentContribution, 0, studentContribution, 0); return(profile); }