public async Task <ActionResult> LiquidAssetsUsable(string fileId) { try { this.Info("Calculating Liquid Assets Usable"); // Validate custom header values CustomHeaderData customHeaderData = new CustomHeaderData(HttpContext.Request.Headers); customHeaderData.ValidateCustomHeaders(); // Get the file from disk MismoContentModel mismoContentModel = await _fileManagerApiClient.GetMismoContentAsync(fileId, $"{_configuration["FileManagerApi:ApiUrl"]}"); // Use custom header information and mismo content to create IUSLoan & DocTypeCalcResolver _IUSLoanManager.SetUp(customHeaderData, mismoContentModel); DocTypeCalcResolver docTypeCalcResolver = _IUSLoanManager.GetDocTypeCalcResolver(); IUSLoan iusLoan = _IUSLoanManager.GetIUSLoan(); // Use Factory to create Calculations Interface Calculations calcs = DocTypeCalcFactory.Create(docTypeCalcResolver, iusLoan); decimal total = calcs.AssetCalculation.LiquidAssetsUsable(); return(Ok(total)); } catch (Exception ex) { this.Error("Error in calculating Liquid Assets Usable", ex.Message); return(BadRequest(ex.Message)); } }
public async Task <ActionResult> MortgageTermsDataAsync(string fileId) { try { this.Info("Calculating Mortgage Terms"); // Validate custom header values CustomHeaderData customHeaderData = new CustomHeaderData(HttpContext.Request.Headers); customHeaderData.ValidateCustomHeaders(); // Get the file from disk MismoContentModel mismoContentModel = await _fileManagerApiClient.GetMismoContentAsync(fileId, $"{_configuration["FileManagerApi:ApiUrl"]}"); // Use custom header information and mismo content to create IUSLoan & DocTypeCalcResolver _IUSLoanManager.SetUp(customHeaderData, mismoContentModel); DocTypeCalcResolver docTypeCalcResolver = _IUSLoanManager.GetDocTypeCalcResolver(); IUSLoan iusLoan = _IUSLoanManager.GetIUSLoan(); // Use Factory to create Calculations Interface Calculations calcs = DocTypeCalcFactory.Create(docTypeCalcResolver, iusLoan); if (iusLoan.MismoLoan.MortgageTerms != null) { return(Ok(iusLoan.MismoLoan.MortgageTerms)); } else { return(NotFound()); } } catch (Exception ex) { this.Error("Error in Calculating Mortgage Terms", ex.Message); return(BadRequest(ex.Message)); } }
public void SetUp(CustomHeaderData customHeaderData, MismoContentModel mismoContentModel) { // Deserialize the MISMO xml to MISMO object LoanApplicationDTO mismoXmlLoan = null; using (TextReader reader = new StringReader(mismoContentModel.content)) { mismoXmlLoan = (LoanApplicationDTO) new XmlSerializer(typeof(LoanApplicationDTO)).Deserialize(reader); } // Map MISMO object to IUSLoan.Loan object MismoMapManager loanMapper = new MismoMapManager(mismoXmlLoan); MismoLoan loan = new MismoLoan(); loan = loanMapper.MapToLoan(); // Create IUSLoan object IUSLoan iUSLoan = new IUSLoan { DocType = customHeaderData.DocTypeEnum, GuideLineDt = customHeaderData.GuidelineDt, MismoLoan = loan, Source = customHeaderData.SourceType, ImpacProgramCode = customHeaderData.ImpacProgramCode }; _IUSLoan = iUSLoan; DocTypeCalcResolver resolver = new DocTypeCalcResolver { DocType = customHeaderData.DocTypeEnum, GuideLineDt = customHeaderData.GuidelineDt, Source = customHeaderData.SourceType }; _docTypeCalcResolver = resolver; }
public async Task <ActionResult> CalculateWorksheet(string fileId) { try { this.Info("Calculating BankStatement worksheet"); // Validate custom header values CustomHeaderData customHeaderData = new CustomHeaderData(HttpContext.Request.Headers); customHeaderData.ValidateCustomHeaders(); // Get full request from disk LoanCalcRequestModel loanCalcRequestModel = await _fileManagerApiClient.GetLoanCalcRequestAsync(fileId, $"{_configuration["FileManagerApi:ApiUrl"]}"); MismoContentModel mismoContentModel = loanCalcRequestModel.MismoContent; List <CreditContentModel> creditContents = loanCalcRequestModel.CreditContents; // Use custom header information and mismo content to create IUSLoan & DocTypeCalcResolver _IUSLoanManager.SetUp(customHeaderData, loanCalcRequestModel); DocTypeCalcResolver docTypeCalcResolver = _IUSLoanManager.GetDocTypeCalcResolver(); IUSLoan iusLoan = _IUSLoanManager.GetIUSLoan(); // Use Factory to create Calculations Interface Calculations calcs = DocTypeCalcFactory.Create(docTypeCalcResolver, iusLoan); // Create worksheet model Worksheet worksheet = new Worksheet(); if (calcs.Message == null) { // Calculate Assets section worksheet.Assets = GetWorksheetAssets(calcs); // Calculate Residual Assets section worksheet.ResidualAssets = GetWorksheetResidualAssets(calcs, iusLoan); worksheet.ResidualAssets.TotalResidualAsset = calcs.AssetCalculation.TotalResidualAssets(); // Calculate 60 months Required Reserves //worksheet.MonthlyLiabilities = GetMonthlyLiabilities(calcs, iusLoan); //worksheet.SixtyMonthsRequiredReserves = GetSixtyMonthRequiredReserves(worksheet.MonthlyLiabilities); //worksheet.ProgramReservesRequired = worksheet.SixtyMonthsRequiredReserves.Total + // (worksheet.ResidualAssets.CashFromBorrower.CashFromBorrowerTotal > 0 // ? worksheet.ResidualAssets.CashFromBorrower.CashFromBorrowerTotal : 0); // Calculate Qualifying P&I Payment worksheet.QualifyingPI = GetQualifyingPI(calcs).ToString(); // Calculate BaseReserve worksheet.BaseReserves = GetBaseReserves(calcs); // Calculate Reo Reserves ForNonSubj Retained Properties worksheet.AdditionalReservesRequired = GetReservesForNonSubjRetainedProperties(calcs); worksheet.TotalRequiredReserves = worksheet.BaseReserves + GetAddOneMonthReserves(calcs); worksheet.UsableCashoutProceeds = GetUsableCashOut(worksheet.ResidualAssets.CashFromBorrower.CashFromBorrowerTotal, calcs.LoanCalcs.LTV()); worksheet.NetReservesNeededAfterCashOut = GetNetReserves(worksheet.BaseReserves, worksheet.AdditionalReservesRequired, worksheet.ResidualAssets.CashFromBorrower.CashFromBorrowerTotal, calcs.LoanCalcs.LTV()); worksheet.TotalAdditionalReservesStillRequired = worksheet.ResidualAssets.TotalResidualAsset - worksheet.NetReservesNeededAfterCashOut < 0 ? worksheet.ResidualAssets.TotalResidualAsset - worksheet.NetReservesNeededAfterCashOut : 0; worksheet.TotalRequiredAssetsForTransaction = worksheet.ResidualAssets.CashFromBorrower.CashFromBorrowerTotal + worksheet.TotalAdditionalReservesStillRequired; } else { worksheet.Message = calcs.Message; } return(Ok(worksheet)); } catch (Exception ex) { this.Error("Error in BankStatement", ex.Message); return(BadRequest(ex.Message)); } }
public async Task <ActionResult> CalculateWorksheet(string fileId) { try { this.Info("Calculating Encompass UW Launchpad worksheet"); // Validate custom header values CustomHeaderData customHeaderData = new CustomHeaderData(HttpContext.Request.Headers); customHeaderData.ValidateCustomHeaders(); // Get full request from disk LoanCalcRequestModel loanCalcRequestModel = await _fileManagerApiClient.GetLoanCalcRequestAsync(fileId, $"{_configuration["FileManagerApi:ApiUrl"]}"); MismoContentModel mismoContentModel = loanCalcRequestModel.MismoContent; List <CreditContentModel> creditContents = loanCalcRequestModel.CreditContents; // Use custom header information and mismo content to create IUSLoan & DocTypeCalcResolver _IUSLoanManager.SetUp(customHeaderData, loanCalcRequestModel); DocTypeCalcResolver docTypeCalcResolver = _IUSLoanManager.GetDocTypeCalcResolver(); IUSLoan iusLoan = _IUSLoanManager.GetIUSLoan(); // Use Factory to create Calculations Interface Calculations calcs = DocTypeCalcFactory.Create(docTypeCalcResolver, iusLoan); UWLaunchPadWorksheet worksheet = new UWLaunchPadWorksheet(); if (calcs.Message == null) { worksheet.ProgramReservesRequired = calcs.LoanCalcs.ProgramReservesRequired(); worksheet.Source = "IUS"; worksheet.AdditionalReservesRequired = calcs.LoanCalcs.AdditionalReservesRequired(); worksheet.TotalReservesRequired = worksheet.ProgramReservesRequired + worksheet.AdditionalReservesRequired; worksheet.TotalReservesRequiredMonth = Math.Round(worksheet.TotalReservesRequired / GetPITIA(iusLoan, calcs), 2); worksheet.Assets = GetWorksheetAssets(calcs); worksheet.VerifiedAssetsMonth = Math.Round(worksheet.Assets.TotalVerifiedAmount / GetPITIA(iusLoan, calcs), 2); worksheet.FundsAvailableForReserves = calcs.AssetCalculation.TotalResidualAssets(); worksheet.UsableCashOutProceed = calcs.LoanCalcs.CashoutProceed(); worksheet.UsableCashOutProceedMonth = Math.Round(worksheet.UsableCashOutProceed / GetPITIA(iusLoan, calcs), 2); worksheet.RequiredFundsToClose = calcs.LoanCalcs.CashFromBorrower(); worksheet.TotalReservesAfterClose = worksheet.Assets.TotalVerifiedAmount - worksheet.RequiredFundsToClose; worksheet.TotalReservesAfterCloseMonth = Math.Round(worksheet.TotalReservesAfterClose / GetPITIA(iusLoan, calcs), 2); worksheet.TotalReservesWithCashoutProceed = worksheet.Assets.TotalVerifiedAmount + worksheet.UsableCashOutProceed - worksheet.RequiredFundsToClose; worksheet.TotalReservesWithCashoutProceedMonth = Math.Round(worksheet.TotalReservesWithCashoutProceed / GetPITIA(iusLoan, calcs), 2); worksheet.TotalNetQualifyingReserves = calcs.LoanCalcs.NetQualifyingReserves(); worksheet.TotalNetCashReserveAmount = worksheet.Assets.TotalUsable - calcs.LoanCalcs.CashFromBorrower() - worksheet.TotalReservesRequired; } else { worksheet.Message = calcs.Message; } return(Ok(worksheet)); } catch (Exception ex) { this.Error("Error in Encompass UW LaunchPad", ex.Message); return(BadRequest(ex.Message)); } }
public void SetUp(CustomHeaderData customHeaderData, LoanCalcRequestModel loanCalcRequestModel) { MismoContentModel mismoContentModel = loanCalcRequestModel.MismoContent; List <CreditContentModel> creditContents = loanCalcRequestModel.CreditContents; // Deserialize the MISMO xml to MISMO object LoanApplicationDTO mismoXmlLoan = null; using (TextReader reader = new StringReader(mismoContentModel.content)) { mismoXmlLoan = (LoanApplicationDTO) new XmlSerializer(typeof(LoanApplicationDTO)).Deserialize(reader); } // Map MISMO object to IUSLoan.Loan object MismoMapManager loanMapper = new MismoMapManager(mismoXmlLoan); MismoLoan loan = new MismoLoan(); loan = loanMapper.MapToLoan(); // Deserialize each credit xml to Credit MISMO object List <CreditResponseGroup> creditResponseGroups = new List <CreditResponseGroup>(); foreach (CreditContentModel creditContent in creditContents) { CREDITREPORTING_RESPONSE_GROUP_Type creditXml = null; using (TextReader reader = new StringReader(creditContent.content)) { creditXml = (CREDITREPORTING_RESPONSE_GROUP_Type) new XmlSerializer(typeof(CREDITREPORTING_RESPONSE_GROUP_Type)).Deserialize(reader); } // Map MISMO object to IUSLoan.Loan object CreditMapManager creditMapper = new CreditMapManager(creditXml); CreditResponseGroup creditResponseGroup = new CreditResponseGroup(); creditResponseGroup = creditMapper.MapToCredit(); creditResponseGroups.Add(creditResponseGroup); } // Create IUSLoan object IUSLoan iUSLoan = new IUSLoan { DocType = customHeaderData.DocTypeEnum, GuideLineDt = customHeaderData.GuidelineDt, MismoLoan = loan, Source = customHeaderData.SourceType, ImpacProgramCode = customHeaderData.ImpacProgramCode, CreditReports = creditResponseGroups }; _IUSLoan = iUSLoan; //Adding BankStatement if DocType is BankStatement or premier if (_IUSLoan.DocType == DocTypeEnum.BankStatements || _IUSLoan.DocType == DocTypeEnum.BankStatementsPremier) { List <BankStatement> bankStatements = new List <BankStatement>(); List <BankStatementContentModel> bankStatementContents = loanCalcRequestModel.BankStatementContents; if (bankStatementContents != null) { foreach (BankStatementContentModel BankStatModel in bankStatementContents) { object bankStatementDTO; XmlSerializer serializer = new XmlSerializer(typeof(BankStatementDTO)); using (TextReader reader = new StringReader(BankStatModel.content)) { bankStatementDTO = serializer.Deserialize(reader); } BankStatementMapManager BankStatementMapper = new BankStatementMapManager((BankStatementDTO)bankStatementDTO); BankStatement bankStatement = new BankStatement(); bankStatement = BankStatementMapper.MapToBankStatement(); bankStatements.Add(bankStatement); } _IUSLoan.BankStatements = bankStatements; } else { //_logger.LogError("BankStatement not found"); } } if (loanCalcRequestModel.IUSLoanInfo != null) { // Merge MortgageTerms request info with loan's mortgage terms object if (loanCalcRequestModel.IUSLoanInfo.MortgageTermsInfo != null) { MortgageTermsMergeManager mortgageTermsMergeMapper = new MortgageTermsMergeManager(loanCalcRequestModel.IUSLoanInfo.MortgageTermsInfo); mortgageTermsMergeMapper.MergeWith(_IUSLoan.MismoLoan.MortgageTerms); } // Merge ReoProperties request info with loan object if (loanCalcRequestModel.IUSLoanInfo.ReoPropertiesInfo != null) { ReoPropertyMergeManager reoPropertyMergeMapper = new ReoPropertyMergeManager(loanCalcRequestModel.IUSLoanInfo.ReoPropertiesInfo); reoPropertyMergeMapper.MergeWith(_IUSLoan.MismoLoan.ReoProperties); } } // Use Liability Merge Manager to apply bussiness logic on merging liabilities. List <CreditLiability> allCreditLiabilities = new List <CreditLiability>(); foreach (CreditResponseGroup creditReport in _IUSLoan.CreditReports) { allCreditLiabilities.AddRange(creditReport.Response.ResponseData.CreditResponse.CreditLiabilities); } LiabilityMergeManager liabilityMergeManager = new LiabilityMergeManager(allCreditLiabilities); liabilityMergeManager.MergeWith(_IUSLoan.MismoLoan.Liabilities); DocTypeCalcResolver resolver = new DocTypeCalcResolver { DocType = customHeaderData.DocTypeEnum, GuideLineDt = customHeaderData.GuidelineDt, Source = customHeaderData.SourceType }; _docTypeCalcResolver = resolver; }
public async Task <ActionResult> CalculateWorksheet(string fileId) { try { this.Info("Calculating Asset Qualifier worksheet"); // Validate custom header values CustomHeaderData customHeaderData = new CustomHeaderData(HttpContext.Request.Headers); customHeaderData.ValidateCustomHeaders(); // Get full request from disk LoanCalcRequestModel loanCalcRequestModel = await _fileManagerApiClient.GetLoanCalcRequestAsync(fileId, $"{_configuration["FileManagerApi:ApiUrl"]}"); MismoContentModel mismoContentModel = loanCalcRequestModel.MismoContent; List <CreditContentModel> creditContents = loanCalcRequestModel.CreditContents; // Use custom header information and mismo content to create IUSLoan & DocTypeCalcResolver _IUSLoanManager.SetUp(customHeaderData, loanCalcRequestModel); DocTypeCalcResolver docTypeCalcResolver = _IUSLoanManager.GetDocTypeCalcResolver(); IUSLoan iusLoan = _IUSLoanManager.GetIUSLoan(); // Use Factory to create Calculations Interface Calculations calcs = DocTypeCalcFactory.Create(docTypeCalcResolver, iusLoan); // Create worksheet model Worksheet worksheet = new Worksheet(); if (calcs.Message == null) { // Calculate Assets section C7, C8, C9, C10, E11 worksheet.Assets = GetWorksheetAssets(calcs); //LoanAmount, Subordinate financing loan amount, Cash from borrower E12, E13, E14 worksheet.ResidualAssets = GetWorksheetResidualAssets(calcs, iusLoan); //Total Residual Assets E15 worksheet.ResidualAssets.TotalResidualAsset = calcs.AssetCalculation.TotalResidualAssets(); // Total Monthly Liabilites, mortgage related expense, PITIA, Total Net Rental D16, D17, D18, D19, D20, E21 worksheet.MonthlyLiabilities = GetMonthlyLiabilities(calcs, iusLoan); //Total 60 months Required Reserves E22 worksheet.SixtyMonthsRequiredReserves = GetSixtyMonthRequiredReserves(worksheet.MonthlyLiabilities); // Calculate Qualifying P&I Payment E23 worksheet.QualifyingPI = iusLoan.ImpacProgramCode.Contains("IO") ? GetQualifyingPI(calcs).ToString() : calcs.ProposedHousingCalcs.FirstMortgagePIAmount().ToString(); // Calculate BaseReserve E24 worksheet.BaseReserves = GetBaseReserves(calcs); //Calculate Additional Reserves Required E25 worksheet.AdditionalReservesRequired = GetReservesForNonSubjRetainedProperties(calcs); //Additional Reserves Required //worksheet.AdditionalReservesRequired = calcs.LoanCalcs.AdditionalReservesRequired(); //Net Reserves Need after Cashout E28 worksheet.NetReservesNeededAfterCashOut = worksheet.BaseReserves + worksheet.AdditionalReservesRequired; //Total Additional Still Required E29 worksheet.TotalAdditionalReservesStillRequired = worksheet.NetReservesNeededAfterCashOut > 0 ? worksheet.NetReservesNeededAfterCashOut : 0; //Total Required Assets For Transaction E30 worksheet.TotalRequiredAssetsForTransaction = worksheet.ResidualAssets.TotalResidualAsset + worksheet.SixtyMonthsRequiredReserves.Total + worksheet.TotalAdditionalReservesStillRequired; //Loan Qualify D31 worksheet.LoanQualify = worksheet.ResidualAssets.TotalResidualAsset < worksheet.TotalRequiredAssetsForTransaction ? false : true; //Amount of shortage or funds Remains E32 worksheet.FundRemain = worksheet.ResidualAssets.TotalResidualAsset - worksheet.TotalRequiredAssetsForTransaction; //Toal Monthly Income C39 worksheet.TotalMonthlyIncome = worksheet.ResidualAssets.TotalResidualAsset > 0 ? worksheet.ResidualAssets.TotalResidualAsset / 60 : 0; //Total Monthly Residual Income E39 worksheet.TotalMonthlyResidualIncome = worksheet.TotalMonthlyIncome - worksheet.MonthlyLiabilities.Total; worksheet.Date = DateTime.Now.Date.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); } else { worksheet.Message = calcs.Message; } return(Ok(worksheet)); } catch (Exception ex) { this.Error("Error in Asset Qualifier worksheet", ex.Message); return(BadRequest(ex.Message)); } }