using AccountsDAL.CustomCode.Reports; using AccountsDAL.DTO.Reports; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.PAndLReport { // BLL for the REAL, live-wired "P and L Vertical" (MREPORT -1399985039) and "P and L Horizontal" // (MREPORT -1399975830) — see PAndLReportQB.cs's class header for the full GB4->GB5 migration // context. No paging: both reports are inherently small (Schedule/Group/Account-level rollups // for one period), matching how AccountVerticalComponent/PLxxxHorizontalComponent consume a // full result set client-side rather than a paged grid. public class PAndLReportBLL : IPAndLReportBLL { private readonly IPAndLReportDAL _dal; private readonly AccountReports.IAccountReportAccessControlBLL _accessControlBLL; public PAndLReportBLL(IPAndLReportDAL dal, AccountReports.IAccountReportAccessControlBLL accessControlBLL) { _dal = dal; _accessControlBLL = accessControlBLL; } public async Task> GetPAndLVertical(int groupType, CriteriaDTO criteriaDTO, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-pandl-vertical", new { groupType, menuId }); var criteria = AccountReports.AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); await _accessControlBLL.EnforceAsync(criteria, int.MaxValue, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-pandl-vertical", new { groupType }); return await _dal.GetPAndLVertical(groupType, criteria, loginDTO).ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("pandl-vertical-failed", ex); throw; } } public async Task> GetPAndLHorizontal(int groupType, CriteriaDTO criteriaDTO, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-pandl-horizontal", new { groupType, menuId }); var criteria = AccountReports.AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); await _accessControlBLL.EnforceAsync(criteria, int.MaxValue, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-pandl-horizontal", new { groupType }); return await _dal.GetPAndLHorizontal(groupType, criteria, loginDTO).ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("pandl-horizontal-failed", ex); throw; } } } }