예제 #1
0
        protected internal override void RandomizeAllItems(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var stDt   = options.Inception == DateTime.MinValue ? GetYearNeg(-1) : options.Inception;
            var ranges = GetYearsInDates(stDt);

            if (options.SumTotal == null || options.SumTotal == 0)
            {
                var randIncome = Math.Round(options.GetRandomYearlyIncome(options.Inception).ToDouble() *
                                            PERCENT_EXPENSE_OF_INCOME);
                options.SumTotal = randIncome;
            }

            foreach (var range in ranges)
            {
                var cloneOptions = options.GetClone();
                cloneOptions.Inception    = range.Item1;
                cloneOptions.Terminus     = range.Item2;
                cloneOptions.DueFrequency = PecuniamExtensions.GetTropicalMonth();

                var items = GetItemsForRange(cloneOptions);
                foreach (var item in items)
                {
                    AddItem(item);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Produces the item names to rates for the Home Expenses (e.g. rent)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Dictionary <string, double> GetHomeExpenseNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            //TODO - integrate ability to have multiple mortgages in options
            options.AddZeroPortion("Other Lein", ExpenseGroupNames.HOME);

            //we want almost all-of-it in Mortgage
            options.Rate = RandPortions.DiminishingRate.VeryFast;

            if (options.IsRenting)
            {
                options.AddZeroPortion("Mortgage", ExpenseGroupNames.HOME);
                options.AddZeroPortion("Maintenance", ExpenseGroupNames.HOME);
                options.AddZeroPortion("Property Tax", ExpenseGroupNames.HOME);
                options.AddZeroPortion("Association Fees", ExpenseGroupNames.HOME);
            }
            else
            {
                options.AddZeroPortion("Rent", ExpenseGroupNames.HOME);
                options.AddPossibleZeroOuts("Association Fees");
            }

            var d = GetItemNames2Portions(ExpenseGroupNames.HOME, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #3
0
        /// <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));
        }
예제 #4
0
        /// <summary>
        /// Produces the item names to rates for the Judgment related forms of Income (e.g. alimony received)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetJudgmentIncomeNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var d = GetItemNames2Portions(IncomeGroupNames.JUDGMENTS, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #5
0
        /// <summary>
        /// Produces the item names to rates for the Income produced from Real Property (e.g. rental property)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetRealPropertyIncomeNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var d = GetItemNames2Portions(IncomeGroupNames.REAL_PROPERTY, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #6
0
        /// <summary>
        /// Produces the item names to rates for the Government Deductions (i.e. taxes)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetGovernmentDeductionName2Rates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            //if the caller has assign values themselves - then just use those and leave
            if (options.AnyGivenDirectly())
            {
                return(GetItemNames2Portions(DeductionGroupNames.GOVERNMENT, options)
                       .ToDictionary(t => t.Item1, t => t.Item2));
            }

            var pay = GetPay(options);

            var fedTaxRate   = AmericanEquations.FederalIncomeTaxRate.SolveForY(pay);
            var stateTaxRate = GetRandomValueFrom(fedTaxRate, 5);

            var fedTaxAmt      = pay * fedTaxRate;
            var stateTaxAmt    = pay * stateTaxRate;
            var ficaTaxAmt     = pay * AmericanData.FICA_DEDUCTION_TAX_RATE;
            var medicareTaxAmt = pay * AmericanData.MEDICARE_DEDUCTION_TAX_RATE;

            options.AddGivenDirectly("Federal tax", DeductionGroupNames.GOVERNMENT, fedTaxAmt);
            options.AddGivenDirectly("State tax", DeductionGroupNames.GOVERNMENT, stateTaxAmt);
            options.AddGivenDirectly("FICA", DeductionGroupNames.GOVERNMENT, ficaTaxAmt);
            options.AddGivenDirectly("Medicare", DeductionGroupNames.GOVERNMENT, medicareTaxAmt);

            //this will be used later, only overwrite it if is unassigned
            if (options.SumTotal == null || options.SumTotal == 0)
            {
                options.SumTotal = (fedTaxAmt + stateTaxAmt + ficaTaxAmt + medicareTaxAmt);
            }

            return(GetItemNames2Portions(DeductionGroupNames.GOVERNMENT, options)
                   .ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #7
0
        /// <summary>
        /// Gets a money amount at random based on the age and either the
        /// employment history or location of the opes options
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Pecuniam GetRandomExpectedIncomeAmount(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var dt = options.Inception == DateTime.MinValue ? DateTime.Today : options.Inception;

            var age = options.FactorOptions.GetAge();

            var ageAtDt = age <= 0 ? AmericanData.AVG_AGE_AMERICAN : age;

            //get something randome near this value
            var randRate = GetRandomRateFromClassicHook(ageAtDt);

            //its income so it shouldn't be negative by definition
            if (randRate <= 0D)
            {
                return(Pecuniam.Zero);
            }

            //get some base to calc the product
            var someBase = Employment.Any()
                           ? GetAnnualEmplyGrossIncome(dt)
                           : options.GetRandomYearlyIncome(dt);

            var randAmt = someBase.ToDouble() * randRate;

            return(randAmt.ToPecuniam());
        }
예제 #8
0
        /// <summary>
        /// Produces the item names to rates for the Transportation Expenses (e.g. car payment, gas, etc.)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Dictionary <string, double> GetTransportationExpenseNames2RandomRates(
            AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, ExpenseGroupNames.TRANSPORTATION));

            //focus most-of-it on Loan Payments or fuel
            options.Rate = RandPortions.DiminishingRate.Fast;

            if (options.NumberOfVehicles > 0)
            {
                if (options.IsVehiclePaidOff)
                {
                    options.AddZeroPortion("Loan Payments", ExpenseGroupNames.TRANSPORTATION);
                }

                options.AddZeroPortion("Public Transportation", ExpenseGroupNames.TRANSPORTATION);
            }
            else
            {
                options.AddZeroPortion("Loan Payments", ExpenseGroupNames.TRANSPORTATION);
                options.AddZeroPortion("Fuel", ExpenseGroupNames.TRANSPORTATION);
                options.AddZeroPortion("Maintenance", ExpenseGroupNames.TRANSPORTATION);
                options.AddZeroPortion("Property Tax", ExpenseGroupNames.TRANSPORTATION);
                options.AddZeroPortion("Parking", ExpenseGroupNames.TRANSPORTATION);
                options.AddZeroPortion("Registration Fees", ExpenseGroupNames.TRANSPORTATION);
            }

            var d = GetItemNames2Portions(ExpenseGroupNames.TRANSPORTATION, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #9
0
        protected internal override void RandomizeAllItems(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var personality = options.Personality;
            var eduFlag     = options.FactorOptions.EducationLevel;

            //employment will be in jagged blocks start-end being random
            var emply = GetRandomEmployment(options, personality, eduFlag);

            foreach (var emp in emply)
            {
                AddEmployment(emp);
            }

            var minDate = options.Inception == DateTime.MinValue ? GetYearNeg(-1) : options.Inception;

            //for all the other items we want the blocks to be nice and even
            var ranges = GetYearsInDates(minDate);

            foreach (var range in ranges)
            {
                var cloneOptions = options.GetClone();
                cloneOptions.DueFrequency = Constants.TropicalYear;
                cloneOptions.Inception    = range.Item1;
                cloneOptions.Terminus     = range.Item2;

                if (cloneOptions.SumTotal == null || cloneOptions.SumTotal == 0)
                {
                    cloneOptions.SumTotal = GetRandomExpectedIncomeAmount(cloneOptions).ToDouble();
                }

                //there aren't ever random but calculated off gross and net income(s)
                if (!cloneOptions.AnyGivenDirectlyOfName(IncomeGroupNames.PUBLIC_BENEFITS))
                {
                    cloneOptions.AddGivenDirectly(IncomeGroupNames.PUBLIC_BENEFITS);
                }

                //make the caller assign these directly
                if (!cloneOptions.AnyGivenDirectlyOfName(IncomeGroupNames.JUDGMENTS))
                {
                    cloneOptions.AddGivenDirectly(IncomeGroupNames.JUDGMENTS);
                }

                var items = GetItemsForRange(cloneOptions);
                foreach (var item in items)
                {
                    AddItem(item);
                }

                var welfareItems = GetPublicBenefitIncomeItemsForRange(cloneOptions);
                if (welfareItems.Any())
                {
                    foreach (var welfareItem in welfareItems)
                    {
                        AddItem(welfareItem);
                    }
                }
            }
        }
예제 #10
0
        public static AmericanAssets RandomAssets(AmericanDomusOpesOptions options = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var assets = new AmericanAssets();

            assets.RandomizeAllItems(options);
            return(assets);
        }
예제 #11
0
        public static AmericanIncome RandomIncome(AmericanDomusOpesOptions options = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var income = new AmericanIncome();

            income.RandomizeAllItems(options);
            return(income);
        }
예제 #12
0
        public static AmericanExpenses RandomExpenses(AmericanDomusOpesOptions options = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var exp = new AmericanExpenses();

            exp.RandomizeAllItems(options);
            return(exp);
        }
예제 #13
0
        /// <summary>
        /// Produces the item names to rates for the Income produced from Securities (e.g. dividends, capital-gains, etc.)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetSecuritiesIncomeNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, IncomeGroupNames.SECURITIES));
            var d = GetItemNames2Portions(IncomeGroupNames.SECURITIES, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #14
0
        /// <summary>
        /// Produces the item names to rates for Institutionally Held Assets (e.g. Money Market).
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetInstitutionalAssetName2Rates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, AssetGroupNames.INSTITUTIONAL));
            var d = GetItemNames2Portions(AssetGroupNames.INSTITUTIONAL, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #15
0
        private double GetPay(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var pPay = _employment.GetAt(options.Inception).Sum() ?? Pecuniam.Zero;
            var pay  = pPay == Pecuniam.Zero ? options.GetRandomYearlyIncome(options.Inception).ToDouble() : pPay.ToDouble();

            return(pay);
        }
예제 #16
0
        /// <summary>
        /// Produces the item names to rates for the Health Expenses (i.e. being paid out-of-pocket)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetHealthExpenseNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, ExpenseGroupNames.HEALTH));
            var d = GetItemNames2Portions(ExpenseGroupNames.HEALTH, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #17
0
        protected internal override void RandomizeAllItems(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            AssignFactorValues(options.FactorOptions);
            options.DueFrequency = Constants.TropicalYear;
            var items = GetItemsForRange(options);

            foreach (var item in items)
            {
                AddItem(item);
            }
        }
예제 #18
0
        /// <summary>
        /// Produces the item names to rates for the Utility Expenses (e.g. gas bill)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetUtilityExpenseNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            if (options.IsRenting)
            {
                options.AddPossibleZeroOuts(GetAllowZeroNames(Division, ExpenseGroupNames.UTILITIES));
            }

            var d = GetItemNames2Portions(ExpenseGroupNames.UTILITIES, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #19
0
        protected internal override List <Tuple <string, double> > GetGroupNames2Portions(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var amtR = options.SumTotal == null || options.SumTotal == 0
                ? _totalEquity
                : (double)options.SumTotal;

            var givenDirectly = new List <Tuple <string, string, double> >();
            var assignedRealEstateDirectly =
                options.AnyGivenDirectlyOfNameAndGroup(REAL_PROPERTY_HOME_OWNERSHIP, AssetGroupNames.REAL_PROPERTY);

            var assignedVehicleDirectly = options.AnyGivenDirectlyOfNameAndGroup(PERSONAL_PROPERTY_MOTOR_VEHICLES,
                                                                                 AssetGroupNames.PERSONAL_PROPERTY);

            var assignedCheckingDirectly =
                options.AnyGivenDirectlyOfNameAndGroup(INSTITUTIONAL_CHECKING, AssetGroupNames.INSTITUTIONAL);

            var assignedSavingDirectly =
                options.AnyGivenDirectlyOfNameAndGroup(INSTITUTIONAL_SAVINGS, AssetGroupNames.INSTITUTIONAL);

            if (!options.IsRenting && !assignedRealEstateDirectly)
            {
                givenDirectly.Add(new Tuple <string, string, double>(REAL_PROPERTY_HOME_OWNERSHIP,
                                                                     AssetGroupNames.REAL_PROPERTY, (_homeEquityRate * amtR)));
            }

            if (options.NumberOfVehicles > 0 && !assignedVehicleDirectly)
            {
                givenDirectly.Add(new Tuple <string, string, double>(PERSONAL_PROPERTY_MOTOR_VEHICLES,
                                                                     AssetGroupNames.PERSONAL_PROPERTY, (_carEquityRate * amtR)));
            }
            if (!assignedCheckingDirectly)
            {
                givenDirectly.Add(new Tuple <string, string, double>(INSTITUTIONAL_CHECKING,
                                                                     AssetGroupNames.INSTITUTIONAL, (_checkingAccountRate * amtR)));
            }
            if (!assignedSavingDirectly)
            {
                givenDirectly.Add(new Tuple <string, string, double>(INSTITUTIONAL_SAVINGS, AssetGroupNames.INSTITUTIONAL,
                                                                     (_savingsAccountRate * amtR)));
            }

            if (options.SumTotal == null || options.SumTotal == 0)
            {
                options.Rate = RandPortions.DiminishingRate.VeryFast;
                options.AddGivenDirectlyRange(givenDirectly);
            }

            return(base.GetGroupNames2Portions(options));
        }
예제 #20
0
        /// <summary>
        /// Produces the item names to rates for the Real Property Assets
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Dictionary <string, double> GetRealPropertyName2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.Rate = RandPortions.DiminishingRate.VeryFast;

            if (options.IsRenting)
            {
                options.AddZeroPortion(REAL_PROPERTY_HOME_OWNERSHIP, AssetGroupNames.REAL_PROPERTY);
            }
            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, AssetGroupNames.REAL_PROPERTY));
            var d = GetItemNames2Portions(AssetGroupNames.REAL_PROPERTY, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #21
0
        /// <summary>
        /// Produces the item names to rates for the Insurance Expenses (being paid for directly, not as a deduction)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Dictionary <string, double> GetInsuranceExpenseNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, ExpenseGroupNames.INSURANCE));

            options.AddZeroPortion(options.IsRenting ? "Home" : "Renters", ExpenseGroupNames.INSURANCE);

            if (options.NumberOfVehicles > 0)
            {
                options.AddZeroPortion("Vehicle", ExpenseGroupNames.INSURANCE);
            }

            var d = GetItemNames2Portions(ExpenseGroupNames.INSURANCE, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #22
0
        /// <summary>
        /// Composes the items for Public Benefits (a.k.a. welfare) whenever
        /// income is below the federal poverty level
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual NamedTradeline[] GetPublicBenefitIncomeItemsForRange(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var startDate = options.Inception;
            var endDate   = options.Terminus;
            var itemsout  = new List <NamedTradeline>();

            startDate = startDate == DateTime.MinValue ? GetYearNeg(-1) : startDate;
            var isPoor = IsBelowFedPovertyAt(options);

            var grossIncome = GetAnnualEmplyGrossIncome(startDate);
            var netIncome   = GetAnnualEmplyNetIncome(startDate);
            var hudAmt      = isPoor ? GetHudMonthlyAmount(grossIncome, netIncome) : Pecuniam.Zero;
            var snapAmt     = isPoor ? GetFoodStampsMonthlyAmount(netIncome) : Pecuniam.Zero;

            var incomeItems = GetIncomeItemNames().Where(i => i.GetName(KindsOfNames.Group) == IncomeGroupNames.PUBLIC_BENEFITS);

            foreach (var incomeItem in incomeItems)
            {
                NamedTradeline p = null;

                switch (incomeItem.Name)
                {
                case "Supplemental Nutrition Assistance Program":
                    p = NamedTradeline.RandomNamedTradelineWithHistoryToSum(incomeItem.Name,
                                                                            IncomeGroupNames.PUBLIC_BENEFITS, snapAmt,
                                                                            PecuniamExtensions.GetTropicalMonth(), startDate, endDate);
                    break;

                case "Housing Choice Voucher Program Section 8":
                    p = NamedTradeline.RandomNamedTradelineWithHistoryToSum(incomeItem.Name,
                                                                            IncomeGroupNames.PUBLIC_BENEFITS, hudAmt,
                                                                            PecuniamExtensions.GetTropicalMonth(), startDate, endDate);
                    break;
                    //TODO implement the other welfare programs
                }
                if (p != null)
                {
                    itemsout.Add(p);
                }
            }
            return(itemsout.ToArray());
        }
예제 #23
0
        /// <summary>
        /// Produces the item names to rates for the Employment Deductions (e.g. 401K)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetEmploymentDeductionName2Rates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, DeductionGroupNames.EMPLOYMENT));

            //if the caller has assign values themselves - then just use those and leave
            if (options.AnyGivenDirectly())
            {
                return(GetItemNames2Portions(DeductionGroupNames.EMPLOYMENT, options)
                       .ToDictionary(t => t.Item1, t => t.Item2));
            }

            var pay = GetPay(options);

            var retirementRate = Etx.RandomPickOne(new[] { 0.01D, 0.02D, 0.03D, 0.04D, 0.05D });
            var retirementAmt  = pay * retirementRate;

            options.AddGivenDirectly("Registered Retirement Savings Plan", DeductionGroupNames.EMPLOYMENT,
                                     retirementAmt);

            var unionDuesAmt = StandardOccupationalClassification.IsLaborUnion(_employment.Occupation)
                ? pay * GetRandomValueFrom(0.04)
                : 0.0D;

            options.AddGivenDirectly("Union Dues", DeductionGroupNames.EMPLOYMENT, unionDuesAmt);

            //we need to have a SumTotal exceeding the current GivenDirectly's sum to have any of the others show up at random
            var someRandRate = GetRandomRateFromClassicHook(options.FactorOptions.GetAge());

            //we will use to force the SumTotal to exceed current GivenDirectly's sum
            var currentTotal   = retirementAmt + unionDuesAmt;
            var someRandAmount = currentTotal * someRandRate;

            //this will be used later, only overwrite it if is unassigned
            if (options.SumTotal == null || options.SumTotal == 0)
            {
                options.SumTotal = currentTotal + someRandAmount;
            }

            return(GetItemNames2Portions(DeductionGroupNames.EMPLOYMENT, options)
                   .ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #24
0
        /// <summary>
        /// Produces the item names to rates for the Personal Property Assets.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual Dictionary <string, double> GetPersonalPropertyAssetNames2Rates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, AssetGroupNames.PERSONAL_PROPERTY));

            //remove obvious rural related items for everyone except those who are way out in the country
            var livesInCountry = options.HomeLocation is UsCityStateZip usCityState &&
                                 usCityState.Msa?.MsaType >= UrbanCentric.Fringe;

            if (!livesInCountry)
            {
                options.AddZeroPortion("Crops", AssetGroupNames.PERSONAL_PROPERTY);

                options.AddZeroPortion("Livestock", AssetGroupNames.PERSONAL_PROPERTY);
            }

            var d = GetItemNames2Portions(AssetGroupNames.PERSONAL_PROPERTY, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #25
0
        /// <summary>
        /// Determines if the annual gross income is at or below the federal poverty level.
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal virtual bool IsBelowFedPovertyAt(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var dt = options.Inception;
            var numHouseholdMembers =
                1 + (options.FactorOptions.MaritalStatus == MaritalStatus.Married ? 1 : 0) + options.ChildrenDobs?.Count ?? 0;

            numHouseholdMembers = numHouseholdMembers <= 0 ? 1 : numHouseholdMembers;
            var povertyLevel = AmericanEquations.GetFederalPovertyLevel(dt);

            var payAtDt = GetEmploymentAt(dt);

            if (payAtDt == null || !payAtDt.Any())
            {
                return(false);
            }

            numHouseholdMembers = numHouseholdMembers <= 0 ? 1 : numHouseholdMembers;

            return(GetAnnualEmplyGrossIncome(dt).ToDouble() <= povertyLevel.SolveForY(numHouseholdMembers));
        }
예제 #26
0
        protected internal override List <Tuple <string, double> > GetGroupNames2Portions(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            //deductions act differently than other items since they are calculated from income
            var grps = new List <Tuple <string, double> >
            {
                new Tuple <string, double>(DeductionGroupNames.INSURANCE, 1),
                new Tuple <string, double>(DeductionGroupNames.EMPLOYMENT, 1),
                new Tuple <string, double>(DeductionGroupNames.GOVERNMENT, 1),
            };

            var assignedJudgmentsDirectly = options.AnyGivenDirectlyOfName(DeductionGroupNames.JUDGMENTS) ||
                                            options.AnyGivenDirectlyOfGroupName(DeductionGroupNames.JUDGMENTS);

            var optionsIncludeJudgment = options.IsPayingChildSupport || options.IsPayingSpousalSupport;

            var judgments = assignedJudgmentsDirectly || optionsIncludeJudgment ? 1 : 0;

            grps.Add(new Tuple <string, double>(DeductionGroupNames.JUDGMENTS, judgments));

            return(grps);
        }
예제 #27
0
        /// <summary>
        /// Produces the item names to rates for the Insurance Deductions
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetInsuranceDeductionName2RandRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            options.AddPossibleZeroOuts(GetAllowZeroNames(Division, DeductionGroupNames.INSURANCE));

            //if the caller has assign values themselves - then just use those and leave
            if (options.AnyGivenDirectly())
            {
                return(GetItemNames2Portions(DeductionGroupNames.INSURANCE, options)
                       .ToDictionary(t => t.Item1, t => t.Item2));
            }

            var expectedHealthInsCost = GetRandomEmployeeHealthInsCost(options.Inception);
            var expectedDentalInsCost = GetRandomValueFrom(expectedHealthInsCost, 8);
            var expectedVisionInsCost = GetRandomValueFrom(expectedHealthInsCost, 13);

            options.AddGivenDirectly("Health", DeductionGroupNames.INSURANCE, expectedHealthInsCost);

            options.AddGivenDirectly("Dental", DeductionGroupNames.INSURANCE, expectedDentalInsCost);

            options.AddGivenDirectly("Vision", DeductionGroupNames.INSURANCE, expectedVisionInsCost);

            var someRandRate = GetRandomRateFromClassicHook(options.FactorOptions.GetAge());

            //we will use to force the SumTotal to exceed current GivenDirectly's sum
            var currentTotal = expectedHealthInsCost + expectedDentalInsCost + expectedVisionInsCost;
            var otherInsCost = currentTotal * someRandRate;

            //this will be used later, only overwrite it if is unassigned
            if (options.SumTotal == null || options.SumTotal == 0)
            {
                options.SumTotal = otherInsCost + currentTotal;
            }

            var d = GetItemNames2Portions(DeductionGroupNames.INSURANCE, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #28
0
        protected internal override void RandomizeAllItems(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            var ranges = _employment.MyItems.Any()
                ? _employment.MyItems.Select(e => new Tuple <DateTime, DateTime?>(e.Inception, e.Terminus))
                : GetYearsInDates(options.Inception);

            foreach (var range in ranges.Distinct())
            {
                var cloneOptions = options.GetClone();
                cloneOptions.DueFrequency = Constants.TropicalYear;

                cloneOptions.Inception = range.Item1;
                cloneOptions.Terminus  = range.Item2;

                var items = GetItemsForRange(cloneOptions);
                foreach (var item in items)
                {
                    AddItem(item);
                }
            }
        }
예제 #29
0
        /// <summary>
        /// Produces the item names to rates for the Child Related Expenses (e.g. day-care),
        /// which are NOT included in groceries (e.g. diapers, food, clothes, etc.)
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        protected internal Dictionary <string, double> GetChildrenExpenseNames2RandomRates(AmericanDomusOpesOptions options)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();

            //when children are young we want to reflect that
            if (options.GetChildrenAges().All(x => x < AmericanData.AVG_AGE_CHILD_ENTER_SCHOOL))
            {
                options.AddZeroPortion("Transportation", ExpenseGroupNames.CHILDREN);
                options.AddZeroPortion("School Supplies", ExpenseGroupNames.CHILDREN);
                options.AddZeroPortion("Lunch Money", ExpenseGroupNames.CHILDREN);
                options.AddZeroPortion("Extracurricular", ExpenseGroupNames.CHILDREN);
                options.AddZeroPortion("Camp", ExpenseGroupNames.CHILDREN);
                options.AddZeroPortion("Allowance", ExpenseGroupNames.CHILDREN);
            }
            else
            {
                options.AddPossibleZeroOuts(GetAllowZeroNames(Division, ExpenseGroupNames.CHILDREN));
            }

            var d = GetItemNames2Portions(ExpenseGroupNames.CHILDREN, options);

            return(d.ToDictionary(t => t.Item1, t => t.Item2));
        }
예제 #30
0
        /// <summary>
        /// Get an ordered list of employment for the last three years at random
        /// </summary>
        /// <param name="options"></param>
        /// <param name="personality"></param>
        /// <param name="eduLevel"></param>
        /// <param name="emplyRanges">
        /// Optional, allows calling assembly to set this directly, defaults to <see cref="GetEmploymentRanges"/>
        /// </param>
        /// <returns></returns>
        protected internal virtual List <ILaboris> GetRandomEmployment(AmericanDomusOpesOptions options, IPersonality personality = null,
                                                                       OccidentalEdu eduLevel = OccidentalEdu.None, List <Tuple <DateTime, DateTime?> > emplyRanges = null)
        {
            options = options ?? AmericanDomusOpesOptions.RandomOpesOptions();
            var empls = new HashSet <ILaboris>();

            emplyRanges = emplyRanges ?? GetEmploymentRanges(options, personality);

            //limit result to those which match the edu level
            Predicate <SocDetailedOccupation> filter = null;

            if (eduLevel < (OccidentalEdu.Bachelor | OccidentalEdu.Grad))
            {
                filter = s => !StandardOccupationalClassification.IsDegreeRequired(s);
            }

            var occ = StandardOccupationalClassification.RandomOccupation(filter);

            foreach (var range in emplyRanges)
            {
                var emply = new AmericanEmployment()
                {
                    Occupation = occ
                };
                var cloneOptions = options.GetClone();
                cloneOptions.Inception = range.Item1;
                cloneOptions.Terminus  = range.Item2;
                emply.RandomizeAllItems(options);
                empls.Add(emply);
            }

            var e = empls.ToList();

            e.Sort(Comparer);
            return(e);
        }