private SavingInterestsAccrualEvent GetInterests(DateTime pLastClosureDate, DateTime pClosureDate) { double interestRate = _saving.InterestRate; OCurrency minimalAmount = _saving.GetBalanceMin(pLastClosureDate); DateTime currentDate = pLastClosureDate.AddDays(1); while (currentDate < pClosureDate) { OCurrency amountAtCurrentDate = _saving.GetBalanceMin(currentDate); if (minimalAmount > amountAtCurrentDate) { minimalAmount = amountAtCurrentDate; } currentDate = currentDate.AddDays(1); } OCurrency interests = interestRate * minimalAmount; return(new SavingInterestsAccrualEvent { Amount = interests, Date = pClosureDate, Fee = 0, User = _user, Cancelable = true, ProductType = _saving.Product.GetType(), Description = _saving.Code, Branch = _saving.Branch, Currency = _saving.Product.Currency, ContracId = _saving.Id }); }