public List<LimitCheckModel> GetSCEReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strSource, string strStatus) { try { DateTime dteReport; LimitCheckBusiness _limitBusiness = new LimitCheckBusiness(); DealBusiness _dealBusiness = new DealBusiness(); CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness(); 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 (_dealBusiness.CountByProcessDate(dteReport) == 0) { throw this.CreateException(new Exception(), "No data for selected report date."); } if (Guid.TryParse(strCtpy, out guCtpyID)) { guCtpyID = Guid.Parse(strCtpy); } var limits = _limitBusiness.GetSCEByCriteria(dteReport, guCtpyID, Guid.Empty, strSource, Guid.Empty, Guid.Empty) .OrderBy(p => p.SNAME).ThenBy(p => p.FLOW_DATE) .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, limit.FLOW_DATE, limit.CTPY_LIMIT_ID); if (temp_limit != null) limit.TEMP_AMOUNT = temp_limit.AMOUNT; } 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 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); } }
public List<DA_TRN_CASHFLOW> GetSCEDetailReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strProduct, string strSource) { try { DateTime dteReport; DealBusiness _dealBusiness = new DealBusiness(); Guid guTemp; 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."); } var cashflows = _dealBusiness.GetFlowsByProcessDate(dteReport).AsQueryable(); if (!string.IsNullOrEmpty(strSource)) { cashflows = cashflows.Where(p => p.DA_TRN.SOURCE == strSource); } if (Guid.TryParse(strCtpy, out guTemp)) { cashflows = cashflows.Where(p => p.DA_TRN.CTPY_ID == Guid.Parse(strCtpy)); } if (Guid.TryParse(strProduct, out guTemp)) { cashflows = cashflows.Where(p => p.DA_TRN.PRODUCT_ID == Guid.Parse(strProduct)); } return cashflows.OrderBy(p => p.DA_TRN.INT_DEAL_NO).ThenByDescending(p => p.FLAG_FIRST).ThenBy(p => p.SEQ).ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }
public List<DA_TRN> GetPCEDetailReport(SessionInfo sessioninfo, string strReportDate, string strCtpy, string strProduct, string strSource) { try { DateTime dteReport; DealBusiness _dealBusiness = new DealBusiness(); Guid guTemp; 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."); } var trns = _dealBusiness.GetDealByProcessDate(dteReport).Where(p => p.MA_STATUS.LABEL.ToString() != StatusCode.CANCELLED.ToString()).AsQueryable(); if (!string.IsNullOrEmpty(strSource)) { trns = trns.Where(p => p.SOURCE == strSource); } if (Guid.TryParse(strCtpy, out guTemp)) { trns = trns.Where(t => t.CTPY_ID == Guid.Parse(strCtpy)); } if (Guid.TryParse(strProduct, out guTemp)) { trns = trns.Where(s => s.PRODUCT_ID == Guid.Parse(strProduct)); } return trns.ToList(); } catch (DataServicesException ex) { throw this.CreateException(ex, null); } }