Example #1
0
        private void FillProjectedYearsList(IProjectionViewModel model)
        {
            var request = new GenericOperationNumberRequest()
            {
                OperationNumber = model.OperationNumber
            };
            var operationId = _disbursementService.GetOperationId(request);
            ApprovalMilestoneDateResponse appDateResponse = new ApprovalMilestoneDateResponse();

            if (operationId.IsValid)
            {
                appDateResponse = _disbursementService
                                  .GetApprovalMilestone(Convert.ToInt32(operationId.Value));
            }

            model.ProjectedYearsList = new List <int>();
            if (appDateResponse != null &&
                appDateResponse.ApprovalMilestoneDate.HasValue)
            {
                int approbalYear = appDateResponse.ApprovalMilestoneDate.Value.Year;
                for (int i = DateTime.Now.Year; i >= approbalYear; i--)
                {
                    model.ProjectedYearsList.Add(i);
                }
            }
            else
            {
                model.ProjectedYearsList.Add(DateTime.Now.Year);
            }
        }
Example #2
0
        public virtual ActionResult RetrieveFinancialData(
            string operationNumber,
            ConvertCurrencyViewModel projectionsModel)
        {
            if (projectionsModel == null)
            {
                return(new HttpStatusCodeResult(
                           HttpStatusCode.BadRequest,
                           DisbursementValues.INVALID_REQUEST));
            }

            var financialResponse = _disbursementService
                                    .GetFinancialPlan(new FinancialPlanProjectionRequest()
            {
                ApprovedCurrency = projectionsModel.CurrCode,
                ContractNumber   = projectionsModel.LoanNumber,
                IsInExecution    = projectionsModel.IsExecution,
                OperationNumber  = projectionsModel.OperationNumber,
                ProjectionsModel = projectionsModel
            });

            string htmlStringView = string.Empty;

            if (financialResponse.IsValid)
            {
                projectionsModel.ProjectedYears = financialResponse.Projections;
                var outOfRangeProjections = projectionsModel.CurrentProjectionRequest
                                            .Where(x => x.IsOutofRange);
                foreach (var item in outOfRangeProjections)
                {
                    var months = projectionsModel.ProjectedYears
                                 .FirstOrDefault(y => y.Year == item.Year);
                    if (months == null)
                    {
                        continue;
                    }

                    var month = months.ProjectedMonths.FirstOrDefault(m => m.Month == item.Month);
                    if (month != null)
                    {
                        month.ProjectedAmount = decimal.MinValue;
                    }
                }

                IProjectionViewModel resultModel = MappProjectionViewModelModel(projectionsModel);
                htmlStringView = Helpers.ViewHelper
                                 .ViewStringify("~/Areas/Disbursement/Views/Shared/_GridProjectForm.cshtml",
                                                resultModel,
                                                this);
            }

            return(Json(
                       new
            {
                FinancialData = htmlStringView,
                MessageType = financialResponse.MessageType,
                IsValid = financialResponse.IsValid
            },
                       JsonRequestBehavior.AllowGet));
        }