示例#1
0
        public void BuildWorkingSet()
        {
            if (Planned.Count == Actual.Count)
            {
                Schedule[] aryPlanned = Planned.ToArray();
                Schedule[] aryActual  = Actual.ToArray();

                for (int i = 0; i < Planned.Count; i++)
                {
                    Schedule oCurPlanned = aryPlanned[i];
                    Schedule oCurActual  = aryActual[i];

                    if (oCurActual.Date != oCurPlanned.Date)
                    {
                        ScheduleState = ScheduleState.SameCountDiffDates;
                    }

                    WorkingSet.Add(new Schedule(this)
                    {
                        ID        = oCurActual.ID,
                        Date      = oCurPlanned.Date,
                        Principal = oCurPlanned.Principal
                    });
                }                 // for

                if (ScheduleState == ScheduleState.Unknown)
                {
                    ScheduleState = ScheduleState.Match;
                }
            }
            else
            {
                ScheduleState = ScheduleState.DiffCount;
                BuildBadWorkingSet();
            }     // if
        }         // BuildWorkingSet
示例#2
0
        }         // FillPlanned

        private void BuildBadWorkingSet()
        {
            if (Actual.Count == 0)
            {
                return;
            }

            if (Planned.Count == 0)
            {
                decimal nOther = Math.Floor(DeclaredLoanAmount / Actual.Count);
                decimal nFirst = DeclaredLoanAmount - nOther * (Actual.Count - 1);

                bool bFirst = true;

                foreach (Schedule sh in Actual)
                {
                    WorkingSet.Add(new Schedule(sh)
                    {
                        Principal = bFirst ? nFirst : nOther
                    });
                    bFirst = false;
                }                 // for each

                return;
            }             // if no planned

            if (TotalPrincipalPaid == DeclaredLoanAmount)
            {
                if (LoanType == LoanType.Standard)
                {
                    decimal nOther = Math.Floor(DeclaredLoanAmount / Actual.Count);
                    decimal nFirst = DeclaredLoanAmount - nOther * (Actual.Count - 1);

                    bool bFirst = true;

                    foreach (Schedule sh in Actual)
                    {
                        WorkingSet.Add(new Schedule(sh)
                        {
                            Principal = bFirst ? nFirst : nOther
                        });
                        bFirst = false;
                    }                     // for each

                    return;
                }                 // if standard loan

                if (LoanType == LoanType.Halfway)
                {
                    int nFirstHalf  = Actual.Count / 2;
                    int nSecondHalf = Actual.Count - nFirstHalf;

                    for (int i = 0; i < nFirstHalf; i++)
                    {
                        WorkingSet.Add(new Schedule(Actual[i])
                        {
                            Principal = 0
                        });
                    }

                    decimal nOther = Math.Floor(DeclaredLoanAmount / nSecondHalf);
                    decimal nFirst = DeclaredLoanAmount - nOther * (nSecondHalf - 1);

                    bool bFirst = true;

                    for (int i = 0; i < nSecondHalf; i++)
                    {
                        WorkingSet.Add(new Schedule(Actual[nFirstHalf + i])
                        {
                            Principal = bFirst ? nFirst : nOther
                        });
                        bFirst = false;
                    }             // for each
                }                 // if halfway loan

                return;
            } // if paid loan
        }     // BuildBadWorkingSet