Exemple #1
0
        public virtual ActionResult UpdateReferenceInfo(
            string year)
        {
            var model = new ProjectedLoanModel();

            return(View(model));
        }
Exemple #2
0
        public virtual ActionResult ReferenceInformation(ConvertCurrencyViewModel model)
        {
            if (model == null)
            {
                model = new ConvertCurrencyViewModel();
            }

            var modelExchanged = new ProjectedLoanModel();

            modelExchanged.ProjectedYears  = model.ProjectedYears;
            modelExchanged.ProjectedMonths = model.ProjectedMonths;
            modelExchanged.OperationNumber = model.OperationNumber;

            var referenceInformationRequest = new ReferenceInformationRequest()
            {
                OperationNumber        = model.OperationNumber,
                Model                  = modelExchanged,
                SelectedYear           = model.SelectedYear,
                LoanNumber             = model.LoanNumber,
                IsExecution            = model.IsExecution,
                ExchangeRates          = model.ExchangeRates,
                CurrentProjectionMonth = model.CurrentProjectionMonth
            };

            var referenceInformationResponse = _disbursementService
                                               .GetReferenceInformationByYear(referenceInformationRequest);

            modelExchanged.Projects = referenceInformationResponse.ReferenceInfo;

            FillProjectedYearsList(modelExchanged);
            return(PartialView("_GridReferenceInformation", (IProjectionViewModel)modelExchanged));
        }
        private void FillProjectedYearsList(ProjectedLoanModel 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);
            }
        }
        public virtual ActionResult GetGraphData(Models.GraphModel graphData)
        {
            var ajaxResult = new Dictionary <string, string>();

            try
            {
                DateTime currentExpirationDate = graphData.CurrentDisbursementExpirationDate;
                string   pcMail = IDBContext.Current.UserName;
                var      result = new Dictionary <string, List <decimal?[]> >();

                var projectionMatrix = new ProjectedLoanModel()
                {
                    ProjectedMonths =
                        new List <MW.Domain.Models.Disbursement.ProjectedMonthYearModel>(),
                    AllLoans = new OperationLevelProjectionsViewModel()
                    {
                        ProjectedMonths =
                            new List <MW.Domain.Models.Disbursement.ProjectedMonthYearModel>()
                    }
                };

                if (graphData.ProjectedMonths != null)
                {
                    projectionMatrix.ProjectedMonths = graphData.ProjectedMonths.ConvertToModel();
                }

                if (graphData.AllLoansProjectedMonths != null)
                {
                    projectionMatrix.AllLoans.ProjectedMonths =
                        graphData.AllLoansProjectedMonths.ConvertToModel();
                }

                _disbursementService.CalculateGraphPoints(
                    result,
                    projectionMatrix,
                    graphData.OperationNumber,
                    pcMail,
                    false,
                    currentExpirationDate,
                    projectionMatrix.AllLoans);

                ajaxResult[DisbursementValues.ACTION] =
                    DisbursementValues.CALL_FUNCTION_PARAMETERED;
                ajaxResult[DisbursementValues.CALL_FUNCTION_FN] =
                    DisbursementValues.DISBURSEMENT_SHOW_GRAPH;
                ajaxResult[DisbursementValues.CALL_FUNCTION_PARAMETERS] =
                    string.Format("[{0}]", new JavaScriptSerializer().Serialize(result));
            }
            catch (Exception e)
            {
                ajaxResult[DisbursementValues.ACTION]     = DisbursementValues.SHOW_ERROR;
                ajaxResult[DisbursementValues.ERROR_TEXT] = e.Message;
            }

            return(Content(new JavaScriptSerializer().Serialize(ajaxResult)));
        }
        private ConvertCurrencyViewModel CreateNewConvertCurrencyViewModel(
            ProjectedLoanModel modelExchanged,
            ConvertCurrencyViewModel originalModel)
        {
            if (originalModel != null)
            {
                ConvertCurrencyViewModel model = new ConvertCurrencyViewModel()
                {
                    HasOperationLevelProjection = originalModel.HasOperationLevelProjection,
                    Balance                           = originalModel.Balance,
                    RemainingBalance                  = originalModel.RemainingBalance,
                    IsExecution                       = originalModel.IsExecution,
                    EditMode                          = originalModel.EditMode,
                    Cancellations                     = originalModel.Cancellations,
                    CurrCode                          = originalModel.CurrCode,
                    PartialEligibilityDate            = originalModel.PartialEligibilityDate,
                    TotalEligibilityDate              = originalModel.TotalEligibilityDate,
                    OriginalExpirationDate            = originalModel.OriginalExpirationDate,
                    CurrentDisbursementExpirationDate =
                        originalModel.CurrentDisbursementExpirationDate,
                    CummulativeExtensions = originalModel.CummulativeExtensions,
                    OperationNumber       = originalModel.OperationNumber,
                    LoanNumber            = originalModel.LoanNumber,
                    ProjectedYears        = originalModel.ProjectedYears,
                    ProjectedMonths       = originalModel.ProjectedMonths,
                    SelectedYear          = originalModel.SelectedYear,
                    ExchangeRate          = originalModel.ExchangeRate,

                    ActualAccumDisbCurrentAccumProj =
                        modelExchanged.Projects[DisbursementValues.LITERAL_ACTUAL],
                    AccumProjAgreedAccumProjPerc =
                        modelExchanged.Projects[DisbursementValues.LITERAL_ACTUAL_AGREED],
                    AccumProjAgreedAccumProj =
                        modelExchanged.Projects[DisbursementValues.LITERAL_ACTUAL_AGREED_ACCUM],
                    AgreedAccumProj =
                        modelExchanged.Projects[DisbursementValues.LITERAL_AGREED_ACCUM],
                    AgreedProjection =
                        modelExchanged.Projects[DisbursementValues.LITERAL_AGREED_PROJECTION],
                };

                return(model);
            }
            else
            {
                return(new ConvertCurrencyViewModel());
            }
        }
        public virtual ActionResult UpdateReferenceInfo(int year,
                                                        string operationNumber,
                                                        string loanNumber,
                                                        string fundCode,
                                                        string loanTcdNum,
                                                        string loanProjectNumber,
                                                        string loanCurrencyCode)
        {
            int currentYear = DateTime.Now.Year;

            if (year > 0)
            {
                currentYear = Convert.ToInt16(year);
            }

            string pcMail = IDBContext.Current.UserName;
            var    model  = new ProjectedLoanModel();

            model = _disbursementService.GetProjectionMatrixWithCache(
                null,
                operationNumber,
                pcMail,
                loanNumber,
                fundCode,
                loanTcdNum,
                loanProjectNumber,
                loanCurrencyCode);

            if (model.CurrentProjectionMonth <= DisbursementValues.ZERO_NUMB)
            {
                model.CurrentProjectionMonth =
                    model.ProjectedMonths != null && model.ProjectedMonths.Any()
                    ? model.ProjectedMonths.Where(o => o.Year == currentYear).Min(z => z.Month)
                    : DisbursementValues.ZERO_NUMB;
            }

            model.OperationNumber   = operationNumber;
            model.LoanTCDNumber     = loanTcdNum;
            model.FundCode          = fundCode;
            model.LoanProjectNumber = loanProjectNumber;

            model.Projects = _disbursementService
                             .GetReferenceInformation(model.OperationNumber, model, model.LoanNumber);
            var loanNumberToArray = new string[] { model.LoanNumber };
            var oldProjection     = _disbursementService.GetMonthlyProyections(
                operationNumber,
                model.CurrentProjectionMonth,
                false,
                model.IsExecution,
                loanNumberToArray);

            model.LoanNumber        = loanNumber;
            model.FundCode          = fundCode;
            model.LoanTCDNumber     = loanTcdNum;
            model.LoanProjectNumber = loanProjectNumber;
            model.LoanCurrencyCode  = loanCurrencyCode;
            model.Download          = true;
            model.OldProjection     = oldProjection.Any()
                ? oldProjection : new List <ActualsFromEdwViewModel>();
            model.Total = _disbursementService.TotalOfProjections(
                oldProjection,
                model.ProjectedYears,
                model.Balance,
                model.CurrentProjectionMonth);
            model.ExchangeRate = decimal.One;

            FillProjectedYearsList(model);

            return(PartialView("_GridReferenceInformation", model));
        }
        public virtual ActionResult Edit(
            string operationNumber,
            string loanNumber,
            string fundCode,
            string loanTcdNum,
            string loanProjectNumber,
            string loanCurrencyCode)
        {
            var model = new ProjectedLoanModel();

            try
            {
                var projectableOperationResponse = _eligibilityService
                                                   .CheckIfContractIsProjectable(new DisbursementEligibilityRequest()
                {
                    OperationNumber = operationNumber,
                    ContractNumber  = loanNumber
                });

                if (!projectableOperationResponse.IsValid)
                {
                    return(View("NonProjectableScreen", new NoProjectableViewModel
                    {
                        OperationNumber = operationNumber,
                        ContractNumber = loanNumber,
                        IsAllNotProjectable = false
                    }));
                }

                string pcMail      = IDBContext.Current.UserName;
                int    currentYear = DateTime.Now.Year;
                model = _disbursementService.GetProjectionMatrixWithCache(
                    null,
                    operationNumber,
                    pcMail,
                    loanNumber,
                    fundCode,
                    loanTcdNum,
                    loanProjectNumber,
                    loanCurrencyCode);

                if (model.CurrentProjectionMonth <= DisbursementValues.ZERO_NUMB)
                {
                    model.CurrentProjectionMonth =
                        model.ProjectedMonths != null && model.ProjectedMonths.Any()
                        ? model.ProjectedMonths.Where(o => o.Year == currentYear).Min(z => z.Month)
                        : DisbursementValues.ZERO_NUMB;
                }

                model.OperationNumber   = operationNumber;
                model.LoanTCDNumber     = loanTcdNum;
                model.FundCode          = fundCode;
                model.LoanProjectNumber = loanProjectNumber;
                model.LoanNumber        = loanNumber;
                model.LoanCurrencyCode  = loanCurrencyCode;
                model.Download          = true;
                var loanNumberToArray = new string[] { model.LoanNumber };
                var oldProjection     = _disbursementService.GetMonthlyProyections(
                    operationNumber,
                    model.CurrentProjectionMonth,
                    false,
                    model.IsExecution,
                    loanNumberToArray);
                model.OldProjection = oldProjection.Any()
                    ? oldProjection : new List <ActualsFromEdwViewModel>();
                var currMonthOldProjection = model.OldProjection
                                             .HasAny(x => x.Month == DateTime.Now.Month && x.Year == DateTime.Now.Year) ?
                                             model.OldProjection
                                             .Where(x => x.Month == DateTime.Now.Month && x.Year == DateTime.Now.Year)
                                             .FirstOrDefault().Value : decimal.Zero;
                model.Projects = _disbursementService
                                 .GetReferenceInformation(model.OperationNumber,
                                                          model,
                                                          model.LoanNumber,
                                                          currentMonthOldProjection: currMonthOldProjection);
                model.Total = _disbursementService.TotalOfProjections(
                    oldProjection,
                    model.ProjectedYears,
                    model.Balance,
                    model.CurrentProjectionMonth);
                FillProjectedYearsList(model);
                model.ExchangeRate = decimal.One;
                model.CurrCode     = string.IsNullOrEmpty(model.CurrCode)
                    ? DisbursementValues.USD : model.CurrCode;
                var edwDataResponse = _disbursementService.GetActualAgreedCompleteProjections(
                    operationNumber, new string[] { loanNumber });
                model.EdwData = edwDataResponse.IsValid
                    ? edwDataResponse.Actual
                    : new List <ActualAgreedModel>();
                GenericOperationNumberRequest request = new GenericOperationNumberRequest();
                request.OperationNumber = operationNumber;
                model.RemainingBalance  = model.RemainingBalance + (model.OldProjection
                                                                    .Where(o => o.Month == model.CurrentProjectionMonth &&
                                                                           o.Year == DateTime.Now.Year)
                                                                    .Select(o => o.Value).FirstOrDefault() / 1000);
                var otherFinancingSourcesResponse = _disbursementService
                                                    .GetOtherFinancingSources(request);

                if (otherFinancingSourcesResponse.IsValid)
                {
                    model.OtherFinancingSources = otherFinancingSourcesResponse.Value;
                }

                GenericLoanNumberRequest loanNumberRequest = new GenericLoanNumberRequest
                {
                    LoanNumber = loanNumber, OperationNumber = operationNumber
                };
                var minimumAmountToBeJustifiedResponse = _disbursementService
                                                         .GetMinimumAmountToBeJustified(loanNumberRequest);
                if (minimumAmountToBeJustifiedResponse.IsValid)
                {
                    model.MinimumAmountPending = minimumAmountToBeJustifiedResponse.Value;
                }
            }
            catch (Exception ex)
            {
                Logger.GetLogger().WriteError(
                    DisbursementValues.LOAN_LEVEL_PROJECTIONS_CONTROLLER,
                    DisbursementValues.MSJ_ERROR_GET_LOAN_MODEL,
                    ex);
                MessageHandler.SetMessage(
                    Localization.GetText(DisbursementValues.WARNING_UNHANDLED_ERROR),
                    DisbursementValues.ERROR);
                model.HasServiceError = true;
            }

            return(View(model));
        }