using AccountsDAL.CustomCode.AccountReports.AccountProfitLossDashboard; using AccountsDAL.DTO.AccountsReports; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.AccountProfitLossDashboard { public class AccountProfitLossDashboardBLL : IAccountProfitLossDashboardBLL { private readonly IAccountProfitLossDashboardDAL _dal; public AccountProfitLossDashboardBLL(IAccountProfitLossDashboardDAL dal) { _dal = dal; } // Deliberately does not call AccountReportAccessControlBLL.EnforceAsync — same reasoning // as RatioAnalysisReportBLL: this report is sourced from the already-posted FFINANCE fact // table, not TVOUCHER/DynamicFilter, so the TVOUCHER-family access-control helper doesn't // apply. OU access is enforced directly in the DAL (accessible-OU intersection). public async Task GetProfitLossDashboard( DateTime fromDate, DateTime toDate, byte periodType, List? ouIds, int ouGroupId, LoginDTO loginDTO, CancellationToken ct) { if (fromDate == default || toDate == default) throw new InvalidOperationException("A from date and to date are required for this report."); if (fromDate > toDate) throw new InvalidOperationException("A from date and to date are required for this report, and from date must not be after to date."); GB5Trace.Step("profit-loss-dashboard", new { fromDate, toDate, periodType, ouIds, ouGroupId }); return await _dal.GetProfitLossDashboard(fromDate, toDate, periodType, ouIds, ouGroupId, loginDTO, ct).ConfigureAwait(false); } } }