Exemplo n.º 1
0
        public void UpdatePCCF(SessionInfo sessioninfo, MA_PCCF pccf)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCFRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(pccf.LABEL.ToLower()) && p.ID != pccf.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                var foundPCCF = unitOfWork.MA_PCCFRepository.All().FirstOrDefault(p => p.ID == pccf.ID);
                if (foundPCCF == null)
                {
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                }
                else
                {
                    foundPCCF.LABEL              = pccf.LABEL;
                    foundPCCF.C1                 = pccf.C1;
                    foundPCCF.C2                 = pccf.C2;
                    foundPCCF.C3                 = pccf.C3;
                    foundPCCF.C4                 = pccf.C4;
                    foundPCCF.C5                 = pccf.C5;
                    foundPCCF.C6                 = pccf.C6;
                    foundPCCF.C7                 = pccf.C7;
                    foundPCCF.C8                 = pccf.C8;
                    foundPCCF.C9                 = pccf.C9;
                    foundPCCF.C10                = pccf.C10;
                    foundPCCF.C11                = pccf.C11;
                    foundPCCF.C12                = pccf.C12;
                    foundPCCF.C13                = pccf.C13;
                    foundPCCF.C14                = pccf.C14;
                    foundPCCF.C15                = pccf.C15;
                    foundPCCF.C16                = pccf.C16;
                    foundPCCF.C17                = pccf.C17;
                    foundPCCF.C18                = pccf.C18;
                    foundPCCF.C19                = pccf.C19;
                    foundPCCF.C20                = pccf.C20;
                    foundPCCF.C1D                = pccf.C1D;
                    foundPCCF.C0D                = pccf.C0D;
                    foundPCCF.C21                = pccf.C21;
                    foundPCCF.C22                = pccf.C22;
                    foundPCCF.C23                = pccf.C23;
                    foundPCCF.C24                = pccf.C24;
                    foundPCCF.DEFAULT            = pccf.DEFAULT;
                    foundPCCF.more20             = pccf.more20;
                    foundPCCF.ISACTIVE           = pccf.ISACTIVE;
                    foundPCCF.LOG.MODIFYBYUSERID = pccf.LOG.MODIFYBYUSERID;
                    foundPCCF.LOG.MODIFYDATE     = pccf.LOG.MODIFYDATE;
                    unitOfWork.Commit();
                }
            }
        }
Exemplo n.º 2
0
 public MA_PCCF GetPCCFByLabelProduct(SessionInfo sessioninfo, string strLabel, Guid GuProduct)
 {
     try
     {
         MA_PCCF pccf = null;
         using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
         {
             pccf = unitOfWork.MA_PCCFRepository.GetByLabelProduct(strLabel, GuProduct);
         }
         return(pccf);
     }
     catch (DataServicesException ex)
     {
         throw this.CreateException(ex, null);
     }
 }
Exemplo n.º 3
0
        public MA_PCCF CreatePCCF(SessionInfo sessioninfo, MA_PCCF pccf)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCFRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(pccf.LABEL.ToLower()));
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                unitOfWork.MA_PCCFRepository.Add(pccf);
                unitOfWork.Commit();
            }

            return(pccf);
        }
Exemplo n.º 4
0
        public static object GetPCCFFXSpotByLabel(SessionInfo sessioninfo, string CCYPairLabel)
        {
            StaticDataBusiness _staticBusiness = new StaticDataBusiness();
            LookupBusiness     _lookupBusiness = new LookupBusiness();
            var     productID = _lookupBusiness.GetProductAll().FirstOrDefault(p => p.LABEL.Replace(" ", string.Empty) == ProductCode.FXSPOT.ToString()).ID;
            MA_PCCF pccf      = _staticBusiness.GetPCCFByLabelProduct(sessioninfo, CCYPairLabel, productID);

            if (pccf != null)
            {
                return(null);// new { CURRENCY1 = pccf.MA_CURRENCY1.LABEL, CURRENCY2 = pccf.MA_CURRENCY2.LABEL, CURRENCYID1 = pccf.MA_CURRENCY1.ID, CURRENCYID2 = pccf.MA_CURRENCY2.ID, FLAG_MULTIPLY = pccf.FLAG_MULTIPLY };
            }
            else
            {
                throw new Exception("Invalid currency pair.");
            }
        }
