public void GetLimitByCriteriaTest() { LimitCheckBusiness target = new LimitCheckBusiness(); // TODO: Initialize to an appropriate value Guid CTPY_ID = new Guid(); // TODO: Initialize to an appropriate value Guid ProductID = new Guid(); // TODO: Initialize to an appropriate value List<LimitCheckModel> expected = null; // TODO: Initialize to an appropriate value List<LimitCheckModel> actual; actual = target.GetLimitByCriteria(CTPY_ID, ProductID); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public LimitDisplayModel CheckCountryLimit(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); Guid guExcludeID = Guid.Empty; if (trn.KK_PCCF != null) { List<CountryLimitModel> deal_conts = new List<CountryLimitModel>(); if (trn.FLAG_SETTLE.HasValue && trn.FLAG_SETTLE.Value) { deal_conts = (from f in trn.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new CountryLimitModel { EXPOSURE_DATE = f.FLOW_DATE.Value, EXPOSURE = f.FLOW_AMOUNT_THB.Value + trn.KK_CONTRIBUTE }).ToList(); } if (trn.TRADE_DATE.Value != trn.MATURITY_DATE.Value) deal_conts.Add(new CountryLimitModel { EXPOSURE_DATE = trn.TRADE_DATE.Value, EXPOSURE = trn.KK_CONTRIBUTE.Value }); //Find original deal for exclude it from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID)) guExcludeID = Guid.Parse(strExcludeID.Replace("\"", "")); List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllCountry(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty); limitDisplay.LimitDisplayObject = GenerateCountryLimitDisplay(deal_conts, ori_conts, trn, null, sessioninfo.CountryOverwrite, ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) trn.OVER_COUNTRY_AMOUNT = limitDisplay.OverAmount; } else { limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR; limitDisplay.Message = "This deal breach allowed tenor."; } return limitDisplay; }
public void LimitCheckBusinessConstructorTest() { LimitCheckBusiness target = new LimitCheckBusiness(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public List<LimitCheckModel> GetSCEReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strSource, string strStatus) { try { DateTime dteReport; LimitCheckBusiness _limitBusiness = new LimitCheckBusiness(); DealBusiness _dealBusiness = new DealBusiness(); CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); Guid guCtpyID = Guid.Empty; if (String.IsNullOrEmpty(strReportDate)) throw this.CreateException(new Exception(), "Please input report date."); else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport)) throw this.CreateException(new Exception(), "Invalid report date."); else dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null); if (_dealBusiness.CountByProcessDate(dteReport) == 0) { throw this.CreateException(new Exception(), "No data for selected report date."); } if (Guid.TryParse(strCtpy, out guCtpyID)) { guCtpyID = Guid.Parse(strCtpy); } var limits = _limitBusiness.GetSCEByCriteria(dteReport, guCtpyID, Guid.Empty, strSource, Guid.Empty, Guid.Empty) .OrderBy(p => p.SNAME).ThenBy(p => p.FLOW_DATE) .Distinct(new LimitCheckComparer()).AsQueryable(); //Get temp limit //Look for temp limit when all conditions meet // 1. Transaction maturity date <= Temp limit maturity date foreach (LimitCheckModel limit in limits) { MA_TEMP_CTPY_LIMIT temp_limit = _counterpartyBusiness.GetActiveTempByID(sessioninfo.Process.CurrentDate, limit.FLOW_DATE, limit.CTPY_LIMIT_ID); if (temp_limit != null) limit.TEMP_AMOUNT = temp_limit.AMOUNT; } if (strStatus != "" ) { limits = limits.Where(t => t.STATUS.IndexOf(strStatus, StringComparison.OrdinalIgnoreCase) >= 0); } return limits.ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public List<RepoReportModel> GetRepoReport(SessionInfo sessioninfo, string strReportDate, string strSource, string strCtpy) { try { DateTime dteReport; LimitCheckBusiness _limitBusiness = new LimitCheckBusiness(); DealBusiness _dealBusiness = new DealBusiness(); LimitProductBusiness _limitProductBusiness = new LimitProductBusiness(); LookupBusiness _lookupBusiness = new LookupBusiness(); StaticDataBusiness _staticBusiness = new StaticDataBusiness(); List<RepoReportModel> reports = new List<RepoReportModel>(); RepoReportModel report; Guid guCtpyID = Guid.Empty; if (String.IsNullOrEmpty(strReportDate)) throw this.CreateException(new Exception(), "Please input report date."); else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport)) throw this.CreateException(new Exception(), "Invalid report date."); else dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null); if (Guid.TryParse(strCtpy, out guCtpyID)) { guCtpyID = Guid.Parse(strCtpy); } Guid guProductID = _lookupBusiness.GetProductByUsercode(ProductCode.REPO.ToString()).ID; MA_PCCF rev_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("84f608c9-8b58-48eb-a6dd-a5407548784a")); MA_PCCF rep_gov_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("28b24b19-e81d-4f82-a2f0-7c834ee3f91c")); MA_PCCF rep_soe_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("7014b05e-198f-4f62-94b0-1d54322efbca")); var limits = _limitBusiness.GetPCEByCriteria(dteReport, guCtpyID, guProductID, strSource, Guid.Empty, Guid.Empty).Distinct(new LimitCheckComparer()).ToList(); foreach (LimitCheckModel limit in limits) { report = new RepoReportModel(); report.PROCESSING_DATE = limit.PROCESSING_DATE; report.SNAME = limit.SNAME; report.LIMIT_LABEL = limit.LIMIT_LABEL; report.GEN_AMOUNT = limit.GEN_AMOUNT; report.TEMP_AMOUNT = limit.TEMP_AMOUNT; //report.AMOUNT = limit.AMOUNT; report.EXPIRE_DATE = limit.EXPIRE_DATE; report.ORIGINAL_KK_CONTRIBUTE = limit.ORIGINAL_KK_CONTRIBUTE; report.DEAL_CONTRIBUTION = 0; report.REV_AMOUNT = report.AVAILABLE / rev_pccf.C1.Value * 100; report.REP_GOV_5_AMOUNT = report.AVAILABLE / rep_gov_pccf.C5.Value * 100; report.REP_GOV_10_AMOUNT = report.AVAILABLE / rep_gov_pccf.C10.Value * 100; report.REP_GOV_20_AMOUNT = report.AVAILABLE / rep_gov_pccf.C20.Value * 100; report.REP_GOV_20s_AMOUNT = report.AVAILABLE / rep_gov_pccf.more20.Value * 100; report.REP_SOE_5_AMOUNT = report.AVAILABLE / rep_soe_pccf.C5.Value * 100; report.REP_SOE_10_AMOUNT = report.AVAILABLE / rep_soe_pccf.C10.Value * 100; report.REP_SOE_20_AMOUNT = report.AVAILABLE / rep_soe_pccf.C20.Value * 100; report.REP_SOE_20s_AMOUNT = report.AVAILABLE / rep_soe_pccf.more20.Value * 100; reports.Add(report); } return reports; } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public List<LimitCheckModel> GetCountryReport(SessionInfo sessioninfo, string strReportDate, string strCountry, string strSource, string strStatus) { try { DateTime dteReport; LimitCheckBusiness _limitBusiness = new LimitCheckBusiness(); DealBusiness _dealBusiness = new DealBusiness(); CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); CountryBusiness _countryBusiness = new CountryBusiness(); Guid guCountryID = Guid.Empty; MA_COUNTRY_LIMIT temp_limit = null; if (String.IsNullOrEmpty(strReportDate)) throw this.CreateException(new Exception(), "Please input report date."); else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport)) throw this.CreateException(new Exception(), "Invalid report date."); else dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null); if (_dealBusiness.CountByProcessDate(dteReport) == 0) { throw this.CreateException(new Exception(), "No data for selected report date."); } if (Guid.TryParse(strCountry, out guCountryID)) { guCountryID = Guid.Parse(strCountry); } List<LimitCheckModel> sets = _limitBusiness.GetCountrySETByCriteria(dteReport, guCountryID, strSource, Guid.Empty, Guid.Empty); List<LimitCheckModel> pces = _limitBusiness.GetCountryPCEByCriteria(dteReport, guCountryID, strSource, Guid.Empty, Guid.Empty); var reports = (from report in sets.Union(pces) join pce in pces on report.COUNTRY_ID equals pce.COUNTRY_ID select new LimitCheckModel { COUNTRY_LABEL = report.COUNTRY_LABEL, COUNTRY_ID = report.COUNTRY_ID, FLAG_CONTROL = report.FLAG_CONTROL, GEN_AMOUNT = report.AMOUNT, PROCESSING_DATE = report.PROCESSING_DATE, EXPIRE_DATE = report.EXPIRE_DATE, FLOW_DATE = report.FLOW_DATE, SET_CONTRIBUTE = report.SET_CONTRIBUTE, PCE_CONTRIBUTE = pce.PCE_CONTRIBUTE }).GroupBy(g => new { g.COUNTRY_ID, g.COUNTRY_LABEL, g.FLAG_CONTROL, g.GEN_AMOUNT, g.PROCESSING_DATE, g.EXPIRE_DATE, g.FLOW_DATE, g.PCE_CONTRIBUTE }).Select(s => new LimitCheckModel { COUNTRY_LABEL = s.Key.COUNTRY_LABEL, COUNTRY_ID = s.Key.COUNTRY_ID, FLAG_CONTROL = s.Key.FLAG_CONTROL, GEN_AMOUNT = s.Key.GEN_AMOUNT, PROCESSING_DATE = s.Key.PROCESSING_DATE, EXPIRE_DATE = s.Key.EXPIRE_DATE, FLOW_DATE = s.Key.FLOW_DATE, PCE_CONTRIBUTE = s.Key.PCE_CONTRIBUTE, SET_CONTRIBUTE = s.Sum(x => x.SET_CONTRIBUTE), ORIGINAL_KK_CONTRIBUTE = s.Key.PCE_CONTRIBUTE + s.Sum(y => y.SET_CONTRIBUTE) }).ToList(); foreach (var report in reports) { temp_limit = _countryBusiness.GetActiveTempByCountryID(sessioninfo.Process.CurrentDate, report.FLOW_DATE, report.COUNTRY_ID); if (temp_limit != null) report.TEMP_AMOUNT = temp_limit.AMOUNT; } if (strStatus != "") { reports = reports.Where(t => t.STATUS.IndexOf(strStatus, StringComparison.OrdinalIgnoreCase) >= 0).ToList(); } return reports.OrderBy(p => p.COUNTRY_LABEL).ThenBy(t => t.FLOW_DATE).ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public LimitDisplayModel CheckFXSwapCountryLimit(SessionInfo sessioninfo, DA_TRN trn1, DA_TRN trn2, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); DA_TRN oldtrn1 = null; DA_TRN oldtrn2 = null; Guid guExcludeID1 = Guid.Empty; Guid guExcludeID2 = Guid.Empty; if (trn1.KK_PCCF != null && trn2.KK_PCCF != null) { List<CountryLimitModel> deal_conts = new List<CountryLimitModel>(); if (trn1.FLAG_SETTLE.HasValue && trn1.FLAG_SETTLE.Value) { deal_conts = (from f in trn1.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new CountryLimitModel { EXPOSURE_DATE = f.FLOW_DATE.Value, EXPOSURE = f.FLOW_AMOUNT_THB.Value + trn1.KK_CONTRIBUTE }).Union( (from f in trn2.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new CountryLimitModel { EXPOSURE_DATE = f.FLOW_DATE.Value, EXPOSURE = f.FLOW_AMOUNT_THB.Value + trn2.KK_CONTRIBUTE })).ToList(); } if (trn1.TRADE_DATE.Value != trn1.MATURITY_DATE.Value) deal_conts.Add(new CountryLimitModel { EXPOSURE_DATE = trn1.TRADE_DATE.Value, EXPOSURE = trn1.KK_CONTRIBUTE.Value + trn2.KK_CONTRIBUTE.Value }); //Find original deals for exclude them from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID1)) { guExcludeID1 = Guid.Parse(strExcludeID.Replace("\"", "")); oldtrn1 = GetByID(guExcludeID1); oldtrn2 = GetDealByProcessDate(sessioninfo.Process.CurrentDate).FirstOrDefault(p => p.INT_DEAL_NO == oldtrn1.INT_DEAL_NO && p.VERSION == oldtrn1.VERSION && p.ID != oldtrn1.ID); if (oldtrn2 == null || oldtrn1 == null) throw this.CreateException(new Exception(), "Cannot find original deals."); guExcludeID1 = oldtrn1.ID; guExcludeID2 = oldtrn2.ID; } List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllCountry(sessioninfo.Process.CurrentDate, trn2, guExcludeID1, guExcludeID2); limitDisplay.LimitDisplayObject = GenerateCountryLimitDisplay(deal_conts, ori_conts, trn1, trn2, sessioninfo.CountryOverwrite, ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) { trn1.OVER_COUNTRY_AMOUNT = limitDisplay.OverAmount; trn2.OVER_COUNTRY_AMOUNT = limitDisplay.OverAmount; } } else { limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR; limitDisplay.Message = "This deal breach allowed tenor."; } return limitDisplay; }
public LimitDisplayModel CheckSwapSCE(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); InstrumentBusiness _insBusiness = new InstrumentBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); Guid guExcludeID = Guid.Empty; List<DA_TRN_CASHFLOW> deal_conts = new List<DA_TRN_CASHFLOW>(); MA_INSTRUMENT ins = _insBusiness.GetByID(sessioninfo, trn.INSTRUMENT_ID.Value); if (ins.LABEL == "CCS") { deal_conts = (from f in trn.DA_TRN_FLOW where f.FLOW_AMOUNT > 0 // Receive cash flows only select new { Flow_Date = f.FLOW_DATE, Flow_Amount_THB = f.FLOW_AMOUNT_THB }).GroupBy(fl => new { fl.Flow_Date }) .Select(p => new DA_TRN_CASHFLOW { FLOW_DATE = p.Key.Flow_Date, FLOW_AMOUNT_THB = p.Sum(x => x.Flow_Amount_THB) }).OrderBy(p => p.FLOW_DATE).ToList(); } else //Net cashflow for IRS { deal_conts = (from f in trn.DA_TRN_FLOW select new { Flow_Date = f.FLOW_DATE, Flow_ccy = f.FLAG_FIRST ? trn.FIRST.CCY_ID : trn.SECOND.CCY_ID, Flow_Amount_THB = f.FLOW_AMOUNT_THB }).GroupBy(fl => new { fl.Flow_Date, fl.Flow_ccy }) .Select(p => new DA_TRN_CASHFLOW { FLOW_DATE = p.Key.Flow_Date, FLOW_AMOUNT_THB = p.Sum(x => x.Flow_Amount_THB) }).Where(t => t.FLOW_AMOUNT_THB > 0).OrderBy(p => p.FLOW_DATE).ToList(); } //Find original deal for exclude it from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID)) guExcludeID = Guid.Parse(strExcludeID.Replace("\"", "")); List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllSET(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty); limitDisplay.LimitDisplayObject = GenerateSETDisplay(deal_conts, ori_conts, sessioninfo.SETOverwrite, ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) trn.OVER_SETTL_AMOUNT = limitDisplay.OverAmount; return limitDisplay; }
public LimitDisplayModel CheckSwapCountryLimit(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); InstrumentBusiness _insBusiness = new InstrumentBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); Guid guExcludeID = Guid.Empty; if (trn.KK_PCCF != null) { List<CountryLimitModel> deal_conts = new List<CountryLimitModel>(); MA_INSTRUMENT ins = _insBusiness.GetByID(sessioninfo, trn.INSTRUMENT_ID.Value); if (ins.LABEL == "CCS") { deal_conts = (from f in trn.DA_TRN_FLOW where f.FLOW_AMOUNT > 0 // Receive cash flows only select new { Flow_Date = f.FLOW_DATE, Flow_Amount_THB = f.FLOW_AMOUNT_THB }).GroupBy(fl => new { fl.Flow_Date }) .Select(p => new CountryLimitModel { EXPOSURE_DATE = p.Key.Flow_Date, EXPOSURE = p.Sum(x => x.Flow_Amount_THB) + trn.KK_CONTRIBUTE.Value }).OrderBy(p => p.EXPOSURE_DATE).ToList(); } else //Net cashflow for IRS { deal_conts = (from f in trn.DA_TRN_FLOW select new { Flow_Date = f.FLOW_DATE, Flow_ccy = f.FLAG_FIRST ? trn.FIRST.CCY_ID : trn.SECOND.CCY_ID, Flow_Amount_THB = f.FLOW_AMOUNT_THB }).GroupBy(fl => new { fl.Flow_Date, fl.Flow_ccy }) .Select(p => new CountryLimitModel { EXPOSURE_DATE = p.Key.Flow_Date, EXPOSURE = p.Sum(x => x.Flow_Amount_THB) + trn.KK_CONTRIBUTE.Value }).Where(t => t.EXPOSURE > 0).OrderBy(p => p.EXPOSURE_DATE).ToList(); } if (trn.TRADE_DATE.Value != trn.MATURITY_DATE.Value) deal_conts.Add(new CountryLimitModel { EXPOSURE_DATE = trn.TRADE_DATE.Value, EXPOSURE = trn.KK_CONTRIBUTE.Value }); //Find original deal for exclude it from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID)) guExcludeID = Guid.Parse(strExcludeID.Replace("\"", "")); List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllCountry(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty); limitDisplay.LimitDisplayObject = GenerateCountryLimitDisplay(deal_conts, ori_conts, trn, null, sessioninfo.CountryOverwrite, ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) trn.OVER_COUNTRY_AMOUNT = limitDisplay.OverAmount; } else { limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR; limitDisplay.Message = "This deal breach allowed tenor."; } return limitDisplay; }
public LimitDisplayModel CheckSCE(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); Guid guExcludeID = Guid.Empty; List<DA_TRN_CASHFLOW> deal_conts = (from f in trn.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new DA_TRN_CASHFLOW { FLOW_DATE = f.FLOW_DATE.Value, FLOW_AMOUNT_THB = f.FLOW_AMOUNT_THB.Value }).ToList(); //Find original deal for exclude it from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID)) guExcludeID = Guid.Parse(strExcludeID.Replace("\"", "")); List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllSET(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty); limitDisplay.LimitDisplayObject = GenerateSETDisplay(deal_conts, ori_conts, sessioninfo.SETOverwrite , ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) trn.OVER_SETTL_AMOUNT = limitDisplay.OverAmount; return limitDisplay; }
//public LimitDisplayModel CheckPCE(SessionInfo sessioninfo, DA_TRN trn) //{ // StaticDataBusiness _staticDataBusiness = new StaticDataBusiness(); // LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); // LimitDisplayModel limitDisplay = new LimitDisplayModel(); // trn.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn); // if (trn.KK_PCCF != null) // { // trn.KK_CONTRIBUTE = Math.Ceiling(trn.NOTIONAL_THB.Value * trn.KK_PCCF.Value / 100); // List<LimitCheckModel> limits = _limitCheckBusiness.GetPCEByCriteria(sessioninfo.Process.CurrentDate, trn.CTPY_ID, trn.PRODUCT_ID.Value, "", Guid.Empty, Guid.Empty); // foreach (LimitCheckModel limit in limits) // { // limit.DEAL_CONTRIBUTION = trn.KK_CONTRIBUTE.Value; // SetLimitDisplayStatus(limit, ref limitDisplay); // } // limitDisplay.LimitDisplayObject = limits; // } // else // { // limitDisplay.LimitCheckStatus = eLimitCheckStatus.NOTALLOW; // limitDisplay.LimitErrorObj = new { Result = "ERROR", Message = "This deal breach allowed tenor." }; // } // return limitDisplay; //} public LimitDisplayModel CheckPCE(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID) { StaticDataBusiness _staticDataBusiness = new StaticDataBusiness(); LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); Guid guExcludeID = Guid.Empty; trn.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn); //Find original deal for exclude it from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID)) guExcludeID = Guid.Parse(strExcludeID.Replace("\"", "")); if (trn.KK_PCCF != null) { trn.KK_CONTRIBUTE = Math.Ceiling(trn.NOTIONAL_THB.Value * trn.KK_PCCF.Value / 100); List<LimitCheckModel> limits = _limitCheckBusiness.CheckAllPCE(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty); foreach (LimitCheckModel limit in limits) { limit.DEAL_CONTRIBUTION = trn.KK_CONTRIBUTE.Value; SetLimitDisplayStatus(limit, sessioninfo.PCEOverwrite, ref limitDisplay); } if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) trn.OVER_AMOUNT = limitDisplay.OverAmount; limitDisplay.LimitDisplayObject = limits; } else { limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR; limitDisplay.Message = "This deal breach allowed tenor."; } return limitDisplay; }
public LimitDisplayModel CheckFXSwapSCE(SessionInfo sessioninfo, DA_TRN trn1, DA_TRN trn2, string strExcludeID) { LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); DA_TRN oldtrn1 = null; DA_TRN oldtrn2 = null; Guid guExcludeID1 = Guid.Empty; Guid guExcludeID2 = Guid.Empty; List<DA_TRN_CASHFLOW> deal_conts = ((from f in trn1.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new DA_TRN_CASHFLOW { FLOW_DATE = f.FLOW_DATE.Value, FLOW_AMOUNT_THB = f.FLOW_AMOUNT_THB.Value }).Union( (from f in trn2.DA_TRN_FLOW where f.FLOW_AMOUNT_THB > 0 select new DA_TRN_CASHFLOW { FLOW_DATE = f.FLOW_DATE.Value, FLOW_AMOUNT_THB = f.FLOW_AMOUNT_THB.Value }) )).ToList(); //Find original deals for exclude them from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID1)) { guExcludeID1 = Guid.Parse(strExcludeID.Replace("\"", "")); oldtrn1 = GetByID(guExcludeID1); oldtrn2 = GetDealByProcessDate(sessioninfo.Process.CurrentDate).FirstOrDefault(p => p.INT_DEAL_NO == oldtrn1.INT_DEAL_NO && p.VERSION == oldtrn1.VERSION && p.ID != oldtrn1.ID); if (oldtrn2 == null || oldtrn1 == null) throw this.CreateException(new Exception(), "Cannot find original deals."); guExcludeID1 = oldtrn1.ID; guExcludeID2 = oldtrn2.ID; } List<LimitCheckModel> ori_conts = _limitCheckBusiness.CheckAllSET(sessioninfo.Process.CurrentDate, trn1, guExcludeID1, guExcludeID2); limitDisplay.LimitDisplayObject = GenerateSETDisplay(deal_conts, ori_conts, sessioninfo.SETOverwrite, ref limitDisplay); if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) { trn1.OVER_SETTL_AMOUNT = limitDisplay.OverAmount; trn2.OVER_SETTL_AMOUNT = limitDisplay.OverAmount; } return limitDisplay; }
public LimitDisplayModel CheckFXSwapPCE(SessionInfo sessioninfo, DA_TRN trn1, DA_TRN trn2, string strExcludeID) { StaticDataBusiness _staticDataBusiness = new StaticDataBusiness(); LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness(); LimitDisplayModel limitDisplay = new LimitDisplayModel(); DA_TRN oldtrn1 = null; DA_TRN oldtrn2 = null; Guid guExcludeID1 = Guid.Empty; Guid guExcludeID2 = Guid.Empty; //Exposure include far leg only -> set near leg to 0 trn1.KK_PCCF = 0; trn2.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn2); //Find original deals for exclude them from limit calculation if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID1)) { guExcludeID1 = Guid.Parse(strExcludeID.Replace("\"", "")); oldtrn1 = GetByID(guExcludeID1); oldtrn2 = GetDealByProcessDate(sessioninfo.Process.CurrentDate).FirstOrDefault(p => p.INT_DEAL_NO == oldtrn1.INT_DEAL_NO && p.VERSION == oldtrn1.VERSION && p.ID != oldtrn1.ID); if (oldtrn2 == null || oldtrn1 == null) throw this.CreateException(new Exception(), "Cannot find original deals."); guExcludeID1 = oldtrn1.ID; guExcludeID2 = oldtrn2.ID; } if (trn1.KK_PCCF != null && trn2.KK_PCCF != null) { trn1.KK_CONTRIBUTE = 0; trn2.KK_CONTRIBUTE = Math.Ceiling(trn2.NOTIONAL_THB.Value * trn2.KK_PCCF.Value / 100); List<LimitCheckModel> limits = _limitCheckBusiness.CheckAllPCE(sessioninfo.Process.CurrentDate, trn1, guExcludeID1, guExcludeID2); foreach (LimitCheckModel limit in limits) { limit.DEAL_CONTRIBUTION = trn1.KK_CONTRIBUTE.Value + trn2.KK_CONTRIBUTE.Value; SetLimitDisplayStatus(limit, sessioninfo.PCEOverwrite, ref limitDisplay); } if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE) { trn1.OVER_AMOUNT = limitDisplay.OverAmount; trn2.OVER_AMOUNT = limitDisplay.OverAmount; } limitDisplay.LimitDisplayObject = limits; } else { limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR; limitDisplay.Message = "This deal breach allowed tenor."; } return limitDisplay; }