예제 #1
0
        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.");
        }
예제 #2
0
        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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public void LimitCheckBusinessConstructorTest()
        {
            LimitCheckBusiness target = new LimitCheckBusiness();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }