예제 #1
0
        /// <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 };
            }
        }
예제 #2
0
 public static DA_TRN GetByID(Guid id)
 {
     DealBusiness _dealBusiness = new DealBusiness();
         return _dealBusiness.GetByID(id);
 }
예제 #3
0
        /// <summary>
        /// Cancel deal by ID
        /// </summary>
        /// <param name="sessioninfo"></param>
        /// <param name="DMKDealID"></param>
        /// <returns></returns>
        public static object CancellingDeal(SessionInfo sessioninfo, Guid DMKDealID)
        {
            ReconcileBusiness _reconcileBusiness = new ReconcileBusiness();
            DealBusiness _dealBusiness = new DealBusiness();
            List<DealTranModel> DealTrans = new List<DealTranModel>();
            DA_TRN deal = null;
            DA_TRN deal2 = null;
            List<DA_TRN> dealExts = null;
            string extdealno = string.Empty;
            try
            {
                LoggingHelper.Debug("Cancelling deal");
                //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) };

                if (deal.MA_PRODUCT.LABEL.Replace(" ", string.Empty) == ProductCode.FXSWAP.ToString())
                    deal2 = _dealBusiness.GetDealByProcessDate(sessioninfo.Process.CurrentDate).FirstOrDefault(p => p.INT_DEAL_NO == deal.INT_DEAL_NO && p.VERSION == deal.VERSION && p.ID != deal.ID);

                if (deal.MA_PRODUCT.LABEL.Replace(" ", string.Empty) == ProductCode.FXSWAP.ToString() && deal2 == null)
                    return new { Result = "ERROR", Message = String.Format("Deal {0} is not found.", deal.INT_DEAL_NO) };

                dealExts = _dealBusiness.GetByExternalByInternalDealNo(sessioninfo.Process.NextDate, deal.INT_DEAL_NO);
                if (dealExts == null)
                    return new { Result = "ERROR", Message = String.Format("OPICS Deal is not found.") };

               // extdealno = deal.EXT_DEAL_NO;

                deal.EXT_DEAL_NO = null;
                deal.EXT_PORTFOLIO = null;
                deal.STATUS_ID = _lookupvaluesRepository.StatusRepository.GetByLabel(StatusCode.OPEN.ToString()).ID;
                deal.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                deal.LOG.MODIFYDATE = DateTime.Now;
                deal.INSERT_BY_EXT = null;
                DealTrans.Add(new DealTranModel() { ProductTransaction = (ProductCode)Enum.Parse(typeof(ProductCode), deal.MA_PRODUCT.LABEL.Replace(" ","")), Transaction = deal, UpdateStates = UpdateStates.Editing });

                if (deal2 != null)
                {
                    deal2.EXT_DEAL_NO = null;
                    deal2.EXT_PORTFOLIO = null;
                    deal2.STATUS_ID = _lookupvaluesRepository.StatusRepository.GetByLabel(StatusCode.OPEN.ToString()).ID;
                    deal2.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                    deal2.LOG.MODIFYDATE = DateTime.Now;
                    deal2.INSERT_BY_EXT = null;
                    DealTrans.Add(new DealTranModel() { ProductTransaction = (ProductCode)Enum.Parse(typeof(ProductCode), deal2.MA_PRODUCT.LABEL.Replace(" ", "")), Transaction = deal2, UpdateStates = UpdateStates.Editing });
                }

                foreach (DA_TRN dealExt in dealExts)
                {
                    DealTrans.Add(new DealTranModel() { ProductTransaction = (ProductCode)Enum.Parse(typeof(ProductCode), dealExt.MA_PRODUCT.LABEL.Replace(" ", "")), Transaction = dealExt, UpdateStates = UpdateStates.Deleting });
                }

                _reconcileBusiness.UpdateDealReconcile(sessioninfo, DealTrans);

                LoggingHelper.Debug("End Cancelling deal");
                return new
                {
                    Result = "OK",
                    Message = String.Format("Process cancel the deal between DMK Deal no {0} and OPICS Deal no {1} completed", deal.INT_DEAL_NO, extdealno)
                };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }