Ejemplo n.º 1
0
        public void TestGetPayName2RandRates()
        {
            var testSubject = new AmericanEmployment();

            testSubject.Occupation = StandardOccupationalClassification.GetById("41-2031");
            var testResult = testSubject.GetPayName2RandRates(new AmericanDomusOpesOptions()
            {
                Inception = new DateTime(2011, 10, 5)
            });

            Assert.IsNotNull(testResult);
            Assert.AreNotEqual(0, testResult.Count);

            var testResultSum = testResult.Select(kv => kv.Value).Sum();

            Assert.AreEqual(1D, Math.Round(testResultSum));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
        }