/// <summary> /// Only makes sense in the context of employment /// </summary> /// <param name="employment"></param> public AmericanDeductions(AmericanEmployment employment) { _employment = employment ?? throw new ArgumentNullException(nameof(employment)); if (_employment.Inception == DateTime.MinValue) { _employment.Inception = GetYearNeg(-1); } }
/// <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); }
/// <summary> /// Gets a list of time ranges over for all the years of this income's start date (and then some). /// Each block is assumed as a span of employment at one single employer. /// </summary> /// <param name="options"></param> /// <param name="personality"></param> /// <returns></returns> protected internal virtual List <Tuple <DateTime, DateTime?> > GetEmploymentRanges(AmericanDomusOpesOptions options, IPersonality personality = null) { options = options ?? AmericanDomusOpesOptions.RandomOpesOptions(); var emply = new List <Tuple <DateTime, DateTime?> >(); //make it appear as if the start date is randomly before options start date var sdt = options.Inception; sdt = sdt == DateTime.MinValue ? Etx.RandomDate(-3, DateTime.Today, true).Date : sdt.AddDays(Etx.RandomInteger(0, 360) * -1); //TODO - tie this together with personality var tenure = AmericanEmployment.RandomEmploymentTenure(options); var lpDt = sdt; while (lpDt < DateTime.Today) { var randDays = Etx.RandomInteger(0, 21); lpDt = lpDt.AddMonths(3).AddDays(randDays); if (lpDt <= sdt.Add(tenure)) { continue; } emply.Add(new Tuple <DateTime, DateTime?>(sdt, lpDt < DateTime.Today ? new DateTime?(lpDt) : null)); sdt = lpDt; tenure = AmericanEmployment.RandomEmploymentTenure(options); } if (!emply.Any()) { emply.Add(new Tuple <DateTime, DateTime?>(Etx.RandomDate(-4, DateTime.Today, true).Date, null)); } return(emply); }