Exemplo n.º 5
0
        public MA_PCCF GetPCCFByID(SessionInfo sessioninfo, Guid guID)
        {
            try
            {
                MA_PCCF pccf = null;

                using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
                {
                    pccf = unitOfWork.MA_PCCFRepository.GetAll().FirstOrDefault(p => p.ID == guID);
                }

                return(pccf);
            }
            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Exemplo n.º 6
0
        public static object Update(SessionInfo sessioninfo, MA_PCCF record)
        {
            try
            {
                StaticDataBusiness _staticBusiness = new StaticDataBusiness();

                //record.FLAG_MULTIPLY = record.FLAG_MULTIPLY == null || !record.FLAG_MULTIPLY.Value ? false : true;
                record.LABEL = record.LABEL.ToUpper();
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;
                _staticBusiness.UpdatePCCF(sessioninfo, record);

                return(new { Result = "OK", Record = record });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemplo n.º 7
0
        public MA_PCCF ValidatePCCFConfig(SessionInfo sessioninfo, DA_TRN record)
        {
            MA_PCCF val = null;
            bool    blnResult;

            //enter conditions
            LoggingHelper.Debug("Begin validate PCCF from config");
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var props   = record.GetType().GetProperties();
                var configs = unitOfWork.MA_PCCF_CONFIGRepository.GetAll()
                              .Where(p => p.PRODUCT_ID.Equals(record.PRODUCT_ID))
                              .OrderBy(p => p.PRIORITY);

                //bool isBond = string.Compare(unitOfWork.MA_PRODUCTRepository.GetById(record.PRODUCT_ID.Value).LABEL, ProductCode.BOND.ToString(), true) == 0;

                if (configs != null)
                {
                    List <bool> ismatchs = new List <bool>();
                    object      obj;
                    foreach (MA_PCCF_CONFIG p in configs.ToList())
                    {
                        ismatchs.Clear();
                        blnResult = false;

                        //List<MA_CONFIG_ATTRIBUTE> atts = unitOfWork.MA_CONFIG_ATTRIBUTERepository.All().Where(t => t.PCCF_CONFIG_ID == p.ID && t.ISACTIVE == true).ToList() ;

                        foreach (MA_CONFIG_ATTRIBUTE ca in p.MA_CONFIG_ATTRIBUTE.Where(t => t.ISACTIVE == true).ToList())
                        {
                            //Fix for Tables
                            switch (ca.TABLE)
                            {
                            case "DA_TRN":
                                var sel = props.FirstOrDefault(t => t.Name.Equals(ca.ATTRIBUTE));
                                if (sel != null)
                                {
                                    if (sel.GetValue(record, null).GetType() == typeof(Guid))
                                    {
                                        switch (ca.ATTRIBUTE)
                                        {
                                        //Fix for fields
                                        case "INSTRUMENT_ID":
                                            obj = new MA_INSTRUMENT();
                                            obj = unitOfWork.MA_INSTRUMENTRepository.GetByIDWithOutInclude(new Guid(sel.GetValue(record, null).ToString()));

                                            blnResult = ((MA_INSTRUMENT)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                            //ismatchs.Add(blnResult);

                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                    else if (sel.GetValue(record, null).GetType() == typeof(Boolean))
                                    {
                                        blnResult = sel.GetValue(record, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(fsel.GetValue(record.FIRST, null).Equals(ca.VALUE=="0" ? false : true));
                                    }
                                    else
                                    {
                                        blnResult = sel.GetValue(record, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                        //ismatchs.Add(blnResult);
                                    }
                                }
                                break;

                            case "BOND_MARKET":
                                MA_INSTRUMENT insMkt = unitOfWork.MA_INSTRUMENTRepository.GetByIDWithInsMarket(record.INSTRUMENT_ID.Value);

                                if (insMkt.MA_BOND_MARKET != null)
                                {
                                    blnResult = insMkt.MA_BOND_MARKET.LABEL.Equals(ca.VALUE);
                                    //ismatchs.Add(blnResult);
                                }
                                //else
                                //ismatchs.Add(false);

                                break;

                            case "FIRST":
                                var fsel = record.FIRST.GetType().GetProperties().FirstOrDefault(f => f.Name.Equals(ca.ATTRIBUTE));
                                if (fsel != null)
                                {
                                    if (fsel.GetValue(record.FIRST, null) != null)
                                    {
                                        if (fsel.GetValue(record.FIRST, null).GetType() == typeof(Guid))
                                        {
                                            switch (ca.ATTRIBUTE)
                                            {
                                            //Fix for fields
                                            case "CCY_ID":
                                                obj = new MA_CURRENCY();
                                                obj = unitOfWork.MA_CURRENCYRepository.GetByID(new Guid(fsel.GetValue(record.FIRST, null).ToString()));

                                                blnResult = ((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                                //ismatchs.Add();

                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        else if (fsel.GetValue(record.FIRST, null).GetType() == typeof(Boolean))
                                        {
                                            blnResult = fsel.GetValue(record.FIRST, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(fsel.GetValue(record.FIRST, null).Equals(ca.VALUE=="0" ? false : true));
                                        }
                                        else
                                        {
                                            blnResult = fsel.GetValue(record.FIRST, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);     //ismatchs.Add(fsel.GetValue(record.FIRST, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));
                                        }
                                    }
                                    //else ismatchs.Add(false);
                                }
                                break;

                            case "SECOND":
                                //var secprop = props.FirstOrDefault(f => f.Name.Equals("SECOND"));
                                var ssel = record.SECOND.GetType().GetProperties().FirstOrDefault(f => f.Name.Equals(ca.ATTRIBUTE));
                                if (ssel != null)
                                {
                                    if (ssel.GetValue(record.SECOND, null) != null)
                                    {
                                        if (ssel.GetValue(record.SECOND, null).GetType() == typeof(Guid))
                                        {
                                            switch (ca.ATTRIBUTE)
                                            {
                                            //Fix for fields
                                            case "CCY_ID":
                                                obj = new MA_CURRENCY();
                                                obj = unitOfWork.MA_CURRENCYRepository.GetByID(new Guid(ssel.GetValue(record.SECOND, null).ToString()));

                                                blnResult = ((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                                //ismatchs.Add(((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));

                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        else if (ssel.GetValue(record.SECOND, null).GetType() == typeof(Boolean))
                                        {
                                            blnResult = ssel.GetValue(record.SECOND, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(ssel.GetValue(record.SECOND, null).Equals(ca.VALUE == "0" ? false : true));
                                        }
                                        else
                                        {
                                            blnResult = ssel.GetValue(record.SECOND, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);    // ismatchs.Add(ssel.GetValue(record.SECOND, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));
                                        }
                                    }
                                    //else ismatchs.Add(false);
                                }
                                break;

                            case "COUNTERPARTY":
                                MA_COUTERPARTY ctpy = unitOfWork.MA_COUTERPARTYRepository.GetAll().FirstOrDefault(z => z.ID == record.CTPY_ID);

                                switch (ca.ATTRIBUTE)
                                {
                                case "SNAME":
                                    blnResult = ctpy.SNAME.ToUpper() == ca.VALUE.ToUpper();

                                    break;

                                case "CSA_TYPE":

                                    MA_CSA_AGREEMENT csa = unitOfWork.MA_CSA_AGREEMENTRepository.GetAll().FirstOrDefault(y => y.ID == record.CTPY_ID);

                                    if (csa != null &&
                                        csa.MA_CSA_TYPE.LABEL.ToUpper() == ca.VALUE.ToUpper() &&
                                        csa.MA_CSA_PRODUCT.FirstOrDefault(y => y.PRODUCT_ID == record.PRODUCT_ID) != null)
                                    {
                                        blnResult = true;
                                    }
                                    //else if (csa == null && ca.VALUE == "")
                                    //    blnResult = true;
                                    else
                                    {
                                        blnResult = false;
                                    }

                                    break;

                                default:
                                    break;
                                }

                                break;
                            }

                            ismatchs.Add(blnResult);

                            //Check result -> if false then go to next config
                            if (!blnResult)
                            {
                                break;
                            }
                        }

                        if (ismatchs.Where(m => m.Equals(false)).Count() == 0)
                        {
                            val = unitOfWork.MA_PCCFRepository.GetByID(p.PCCF_ID);
                            LoggingHelper.Debug("PCCF: " + val.LABEL);
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    val = null;
                }
            }
            LoggingHelper.Debug("End validate PCCF from config");
            return(val);
        }
Exemplo n.º 8
0
        public static decimal?GetPCCFValue(MA_PCCF pccf, string strBucket)
        {
            switch (strBucket)
            {
            case "1":
                return(pccf.C1);

            case "2":
                return(pccf.C2);

            case "3":
                return(pccf.C3);

            case "4":
                return(pccf.C4);

            case "5":
                return(pccf.C5);

            case "6":
                return(pccf.C6);

            case "7":
                return(pccf.C7);

            case "8":
                return(pccf.C8);

            case "9":
                return(pccf.C9);

            case "10":
                return(pccf.C10);

            case "11":
                return(pccf.C11);

            case "12":
                return(pccf.C12);

            case "13":
                return(pccf.C13);

            case "14":
                return(pccf.C14);

            case "15":
                return(pccf.C15);

            case "16":
                return(pccf.C16);

            case "17":
                return(pccf.C17);

            case "18":
                return(pccf.C18);

            case "19":
                return(pccf.C19);

            case "20":
                return(pccf.C20);

            case "21":
                return(pccf.C21);

            case "22":
                return(pccf.C22);

            case "23":
                return(pccf.C23);

            case "24":
                return(pccf.C24);

            case ">20":
                return(pccf.more20);

            default:
                return(null);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        public decimal?GetPCCF(SessionInfo sessioninfo, DA_TRN trn)
        {
            try
            {
                decimal?           decPCCF         = null;
                LookupBusiness     _lookupBusiness = new LookupBusiness();
                PCCFConfigBusiness _pccfBusiness   = new PCCFConfigBusiness();

                MA_PRODUCT  product  = _lookupBusiness.GetProductByID(sessioninfo, trn.PRODUCT_ID.Value);
                ProductCode nProduct = (ProductCode)Enum.Parse(typeof(ProductCode), product.LABEL.Replace(" ", string.Empty));

                MA_PCCF pccf = _pccfBusiness.ValidatePCCFConfig(sessioninfo, trn);

                //if (pccf == null)
                //    throw this.CreateException(new Exception(), "Cannot find PCCF for transaction #" + trn.EXT_DEAL_NO);

                if (nProduct == ProductCode.BOND || nProduct == ProductCode.REPO)
                {
                    InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();

                    //------Check whether seleted bond can be used.---------
                    MA_INSTRUMENT ins = _instrumentBusiness.GetByID(sessioninfo, trn.INSTRUMENT_ID.Value);

                    if (trn.MATURITY_DATE >= ins.MATURITY_DATE)
                    {
                        throw this.CreateException(new Exception(), "Settlement date cannot be equal or after bond maturity date.");
                    }

                    if (pccf == null)
                    {
                        throw this.CreateException(new Exception(), "Selected instrument cannot be used.");
                    }
                    //-------------------------------------------------------

                    decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetYearBucket(trn.START_DATE.Value, ins.MATURITY_DATE.Value));
                }
                else
                {
                    if (pccf == null)
                    {
                        throw this.CreateException(new Exception(), "PCCF is not defined in the system." + "RF");
                    }

                    if (nProduct == ProductCode.SWAP)
                    {
                        decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetYearBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                    }
                    else if (nProduct == ProductCode.FXSPOT)
                    {
                        decPCCF = pccf.DEFAULT;
                    }
                    else if (nProduct == ProductCode.FXFORWARD)
                    {
                        decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetMonthBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                    }
                    else if (nProduct == ProductCode.FXSWAP)
                    {
                        if (trn.TRADE_DATE == trn.MATURITY_DATE)
                        {
                            decPCCF = pccf.C0D;
                        }
                        else if (trn.MATURITY_DATE < trn.SPOT_DATE)
                        {
                            decPCCF = pccf.C1D;
                        }
                        else if (trn.MATURITY_DATE == trn.SPOT_DATE)
                        {
                            decPCCF = pccf.DEFAULT;
                        }
                        else
                        {
                            decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetMonthBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                        }
                    }
                }

                return(decPCCF);
            }
            catch (Exception ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Exemplo n.º 11
0
 public static object UpdatePCCF(MA_PCCF record)
 {
     return(PCCFUIP.Update(SessionInfo, record));
 }