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); }
private List <SavingEvent> PostingEndOfWeek(DateTime pDate, User pUser) { DateTime lastPostingDate = GetLastPostingDate(); List <SavingEvent> events = new List <SavingEvent>(); while (DateCalculationStrategy.DateCalculationWeekly(lastPostingDate, pDate, ApplicationSettings.WeekEndDay2)) { lastPostingDate = DateCalculationStrategy.GetNextWeekly(lastPostingDate, ApplicationSettings.WeekEndDay2); events.AddRange(AddSavingEvent(CalculateInterest(new DateTime(lastPostingDate.Year, lastPostingDate.Month, lastPostingDate.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), pUser))); events.AddRange(AddSavingEvent(PostingInterests(new DateTime(lastPostingDate.Year, lastPostingDate.Month, lastPostingDate.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second), pUser))); } events.AddRange(AddSavingEvent(CalculateInterest(pDate, pUser))); return(events); }
public List <SavingInterestsPostingEvent> PostingInterests(DateTime postingDate) { List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); DateTime lastPostingDate = _saving.GetLastPostingDate(); DateTime currentPostingDate; while (DateCalculationStrategy.DateCalculationWeekly(lastPostingDate, postingDate, _weekEndDay2)) { currentPostingDate = DateCalculationStrategy.GetNextWeekly(lastPostingDate, _weekEndDay2); currentPostingDate = new DateTime(currentPostingDate.Year, currentPostingDate.Month, currentPostingDate.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); OCurrency interestsToPost = 0; foreach (SavingEvent savEvent in _saving.Events) { if (savEvent is SavingInterestsAccrualEvent && savEvent.Date <= currentPostingDate && savEvent.Date > lastPostingDate) { interestsToPost += 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 = currentPostingDate; } return(list); }