コード例 #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);
        }
コード例 #2
0
ファイル: Monthly.cs プロジェクト: weatherdata/opencbs
        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);
        }
コード例 #3
0
        private List <SavingEvent> PostingEndOfMonth(DateTime pDate, User pUser)
        {
            DateTime           lastPostingDate = GetLastPostingDate();
            List <SavingEvent> events          = new List <SavingEvent>();

            while (DateCalculationStrategy.DateCalculationMonthly(lastPostingDate, pDate))
            {
                lastPostingDate = lastPostingDate.AddMonths(1);

                events.AddRange(AddSavingEvent(CalculateInterest(new DateTime(lastPostingDate.Year, lastPostingDate.Month, 01,
                                                                              DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), pUser)));
                events.AddRange(AddSavingEvent(PostingInterests(new DateTime(lastPostingDate.Year, lastPostingDate.Month, 01,
                                                                             DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), pUser)));
            }

            if ((Product).InterestBase != OSavingInterestBase.Monthly)
            {
                events.AddRange(AddSavingEvent(CalculateInterest(pDate, pUser)));
            }

            return(events);
        }
コード例 #4
0
        public List <SavingInterestsPostingEvent> PostingInterests(DateTime postingDate)
        {
            List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>();

            DateTime lastPostingDate = _saving.GetLastPostingDate();
            DateTime currentPostingDate;

            while (DateCalculationStrategy.DateCalculationMonthly(lastPostingDate, postingDate))
            {
                currentPostingDate = new DateTime(lastPostingDate.AddMonths(1).Year, lastPostingDate.AddMonths(1).Month, 01,
                                                  DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

                OCurrency interestsToPost =
                    _saving.Events.Where(
                        savEvent =>
                        savEvent is SavingInterestsAccrualEvent && savEvent.Date <= currentPostingDate &&
                        savEvent.Date >= lastPostingDate).Aggregate <SavingEvent, OCurrency>(0,
                                                                                             (current, savEvent) =>
                                                                                             current +
                                                                                             savEvent.Amount.Value);

                list.Add(new SavingInterestsPostingEvent
                {
                    Date        = currentPostingDate,
                    Amount      = interestsToPost,
                    Description = string.Format("Posting interests for period : {0:d} to {1:d} : {2}", lastPostingDate, currentPostingDate, _saving.Code),
                    User        = _user,
                    Cancelable  = true,
                    ProductType = _saving.Product.GetType(),
                    Branch      = _saving.Branch,
                    Currency    = _saving.Product.Currency,
                    ContracId   = _saving.Id
                });

                lastPostingDate = lastPostingDate.AddMonths(1);
            }

            return(list);
        }