/// <summary> /// Produces the item names to rates for the Judgement Deductions (e.g. alimony paid-out) /// </summary> /// <param name="options"></param> /// <returns></returns> protected internal Dictionary <string, double> GetJudgmentDeductionName2RandomRates(AmericanDomusOpesOptions options) { options = options ?? AmericanDomusOpesOptions.RandomOpesOptions(); const string CHILD_SUPPORT = "Child Support"; const string ALIMONY = "Alimony"; var pay = GetPay(options); if (options.IsPayingChildSupport && !options.AnyGivenDirectlyOfNameAndGroup(CHILD_SUPPORT, DeductionGroupNames.JUDGMENTS)) { var adjPay = AmericanEquations.GetInflationAdjustedAmount(pay, 2015, options.Inception); var adjMonthlyPay = adjPay / 12; var childSupportEquation = AmericanEquations.GetChildSupportMonthlyCostEquation(options.GetChildrenAges().Count); var childSupport = Math.Round(childSupportEquation.SolveForY(adjMonthlyPay), 2); //need to turn this back into annual amount childSupport = childSupport * 12; options.AddGivenDirectly(CHILD_SUPPORT, DeductionGroupNames.JUDGMENTS, childSupport); } if (options.IsPayingSpousalSupport && !options.AnyGivenDirectlyOfNameAndGroup(ALIMONY, DeductionGroupNames.JUDGMENTS)) { //this is technically computed as 0.25 * (diff in spousal income) var randRate = Etx.RandomDouble(0.01, 0.25); var spouseSupport = Math.Round(randRate * pay, 2); options.AddGivenDirectly(ALIMONY, DeductionGroupNames.JUDGMENTS, spouseSupport); } var d = GetItemNames2Portions(DeductionGroupNames.JUDGMENTS, options); return(d.ToDictionary(t => t.Item1, t => t.Item2)); }
public void TestGetChildSupportMonthlyCostEquation() { for (var i = 1; i <= 5; i++) { var prev = 0.0D; for (var j = 2000; j < 55000; j += 500) { var t = AmericanEquations.GetChildSupportMonthlyCostEquation(i); var current = t.SolveForY(j); //assert it never goes down as income goes up if (current < prev) { Console.WriteLine($"i {i}, j {j}, current {current}, prev {prev}"); } Assert.IsTrue(current >= prev); prev = current; } } }