Example #1
0
        /// <summary>
        /// Tests if the <see cref="childDob"/> is a real possiablity 
        /// given the presence of siblings and thier date-of-birth.
        /// </summary>
        /// <param name="childDob"></param>
        /// <returns>
        /// True when the <see cref="childDob"/> is possiable given 
        /// the this instance's age at this time and the date-of-birth
        /// of siblings.
        /// </returns>
        /// <remarks>
        /// Is coded with implicit presumption of <see cref="IPerson.MyGender"/> 
        /// being <see cref="Gender.Female"/>, but does not test as such.
        /// </remarks>
        protected internal bool IsValidDobOfChild(DateTime childDob)
        {
            ThrowOnBirthDateNull(this);

            var maxDate = BirthCert.DateOfBirth.AddYears(55);
            var minDate = BirthCert.DateOfBirth.AddYears(13);

            if (childDob.ComparedTo(minDate) == ChronoCompare.Before ||
                childDob.ComparedTo(maxDate) == ChronoCompare.After)
            {
                throw new RahRowRagee(
                    $"The Child Date-of-Birth, {childDob}, does not fall " +
                    $"within a rational range given the mother's Date-of-Birth of {BirthCert.DateOfBirth}");
            }
            var clildDobTuple = new Tuple<DateTime, DateTime>(childDob.AddDays(-1 * PREG_DAYS), childDob);

            var bdayTuples =
                _children.Where(x => x.Est.BirthCert != null)
                    .Select(
                        x =>
                            new Tuple<DateTime, DateTime>(x.Est.BirthCert.DateOfBirth.AddDays(-1*(PREG_DAYS + MS_DAYS)),
                                x.Est.BirthCert.DateOfBirth.AddDays(MS_DAYS))).ToList();
            foreach (var s in bdayTuples)
            {
                var xDoC = s.Item1;
                var xDoB = s.Item2;

                var yDoC = clildDobTuple.Item1;
                var yDoB = clildDobTuple.Item2;

                //neither of the (y) values can appear between the x values
                if (yDoC.IsBetween(xDoC, xDoB) || yDoB.IsBetween(xDoC, xDoB))
                    return false;
            }

            return true;
        }
Example #2
0
        public static int CountOfWholeCalendarMonthsBetween(DateTime d1, DateTime d2, int dayOfMonthRentDue = 1)
        {
            if (d1.Date.ComparedTo(d2.Date) == ChronoCompare.SameTime)
                return 0;

            DateTime olderDt;
            DateTime newerDt;
            if (d1.ComparedTo(d2) == ChronoCompare.Before)
            {
                olderDt = d1;
                newerDt = d2;
            }
            else
            {
                olderDt = d2;
                newerDt = d1;
            }
            //back newer date to first day of its month
            newerDt = new DateTime(newerDt.Year, newerDt.Month, dayOfMonthRentDue);

            var countOfMonths = 0;
            while (newerDt.ComparedTo(olderDt) == ChronoCompare.After)
            {
                newerDt = newerDt.Month == 1
                    ? new DateTime(newerDt.Year - 1, 12, dayOfMonthRentDue)
                    : new DateTime(newerDt.Year, newerDt.Month - 1, dayOfMonthRentDue);
                if (newerDt.ComparedTo(olderDt) == ChronoCompare.After
                    || newerDt.ComparedTo(olderDt) == ChronoCompare.SameTime)
                    countOfMonths += 1;
            }

            return countOfMonths;
        }
Example #3
0
 public override Pecuniam GetValueAt(DateTime dt)
 {
     //when date is prior to signing
     return dt.ComparedTo(TradeLine.OpennedDate) == ChronoCompare.Before
         ? Pecuniam.Zero
         : TradeLine.Balance.GetCurrent(dt, 0);
 }
Example #4
0
        protected internal Pecuniam GetExpectedTotalRent(DateTime dt)
        {
            //when date is prior to signing
            if (dt.ComparedTo(TradeLine.OpennedDate) == ChronoCompare.Before)
                return Pecuniam.Zero;

            //when between signing and first months rent
            if(dt.ComparedTo(_dtOfFirstFullRentDue) == ChronoCompare.Before)
                return _proRatedAmt;

            var numOfRentPmts = CountOfWholeCalendarMonthsBetween(TradeLine.OpennedDate, dt, _dayOfMonthRentDue);

            //don't let calc exceed contract limit
            numOfRentPmts = numOfRentPmts > LeaseTermInMonths ? LeaseTermInMonths : numOfRentPmts;

            return new Pecuniam(MonthlyPmt.Amount * (numOfRentPmts+1)) + _proRatedAmt;
        }
Example #5
0
 public override Pecuniam GetMinPayment(DateTime dt)
 {
     var e = -1*GetExpectedTotalRent(dt).Amount;
     dt = dt.ComparedTo(TradeLine.OpennedDate) == ChronoCompare.SameTime
         ? dt.AddDays(1)
         : dt;
     var pd = TradeLine.Balance.GetDebitSum(
         new Tuple<DateTime, DateTime>(TradeLine.OpennedDate, dt));
     return new Pecuniam(e - pd.Amount);
 }