Example #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);
                }
            }
        }
Example #2
0
        public void TestGetTropicalMonth()
        {
            var testResult = PecuniamExtensions.GetTropicalMonth();

            Console.WriteLine($"Days: {testResult.Days}, Hours: {testResult.Hours}, Minutes: {testResult.Minutes}, Seconds: {testResult.Seconds}, Milliseconds: {testResult.Milliseconds}");

            var back2Year = testResult.Ticks * 12L;

            Assert.AreEqual(Constants.TropicalYear.Ticks, back2Year);
        }
Example #3
0
        public void TestToInterval()
        {
            var testInput  = PecuniamExtensions.GetTropicalMonth();
            var testResult = PecuniamExtensions.ToInterval(testInput);

            Console.WriteLine(testResult.ToString());
            Assert.AreEqual(Interval.Monthly, testResult);

            testInput  = Constants.TropicalYear;
            testResult = PecuniamExtensions.ToInterval(testInput);
            Console.WriteLine(testResult.ToString());
            Assert.AreEqual(Interval.Annually, testResult);
        }
Example #4
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());
        }
Example #5
0
        public override IDictionary <string, object> ToData(KindsOfTextCase txtCase)
        {
            Func <string, string> textFormat = (x) => VocaBase.TransformText(x?.Replace(",", "").Replace(" ", ""), txtCase);
            var itemData = new Dictionary <string, object>();

            foreach (var p in CurrentItems)
            {
                var v = p.AveragePerDueFrequency(PecuniamExtensions.GetTropicalMonth());
                if (v == Pecuniam.Zero)
                {
                    continue;
                }
                var expenseName = Division.ToString() + p.DueFrequency.ToInterval();
                expenseName += p.Name;
                if (itemData.ContainsKey(textFormat(expenseName)))
                {
                    continue;
                }
                itemData.Add(textFormat(expenseName), v.GetRounded());
            }

            return(itemData);
        }