/// <summary> /// To get the Projected Cash From Deposit Log when number of last working days are given. /// </summary> /// <param name="clientCode"></param> /// <param name="numberOfLastWorkingDays"></param> /// <param name="month"></param> /// <param name="year"></param> /// <param name="savedLastNumberOfBusinessDays"></param> /// <returns></returns> public DepositLogProjectionViewModel GetProjectedCashFromSimpleBusinessDays(string clientCode, int numberOfLastWorkingDays, int month, int year, int savedLastNumberOfBusinessDays) { try { DepositLogProjectionViewModel depositLogSimpleBusinessDaysViewModel = null; DepositLogSimpleBusinessDays depositLogSimpleBusinessDays = null; DateTime endDate = DateTime.Today; decimal? depositLogAmountForMonth = 0; long? payments = null; if (new DateTime(year, month, 1) < new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1)) { endDate = new DateTime(year, month, DateTime.DaysInMonth(year, month)); } ClientDepositLogInfo clientDepositLogInfo = new ClientDepositLogInfo(); clientDepositLogInfo = _depositLogResposiotory.GetDepositLogStartDateAndNumberOfDepositDates(clientCode, numberOfLastWorkingDays, endDate); if (clientDepositLogInfo.NumberOfDepositDates > 0) { depositLogSimpleBusinessDays = _depositLogResposiotory.GetProjectedCashFromSimpleBusinessDays(clientCode, clientDepositLogInfo.NumberOfDepositDates, month, year, clientDepositLogInfo.DepositStartDate, endDate); if (depositLogSimpleBusinessDays != null) { depositLogSimpleBusinessDaysViewModel = new DepositLogProjectionViewModel(); depositLogSimpleBusinessDaysViewModel.Payments = depositLogSimpleBusinessDays.Payments; depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekEnds = depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekEnds != null ? (decimal)depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekEnds : (decimal)0.0; depositLogSimpleBusinessDaysViewModel.DepositLogAmount = depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekDays != null ? (decimal)depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekDays : (decimal)0.0; depositLogSimpleBusinessDaysViewModel.DepositLogAmount = ((depositLogSimpleBusinessDaysViewModel.DepositLogAmount / clientDepositLogInfo.NumberOfDepositDates) * depositLogSimpleBusinessDays.BusinessDays) + depositLogSimpleBusinessDays.DepositLogPaymentsOnWeekEnds; depositLogSimpleBusinessDaysViewModel.NumberOfLastWorkingDaysOrWeeks = clientDepositLogInfo.NumberOfDepositDates; return(depositLogSimpleBusinessDaysViewModel); } else { return(depositLogSimpleBusinessDaysViewModel); } } else { payments = _depositLogResposiotory.GetClientPaymentForMonth(clientCode, month, year); depositLogSimpleBusinessDaysViewModel = GetDepositLogProjectionViewModel(depositLogSimpleBusinessDaysViewModel, payments, depositLogAmountForMonth, clientDepositLogInfo.NumberOfDepositDates); return(depositLogSimpleBusinessDaysViewModel); } } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }
/// <summary> /// To get the projected cash of the last working days and the target payments for the given month. /// </summary> /// <param name="clientCode"></param> /// <param name="month"></param> /// <param name="year"></param> /// <param name="numberOfLastWorkingDays"></param> /// <returns></returns> public DepositLogProjectedCashAmountWithPayment GetProjectedCashOfLastWorkingDays(string clientCode, int month, int year, int numberOfLastWorkingDays) { try { DepositLogProjectedCashAmountWithPayment depositLogProjectedCashAmountWithPayment = null; List <DepositLogProjectedCashViewModel> projectedCashViewModel = null; List <DepositLogProjectedCashViewModel> previousDateViewModel = null; List <DepositLogProjectedCash> depositLogProjectedCashList = null; DateTime endDate = DateTime.Today; ClientDepositLogInfo clientDepositLogInfo = new ClientDepositLogInfo(); clientDepositLogInfo = _depositLogResposiotory.GetDepositLogStartDateAndNumberOfDepositDates(clientCode, numberOfLastWorkingDays, DateTime.Today); long?payments = _depositLogResposiotory.GetClientPaymentForMonth(clientCode, month, year); if (clientDepositLogInfo.NumberOfDepositDates > 0) { depositLogProjectedCashList = _depositLogResposiotory.GetProjectedCashOfLastWorkingDays(clientCode, month, year, numberOfLastWorkingDays, clientDepositLogInfo.DepositStartDate, endDate); if (depositLogProjectedCashList != null) { depositLogProjectedCashAmountWithPayment = new DepositLogProjectedCashAmountWithPayment(); projectedCashViewModel = new List <DepositLogProjectedCashViewModel>(); previousDateViewModel = new List <DepositLogProjectedCashViewModel>(); foreach (DepositLogProjectedCash depositLogProjectedCash in depositLogProjectedCashList) { DepositLogProjectedCashViewModel projectedCash = new DepositLogProjectedCashViewModel(); DepositLogProjectedCashViewModel previousDate = new DepositLogProjectedCashViewModel(); projectedCash.name = depositLogProjectedCash.LastWorkingDayNumber.ToString(); projectedCash.value = depositLogProjectedCash.ProjectedCash; previousDate.name = depositLogProjectedCash.LastWorkingDayNumber.ToString(); previousDate.value = payments != null ? (decimal)payments : (decimal)0.0; projectedCashViewModel.Add(projectedCash); previousDateViewModel.Add(previousDate); } depositLogProjectedCashAmountWithPayment.DepositLogProjectedCashViewModelList = projectedCashViewModel; depositLogProjectedCashAmountWithPayment.Payments = previousDateViewModel; } } return(depositLogProjectedCashAmountWithPayment); } catch (Exception ex) { _logger.Log(ex, LogLevel.Error, ex.Message); return(null); } }