public List <LimitCheckModel> CheckAllSET(DateTime ProcessingDate, DA_TRN trn, Guid ExcludeID1, Guid ExcludeID2) { CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); List <LimitCheckModel> results = GetSCEByCriteria(ProcessingDate, trn.CTPY_ID, trn.PRODUCT_ID.Value, "", ExcludeID1, ExcludeID2); //Get group exposure MA_COUTERPARTY ctpy = _counterpartyBusiness.GetCounterpartyAll().FirstOrDefault(p => p.ID == trn.CTPY_ID); if (ctpy != null && ctpy.GROUP_CTPY_ID != null) { var group = GetSCEByCriteria(ProcessingDate, ctpy.GROUP_CTPY_ID.Value, trn.PRODUCT_ID.Value, "", ExcludeID1, ExcludeID2); results = results.Union(group).ToList(); } //Get temp limit //Look for temp limit when all conditions meet // 1. Transaction maturity date <= Temp limit maturity date foreach (LimitCheckModel result in results) { MA_TEMP_CTPY_LIMIT temp_limit = _counterpartyBusiness.GetActiveTempByID(ProcessingDate, trn.MATURITY_DATE.Value, result.CTPY_LIMIT_ID); if (temp_limit != null) { result.TEMP_AMOUNT = temp_limit.AMOUNT; } //result.AMOUNT = result.AMOUNT + temp_limit.AMOUNT; } return(results); }
public MA_TEMP_CTPY_LIMIT UpdateTempLimit(SessionInfo sessioninfo, MA_TEMP_CTPY_LIMIT record) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Effective date cannot be set to past date."); } if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Expiry date cannot be set to past date."); } if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE) { throw this.CreateException(new Exception(), "Expiry date must be after effective date."); } var duplicate = unitOfWork.MA_TEMP_CTPY_LIMITRepository.All().FirstOrDefault(p => p.CTPY_LIMIT_ID == record.CTPY_LIMIT_ID && p.ISACTIVE == true && p.ID != record.ID && p.EXPIRY_DATE >= record.EFFECTIVE_DATE); if (duplicate != null) { throw this.CreateException(new Exception(), "Duplicate temp limit info"); } var foundData = unitOfWork.MA_TEMP_CTPY_LIMITRepository.GetAll().FirstOrDefault(p => p.ID == record.ID); if (foundData == null) { throw this.CreateException(new Exception(), "Data not found!"); } else { LogBusiness logBusiness = new LogBusiness(); var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = foundData.EFFECTIVE_DATE, EXPIRY_DATE = foundData.EXPIRY_DATE, ISACTIVE = foundData.ISACTIVE }; var newRecord = new { AMOUNT = record.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE, ISACTIVE = record.ISACTIVE }; var log = logBusiness.UpdateLogging(sessioninfo, foundData.CTPY_LIMIT_ID, LimitLogEvent.TEMP_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_TEMP_CTPY_LIMIT, oldRecord, newRecord, "Temp Limit"); if (log != null) { unitOfWork.DA_LOGGINGRepository.Add(log); } foundData.AMOUNT = record.AMOUNT; foundData.CTPY_LIMIT_ID = record.CTPY_LIMIT_ID; foundData.EFFECTIVE_DATE = record.EFFECTIVE_DATE; foundData.EXPIRY_DATE = record.EXPIRY_DATE; foundData.ISACTIVE = record.ISACTIVE; foundData.LOG.MODIFYBYUSERID = record.LOG.MODIFYBYUSERID; foundData.LOG.MODIFYDATE = DateTime.Now; unitOfWork.Commit(); } } return(record); }
public MA_TEMP_CTPY_LIMIT GetActiveTempByID(DateTime ProcessingDate, DateTime MaturityDate, Guid ID) { MA_TEMP_CTPY_LIMIT temp_limit = null; using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { temp_limit = unitOfWork.MA_TEMP_CTPY_LIMITRepository.GetAll().FirstOrDefault(p => p.ISACTIVE == true && p.CTPY_LIMIT_ID == ID && p.EFFECTIVE_DATE <= ProcessingDate && p.EXPIRY_DATE >= MaturityDate); } return(temp_limit); }
public static object UpdateTempLimit(SessionInfo sessioninfo, MA_TEMP_CTPY_LIMIT record) { try { CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE ? false : true; record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId; record.LOG.MODIFYDATE = DateTime.Now; var addedRecord = _counterpartyBusiness.UpdateTempLimit(sessioninfo, record); return(new { Result = "OK" }); } catch (Exception ex) { return(new { Result = "ERROR", Message = ex.Message }); } }
public MA_TEMP_CTPY_LIMIT CreateTempLimit(SessionInfo sessioninfo, MA_TEMP_CTPY_LIMIT record) { using (EFUnitOfWork unitOfWork = new EFUnitOfWork()) { if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Effective date cannot be set to past date."); } if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate) { throw this.CreateException(new Exception(), "Expiry date cannot be set to past date."); } if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE) { throw this.CreateException(new Exception(), "Expiry date must be after effective date."); } var duplicate = unitOfWork.MA_TEMP_CTPY_LIMITRepository.All().FirstOrDefault(p => p.CTPY_LIMIT_ID == record.CTPY_LIMIT_ID && p.ISACTIVE == true && p.EXPIRY_DATE >= record.EFFECTIVE_DATE); if (duplicate != null) { throw this.CreateException(new Exception(), "Duplicate temp limit info"); } LogBusiness logBusiness = new LogBusiness(); var newRecord = new { AMOUNT = record.AMOUNT, EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE }; unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, record.CTPY_LIMIT_ID, LimitLogEvent.TEMP_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_TEMP_CTPY_LIMIT, "Temp Limit", newRecord)); unitOfWork.MA_TEMP_CTPY_LIMITRepository.Add(record); unitOfWork.Commit(); } return(record); }
public List <LimitCheckModel> GetPCEReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strLimit, string strSource, string strStatus) { try { DateTime dteReport; LimitCheckBusiness _limitBusiness = new LimitCheckBusiness(); DealBusiness _dealBusiness = new DealBusiness(); CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); Guid guCtpyID = Guid.Empty; Guid guLimitID = 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); } if (_dealBusiness.CountByProcessDate(dteReport) == 0) { throw this.CreateException(new Exception(), "No data for selected report date."); } var limits = _limitBusiness.GetPCEByCriteria(dteReport, guCtpyID, Guid.Empty, strSource, Guid.Empty, Guid.Empty).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, sessioninfo.Process.CurrentDate, limit.CTPY_LIMIT_ID); if (temp_limit != null) { limit.TEMP_AMOUNT = temp_limit.AMOUNT; } } //Additional filter on limit name if (Guid.TryParse(strLimit, out guLimitID)) { LookupBusiness _lookupBusiness = new LookupBusiness(); MA_LIMIT limit = _lookupBusiness.GetLimitAll().FirstOrDefault(t => t.ID == Guid.Parse(strLimit)); limits = limits.Where(t => t.LIMIT_LABEL.IndexOf(limit.LABEL, StringComparison.OrdinalIgnoreCase) >= 0); } 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 static object Update(MA_TEMP_CTPY_LIMIT record) { return(CounterpartyUIP.UpdateTempLimit(SessionInfo, record)); }