public void GetOPICSDealExternalTest() { OpicsBusiness target = new OpicsBusiness(); // TODO: Initialize to an appropriate value List<DEALModel> expected = null; // TODO: Initialize to an appropriate value List<DEALModel> actual; actual = target.GetOPICSDealExternal(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
/// <summary> /// Match deal between DMK deal no and OPICS deal no on processing date /// </summary> /// <param name="sessioninfo"></param> /// <param name="processdate"></param> /// <param name="DMKDealID"></param> /// <param name="OPICSNo"></param> /// <returns></returns> public static object MatchingDeal(SessionInfo sessioninfo, DateTime processdate, Guid DMKDealID, string OPICSNo) { DealBusiness _dealBusiness = new DealBusiness(); OpicsBusiness _opicsBusiness = new OpicsBusiness(); DA_TRN deal = null; string[] OPICSNoArr = OPICSNo.Split(','); List<DA_TRN> UpdateDeals = new List<DA_TRN>(); List<DEALModel> opicdeals = null; try { LoggingHelper.Debug("Match deal process on " + processdate.ToString()); //find deal before deal = _dealBusiness.GetByID(DMKDealID); if (deal==null) return new { Result = "ERROR", Message = String.Format("Deal {0} is not found.", deal.INT_DEAL_NO) }; //Find Deal in OPICS deal opicdeals = _opicsBusiness.GetOPICSDealExternal(processdate).Where(p => OPICSNoArr.Contains(p.EXT_DEAL_NO)).ToList(); foreach(string product in opicdeals.Select(o => o.PRODUCT).ToArray() ) { if (!deal.MA_PRODUCT.LABEL.Equals(product)) { return new { Result = "ERROR", Message = "Product does not match." }; } } foreach (string cpty in opicdeals.Select(o => o.CPTY).ToArray()) { if (!deal.MA_COUTERPARTY.USERCODE.ToString().Equals(cpty.Trim())) { return new { Result = "ERROR", Message = "Counterparty does not match." }; } } //Build transaction each deal BuildTransation(sessioninfo, opicdeals, deal, ref UpdateDeals); LoggingHelper.Debug("End Match deal process on " + processdate.ToString()); return new { Result = "OK", Message = String.Format("Match deal completed, between {0} and {1}.", deal.INT_DEAL_NO, OPICSNo) }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public static object GetDealExternalByProcessDate(SessionInfo sessioninfo, DateTime processdate, int startIndex, int count, string sorting) { OpicsBusiness _opicsBusiness = new OpicsBusiness(); DealBusiness _dealBusiness = new DealBusiness(); ReconcileBusiness _reconcileBusiness = new ReconcileBusiness(); List<DealTranModel> DealTrans = new List<DealTranModel>(); try { FlagReconcile(sessioninfo, true); LoggingHelper.Debug("Locked Reconcile table " + processdate.ToString()); LoggingHelper.Debug("Get OPICS Deal on " + processdate.ToString()); //Get data from database List<DEALModel> dealopics = _opicsBusiness.GetOPICSDealExternal(processdate); List<DA_TRN> importeddeals = _dealBusiness.GetImportedDealsByProcessDate(sessioninfo.Process.NextDate); //Ignore imported DMK Deals var query = from o in dealopics where !importeddeals.Any(d => d.EXT_DEAL_NO == o.EXT_DEAL_NO) select o; //Import unimported OPIC deals, and engine date < process date var passedopicdeals = query.Where(d => d.INSERT_DATE.Date < processdate.Date); //todaydeals for display on screen var todaydeals = from o in query where !passedopicdeals.Any(p => p.EXT_DEAL_NO == o.EXT_DEAL_NO) select o; //20140129 //OPICS deals which are cancelled after reconcile have been run once, must be deleted from DMK var cancelleddeals = from o in importeddeals where !dealopics.Any(p => p.EXT_DEAL_NO == o.EXT_DEAL_NO) select o; if (passedopicdeals != null) { LoggingHelper.Debug("Import Passed OPICS Deal"); foreach (DEALModel passedopicdeal in passedopicdeals.ToList()) { if (ValidateOPICS(passedopicdeal)) ImportPassedOPICSDeal(sessioninfo, passedopicdeal, sessioninfo.Process.NextDate, ref DealTrans); } if (cancelleddeals != null) { foreach (DA_TRN trn in cancelleddeals.ToList()) { DealTrans.Add(new DealTranModel() { ProductTransaction = (ProductCode)Enum.Parse(typeof(ProductCode), trn.MA_PRODUCT.LABEL.Replace(" ", string.Empty)), Transaction = trn, UpdateStates = UpdateStates.Deleting }); } } LoggingHelper.Debug("End Import Passed OPICS Deal as " + passedopicdeals.Count().ToString()); if (DealTrans.Count > 0) { LoggingHelper.Debug("UpdateDealReconcile for passed deal on " + processdate.ToString()); _reconcileBusiness.UpdateDealReconcile(sessioninfo, DealTrans); } } //Sort order by sorting string[] sortsp = sorting.Split(' '); IQueryable<DEALModel> orderedRecords = todaydeals.AsQueryable().OrderBy(sortsp[0], sortsp[1]); IEnumerable<DEALModel> sortedRecords = orderedRecords.ToList(); //if (sortsp[1].ToLower() == "desc") sortedRecords = sortedRecords.Reverse(); FlagReconcile(sessioninfo, false); LoggingHelper.Debug("Un-locked Reconcile table " + processdate.ToString()); //Return result to jTable return new { Result = "OK", Records = count > 0 ? sortedRecords.Skip(startIndex).Take(count).ToList() : sortedRecords, TotalRecordCount = sortedRecords.ToList().Count }; } catch (Exception ex) { FlagReconcile(sessioninfo,false); return new { Result = "ERROR", Message = ex.Message }; } }
public static object ImportExternalByProcessDate(SessionInfo sessioninfo) { OpicsBusiness _opicsBusiness = new OpicsBusiness(); DealBusiness _dealBusiness = new DealBusiness(); ReconcileBusiness _reconcileBusiness = new ReconcileBusiness(); List<DealTranModel> DealTrans = new List<DealTranModel>(); var results = new List<object>(); try { LoggingHelper.Debug("Get OPICS Deal on " + sessioninfo.Process.PreviousDate.ToString()); //Get data from OPICS List<DEALModel> opicsdeals = _opicsBusiness.GetOPICSDealExternal(sessioninfo.Process.PreviousDate); List<CASHFLOWModel> opicscashflows = _opicsBusiness.GetOPICSCashflow(sessioninfo.Process.PreviousDate); List<DA_TRN> importeddeals = _dealBusiness.GetImportedDealsByProcessDate(sessioninfo.Process.CurrentDate); //Ignore imported deals var query = from o in opicsdeals where !importeddeals.Any(d => d.EXT_DEAL_NO == o.EXT_DEAL_NO) select o; LoggingHelper.Debug("Import Passed OPICS Deal"); foreach (DEALModel opicdeal in query.ToList()) { if (ValidateOPICS(opicdeal)) ImportPassedOPICSDeal(sessioninfo, opicdeal, sessioninfo.Process.CurrentDate, ref DealTrans); } LoggingHelper.Debug("End Import Passed OPICS Deal as " + query.Count().ToString()); if (DealTrans.Count > 0) { //Insert to database LoggingHelper.Debug("Insert OPICS deals on " + sessioninfo.Process.PreviousDate.ToString()); _reconcileBusiness.UpdateDealReconcile(sessioninfo, DealTrans); } results.Add(new { Object = "OPICS Deals", Total = DealTrans.Count}); //Import Cashflows from OPICS List<DA_TRN_CASHFLOW> cashflows = null; if (opicscashflows != null && opicscashflows.Count > 0) { List<DA_TRN> allimporteddeals = importeddeals.Union(from t in DealTrans select t.Transaction).ToList(); List<DA_TRN_CASHFLOW> importedcashflows = _dealBusiness.GetFlowsByProcessDate(sessioninfo.Process.CurrentDate); cashflows = GenerateCashflowObject(sessioninfo, opicscashflows, importedcashflows, allimporteddeals); if (cashflows.Count > 0) { _reconcileBusiness.ImportCashflows(sessioninfo, cashflows); } } results.Add(new { Object = "OPICS Cashflows", Total = cashflows == null ? 0 : cashflows.Count }); //Return result to jTable return new { Result = "OK", //Records = count > 0 ? sortedRecords.Skip(startIndex).Take(count).ToList() : sortedRecords, Records = results, TotalRecordCount = results.Count }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }
public static object GetDealByProcessDateStatusCode(SessionInfo sessioninfo, DateTime processdate, StatusCode statuscode, int startIndex, int count, string sorting) { DealBusiness _dealBusiness = new DealBusiness(); OpicsBusiness _opicsBusiness = new OpicsBusiness(); LookupBusiness _lookupBusiness = new LookupBusiness(); List<DA_TRN> deals = null; List<DA_TRN> dealExts = null; List<DEALModel> opicdeals = null; try { //Get data from database if (statuscode == StatusCode.MATCHED) { LoggingHelper.Debug("Get DMK Deal is matched on " + processdate.ToString()); deals = _dealBusiness.GetDealByProcessDate(processdate, StatusCode.MATCHED); dealExts = _dealBusiness.GetImportedDealsByProcessDate(sessioninfo.Process.NextDate); } else { LoggingHelper.Debug("Get DMK Deal is not matched on " + processdate.ToString()); //Get data from database opicdeals = _opicsBusiness.GetOPICSDealExternal(processdate); //auto match with OPICS deal AutoMatchAndUpdateDeals(sessioninfo, processdate, opicdeals, out deals); } if (dealExts == null) dealExts = new List<DA_TRN>(); List<MA_FREQ_TYPE> freq = _lookupBusiness.GetFreqTypeAll(); List<MA_CURRENCY> ccys = _lookupBusiness.GetCurrencyAll(); //Sorting string[] sortsp = sorting.Split(' '); List<DealViewModel> dealviews = (from t in deals join p in dealExts on new { t.INT_DEAL_NO, t.FLAG_NEARFAR } equals new { p.INT_DEAL_NO, p.FLAG_NEARFAR } into ps join f1 in freq on t.FIRST.FREQTYPE_ID equals f1.ID into fg1 from subfg1 in fg1.DefaultIfEmpty() join f2 in freq on t.SECOND.FREQTYPE_ID equals f2.ID into fg2 from subfg2 in fg2.DefaultIfEmpty() join tempccy1 in ccys on t.FIRST.CCY_ID equals tempccy1.ID into ljccy1 from ccy1 in ljccy1.DefaultIfEmpty() join tempccy2 in ccys on t.SECOND.CCY_ID equals tempccy2.ID into ljccy2 from ccy2 in ljccy2.DefaultIfEmpty() where t.MA_STATUS.LABEL.Contains(statuscode.ToString()) && t.MATURITY_DATE.HasValue ? t.MATURITY_DATE.Value > sessioninfo.Process.CurrentDate : true select new DealViewModel { ID = t.ID, EntryDate = t.LOG.INSERTDATE, DMK_NO = t.INT_DEAL_NO, OPICS_NO = ps == null ? t.EXT_DEAL_NO : string.Join(",", ps.Select(i => i.EXT_DEAL_NO)), TradeDate = t.TRADE_DATE.Value, EffectiveDate = t.START_DATE, Instrument = t.MA_INSRUMENT.LABEL, MaturityDate = t.MATURITY_DATE.HasValue ? t.MATURITY_DATE : null, BuySell = t.FLAG_BUYSELL, Product = t.MA_PRODUCT.LABEL, Portfolio = t.MA_PORTFOLIO.LABEL, Counterparty = t.MA_COUTERPARTY.SNAME, Notional1 = t.FIRST.NOTIONAL, PayRec1 = t.FIRST.FLAG_PAYREC, FixedFloat1 = !t.FIRST.FLAG_FIXED.HasValue ? null : t.FIRST.FLAG_FIXED == true ? "FIXED" : "FLOAT", Fixing1 = t.FIRST.FIRSTFIXINGAMT, Rate1 = t.FIRST.RATE, SwapPoint1 = t.FIRST.SWAP_POINT, Notional2 = t.SECOND.NOTIONAL, PayRec2 = t.SECOND.FLAG_PAYREC, FixedFloat2 = !t.SECOND.FLAG_FIXED.HasValue ? null : t.SECOND.FLAG_FIXED == true ? "FIXED" : "FLOAT", Fixing2 = t.SECOND.FIRSTFIXINGAMT, Rate2 = t.SECOND.RATE, SwapPoint2 = t.SECOND.SWAP_POINT, Status = t.MA_STATUS.LABEL, KKContribute = t.KK_CONTRIBUTE, BotContribute = t.BOT_CONTRIBUTE, Remark = t.REMARK, Freq1 = subfg1 != null ? subfg1.USERCODE : null, Freq2 = subfg2 != null ? subfg2.USERCODE : null, CCY1 = ccy1 != null ? ccy1.LABEL : null, CCY2 = ccy2 != null ? ccy2.LABEL : null }).AsQueryable().OrderBy(sortsp[0], sortsp[1]).ToList(); //Return result to jTable return new { Result = "OK", Records = dealviews.Count > 0 ? dealviews.Skip(startIndex).Take(count).ToList() : dealviews, TotalRecordCount = dealviews.Count }; } catch (Exception ex) { return new { Result = "ERROR", Message = ex.Message }; } }