Example #1
0
        public List <SavingInterestsAccrualEvent> CalculateInterest(DateTime pClosureDate)
        {
            List <SavingInterestsAccrualEvent> listInterestsAccrualEvent = new List <SavingInterestsAccrualEvent>();

            DateTime lastClosureDate = _saving.GetLastAccrualDate();

            while (DateCalculationStrategy.DateCalculationMonthly(lastClosureDate, pClosureDate))
            {
                DateTime accrualDate = new DateTime(lastClosureDate.AddMonths(1).Year, lastClosureDate.AddMonths(1).Month, 01,
                                                    DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

                int count = _saving.Events.FindAll(se =>
                                                   (se.Code == OSavingEvents.Withdraw ||
                                                    se.Code == OSavingEvents.DebitTransfer /* ||
                                                                                            * se.Code == OSavingEvents.SpecialOperationDebit*/) &&
                                                   (se.Date > lastClosureDate && se.Date < accrualDate)).Count;

                if (count < 3)
                {
                    if (!_checkUsage)
                    {
                        listInterestsAccrualEvent.Add(GetInterests(lastClosureDate, accrualDate));
                    }
                    else
                    {
                        //slycode
                        SavingInitialDepositEvent firstDeposit = null;

                        foreach (var evnt in _saving.Events)
                        {
                            if (evnt is SavingInitialDepositEvent)
                            {
                                firstDeposit = (SavingInitialDepositEvent)evnt;

                                if (DateCalculationStrategy.DateCalculationMonthly(firstDeposit.Date, DateTime.Now, -3))
                                {
                                    listInterestsAccrualEvent.Add(GetInterests(lastClosureDate, accrualDate));
                                }

                                break;
                            }
                        }
                    }
                }
                lastClosureDate = lastClosureDate.AddMonths(1);
            }

            return(listInterestsAccrualEvent);
        }
Example #2
0
        public List <SavingInterestsAccrualEvent> CalculateInterest(DateTime pClosureDate)
        {
            List <SavingInterestsAccrualEvent> listInterestsAccrualEvent = new List <SavingInterestsAccrualEvent>();

            DateTime lastClosureDate = _saving.GetLastAccrualDate();

            while (DateCalculationStrategy.DateCalculationMonthly(lastClosureDate, pClosureDate))
            {
                DateTime accrualDate = new DateTime(lastClosureDate.AddMonths(1).Year, lastClosureDate.AddMonths(1).Month, 01,
                                                    DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                listInterestsAccrualEvent.Add(GetInterests(lastClosureDate, accrualDate));

                lastClosureDate = lastClosureDate.AddMonths(1);
            }

            return(listInterestsAccrualEvent);
        }
Example #3
0
        public List <SavingInterestsAccrualEvent> CalculateInterest(DateTime pClosureDate)
        {
            List <SavingInterestsAccrualEvent> listInterestsAccrualEvent = new List <SavingInterestsAccrualEvent>();

            DateTime lastClosureDate = _saving.GetLastAccrualDate();

            while (DateCalculationStrategy.DateCalculationWeekly(lastClosureDate, pClosureDate, _weekEndDay2))
            {
                DateTime cDate = new DateTime(lastClosureDate.Year, lastClosureDate.Month, lastClosureDate.Day,
                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                DateTime accrualDate = DateCalculationStrategy.GetNextWeekly(cDate, _weekEndDay2);
                listInterestsAccrualEvent.Add(GetInterests(lastClosureDate, accrualDate));
                lastClosureDate = accrualDate;
            }

            return(listInterestsAccrualEvent);
        }