} // AddOwners private CompanyScoreModel BuildLimitedScoreModel(ExperianLtdActionResult oExperianLtd) { SortedDictionary <string, CompanyScoreModelItem> oDataset = oExperianLtd.Value.ToCompanyScoreModel(); return(new CompanyScoreModel { result = CompanyScoreModel.Ok, dataset = oDataset, dataset_display_order = ms_DisplayOrder, company_name = oExperianLtd.Value.CompanyName, company_ref_num = oExperianLtd.Value.RegisteredNumber, Data = null, DashboardModel = BuildLimitedDashboardModel(oExperianLtd), CompaniesHouseModel = oExperianLtd.CompaniesHouse }); } // BuildLimitedScoreModel
} // LoadExperianLtd public ExperianLtd CheckLtdCompanyCache(int userId, string sCompanyRefNum) { ExperianLtdActionResult ar = m_oServiceClient.Instance.CheckLtdCompanyCache(userId, sCompanyRefNum); return(ar.Value); } // CheckLtdCompanyCache
public ComapanyDashboardModel BuildLimitedDashboardModel(ExperianLtdActionResult data, ComapanyDashboardModel oModel = null) { if (oModel == null) { oModel = new ComapanyDashboardModel { FinDataHistories = new List <FinDataModel>(), LastFinData = new FinDataModel(), IsLimited = true, CompanyHistories = new List <CompanyHistory>() }; } // if var oExperianLtd = data.Value; oModel.CompanyName = oExperianLtd.CompanyName; oModel.CompanyRefNum = oExperianLtd.RegisteredNumber; oModel.Score = oExperianLtd.GetCommercialDelphiScore(); oModel.ScoreColor = CreditBureauModelBuilder.GetScorePositionAndColor(oModel.Score, 100, 0).Color; oModel.CcjMonths = oExperianLtd.GetAgeOfMostRecentCCJDecreeMonths(); oModel.Ccjs = oExperianLtd.GetNumberOfCcjsInLast24Months(); oModel.CcjValue = oExperianLtd.GetSumOfCcjsInLast24Months(); oModel.OriginationDate = oExperianLtd.GetOriginationDate(); if (data.History != null) { foreach (ScoreAtDate scoreAtDate in data.History) { oModel.CompanyHistories.Add(new CompanyHistory { Score = scoreAtDate.Score, Date = scoreAtDate.Date, ServiceLogId = scoreAtDate.ServiceLogId, Balance = scoreAtDate.Balance }); } } List <ExperianLtdDL97> oDL97List = new List <ExperianLtdDL97>(); List <ExperianLtdDL99> oDL99List = new List <ExperianLtdDL99>(); foreach (var oKid in oExperianLtd.Children) { if (typeof(ExperianLtdDL97) == oKid.GetType()) { oDL97List.Add((ExperianLtdDL97)oKid); } else if (typeof(ExperianLtdDL99) == oKid.GetType()) { ExperianLtdDL99 dl99 = (ExperianLtdDL99)oKid; if (dl99.Date.HasValue) { oDL99List.Add(dl99); } } // if } // for each string worstStatusAll = "0"; //Calc and add Cais Balance oModel.CaisBalance = 0; foreach (var cais in oDL97List) { var state = cais.AccountState; var balance = cais.CurrentBalance ?? 0; // Sum all accounts balance that are not settled if (!string.IsNullOrEmpty(state) && state[0] != 'S') { oModel.CaisBalance += balance; oModel.CaisAccounts++; } // if if (!string.IsNullOrEmpty(state) && state[0] == 'D') { oModel.DefaultAccounts++; oModel.DefaultAmount += cais.DefaultBalance ?? 0; } else { var status = cais.AccountStatusLast12AccountStatuses ?? string.Empty; var worstStatus = CreditBureauModelBuilder.GetWorstStatus(Regex.Split(status, string.Empty)); if (worstStatus != "0") { oModel.LateAccounts++; worstStatusAll = CreditBureauModelBuilder.GetWorstStatus(worstStatusAll, worstStatus); } // if } // if } // for each string date; oModel.LateStatus = CreditBureauModelBuilder.GetAccountStatusString(worstStatusAll, out date, true); // Calc and add tangible equity and adjusted profit if (oDL99List.Count > 0) { // ReSharper disable PossibleInvalidOperationException oDL99List.Sort((a, b) => b.Date.Value.CompareTo(a.Date.Value)); // ReSharper restore PossibleInvalidOperationException for (var i = 0; i < oDL99List.Count - 1; i++) { ExperianLtdDL99 oCurItem = oDL99List[i]; decimal totalShareFund = oCurItem.TotalShareFund ?? 0; decimal inTngblAssets = oCurItem.InTngblAssets ?? 0; decimal debtorsDirLoans = oCurItem.DebtorsDirLoans ?? 0; decimal credDirLoans = oCurItem.CredDirLoans ?? 0; decimal onClDirLoans = oCurItem.OnClDirLoans ?? 0; decimal tangibleEquity = totalShareFund - inTngblAssets - debtorsDirLoans + credDirLoans + onClDirLoans; if (oDL99List.Count > 1) { var oNextItem = oDL99List[i + 1]; decimal retainedEarnings = oCurItem.RetainedEarnings ?? 0; decimal retainedEarningsPrev = oNextItem.RetainedEarnings ?? 0; decimal fixedAssetsPrev = oNextItem.TngblAssets ?? 0; decimal adjustedProfit = retainedEarnings - retainedEarningsPrev + fixedAssetsPrev / 5; var fin = new FinDataModel { TangibleEquity = tangibleEquity, AdjustedProfit = adjustedProfit, }; oModel.FinDataHistories.Add(fin); if (i == 0) { oModel.LastFinData = fin; } } // if } // for each } // if DL99 has data return(oModel); } // BuildLimitedDashboardModel
} // ParseExperianLtd public ExperianLtd LoadExperianLtd(long nServiceLogID) { ExperianLtdActionResult ar = m_oServiceClient.Instance.LoadExperianLtd(nServiceLogID); return(ar.Value); } // LoadExperianLtd