Exemplo n.º 1
0
 public static object GetConfigByFilter(SessionInfo sessioninfo, string name, int jtStartIndex, int jtPageSize, string jtSorting)
 {
     try
     {
         LoggingHelper.Debug("Begin Get config by " + name);
         //Return result to jTable
         PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
         //Get data from database
         List <MA_PCCF_CONFIG> factors = _factorBusiness.GetConfigByFilter(sessioninfo, name, jtSorting);
         LoggingHelper.Debug("End Get config");
         //Return result to jTable
         return(new
         {
             Result = "OK"
             ,
             Records = jtPageSize > 0 ? factors.Skip(jtStartIndex).Take(jtPageSize).ToList() : factors
             ,
             TotalRecordCount = factors.Count
         });
     }
     catch (BusinessWorkflowsException bex)
     {
         return(new { Result = "ERROR", Message = bex.Message });
     }
     catch (Exception ex)
     {
         return(new { Result = "ERROR", Message = ex.Message });
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            PCCFConfigBusiness pccfBusiness = new PCCFConfigBusiness();

            DA_TRN record = new DA_TRN();

            record.ID                 = Guid.NewGuid();
            record.ENGINE_DATE        = DateTime.Now;
            record.STATUS_ID          = new Guid("9161ED18-1298-44FA-BA7D-34522CB40D66");
            record.INSTRUMENT_ID      = new Guid("33F88EB3-46C0-4667-BCF6-05426321B71B");
            record.PRODUCT_ID         = new Guid("F85252D1-BC58-4AC6-8B56-2E228FB0A367");
            record.LOG.INSERTBYUSERID = new Guid("F85252D1-BC58-4AC6-8B56-2E228FB0A367");
            record.LOG.INSERTDATE     = DateTime.Now;

            record.FIRST.CCY_ID       = new Guid("825F343B-CAEA-409B-AE92-CCA2DAB3765E");
            record.FIRST.FLAG_PAYREC  = "R";
            record.FIRST.FLAG_FIXED   = false;
            record.SECOND.CCY_ID      = new Guid("825F343B-CAEA-409B-AE92-CCA2DAB3765E");
            record.SECOND.FLAG_PAYREC = "P";
            record.SECOND.FLAG_FIXED  = false;

            var temp = pccfBusiness.ValidatePCCFConfig(null, record);

            if (temp != null)
            {
                Console.WriteLine("PCCF:" + temp.LABEL);
            }
            else
            {
                Console.WriteLine("PCCF is not match");
            }
            Console.WriteLine("End");
            Console.ReadLine();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            PCCFConfigBusiness pccfBusiness = new PCCFConfigBusiness();

            DA_TRN record = new DA_TRN();
            record.ID = Guid.NewGuid();
            record.ENGINE_DATE = DateTime.Now;
            record.STATUS_ID = new Guid("9161ED18-1298-44FA-BA7D-34522CB40D66");
            record.INSTRUMENT_ID = new Guid("33F88EB3-46C0-4667-BCF6-05426321B71B");
            record.PRODUCT_ID = new Guid("F85252D1-BC58-4AC6-8B56-2E228FB0A367");
            record.LOG.INSERTBYUSERID = new Guid("F85252D1-BC58-4AC6-8B56-2E228FB0A367");
            record.LOG.INSERTDATE = DateTime.Now;

            record.FIRST.CCY_ID = new Guid("825F343B-CAEA-409B-AE92-CCA2DAB3765E");
            record.FIRST.FLAG_PAYREC = "R";
            record.FIRST.FLAG_FIXED = false;
            record.SECOND.CCY_ID = new Guid("825F343B-CAEA-409B-AE92-CCA2DAB3765E");
            record.SECOND.FLAG_PAYREC = "P";
            record.SECOND.FLAG_FIXED = false ;

            var temp = pccfBusiness.ValidatePCCFConfig(null, record);
            if(temp!=null)
                Console.WriteLine("PCCF:" + temp.LABEL);
            else
                Console.WriteLine("PCCF is not match");
            Console.WriteLine("End");
            Console.ReadLine();
        }
Exemplo n.º 4
0
        public static object UpdateFactor(SessionInfo sessioninfo, MA_CONFIG_ATTRIBUTE record)
        {
            try
            {
                LoggingHelper.Debug("Update Factor by " + record.ATTRIBUTE);

                PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
                record.ISACTIVE           = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;
                var updated = _factorBusiness.UpdateFactor(sessioninfo, record);
                LoggingHelper.Debug("End Update");
                return(new { Result = "OK" });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemplo n.º 5
0
        public static object CreateFactor(SessionInfo sessioninfo, MA_CONFIG_ATTRIBUTE record)
        {
            try
            {
                LoggingHelper.Debug("Create Factor by " + record.ATTRIBUTE);

                PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
                record.ID                 = Guid.NewGuid();
                record.ISACTIVE           = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
                record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.INSERTDATE     = DateTime.Now;

                LoggingHelper.Debug("End Create");
                var added = _factorBusiness.CreateFactor(sessioninfo, record);
                return(new { Result = "OK", Record = added });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemplo n.º 6
0
        public static object UpdateConfig(SessionInfo sessioninfo, MA_PCCF_CONFIG record)
        {
            try
            {
                LoggingHelper.Debug("Update Config by " + record.LABEL);

                PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
                record.ISACTIVE           = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true;
                record.LABEL              = record.LABEL.ToUpper();
                record.DESCRIPTION        = record.DESCRIPTION.ToUpper();
                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;
                var updated = _factorBusiness.UpdateConfig(sessioninfo, record);
                LoggingHelper.Debug("End Update");
                return(new { Result = "OK" });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemplo n.º 7
0
 public static object GetFactorByFilter(SessionInfo sessioninfo, Guid ID)
 {
     try
     {
         LoggingHelper.Debug("Begin Get Factor by " + ID);
         //Return result to jTable
         PCCFConfigBusiness _factorBusiness = new PCCFConfigBusiness();
         //Get data from database
         List <MA_CONFIG_ATTRIBUTE> factors = _factorBusiness.GetFactorByFilter(sessioninfo, ID);
         LoggingHelper.Debug("End Get Factor");
         //Return result to jTable
         return(new { Result = "OK", Records = factors, TotalRecordCount = factors.Count });
     }
     catch (BusinessWorkflowsException bex)
     {
         return(new { Result = "ERROR", Message = bex.Message });
     }
     catch (Exception ex)
     {
         return(new { Result = "ERROR", Message = ex.Message });
     }
 }
Exemplo n.º 8
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.º 9
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);
            }
        }