using AccountsBLL.AccountReports; using AccountsDAL.CustomCode.AccountReports.AccountReceivableDashboard; using AccountsDAL.DTO.AccountsReports; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.AccountReceivableDashboard { // Bill-level/TVOUCHER-sourced, same family as Outstanding/Ageing -- uses the shared // EnforceForAsOnDateAsync (AsOnDate-only) check, unlike the P&L Dashboard's own bespoke // fact-table-sourced check. public class AccountReceivableDashboardBLL : IAccountReceivableDashboardBLL { private const int DEFAULT_MAX_RESULT_CAP = 500; private readonly IAccountReceivableDashboardDAL _dal; private readonly IAccountReportAccessControlBLL _accessControlBLL; public AccountReceivableDashboardBLL(IAccountReceivableDashboardDAL dal, IAccountReportAccessControlBLL accessControlBLL) { _dal = dal; _accessControlBLL = accessControlBLL; } public async Task GetReceivableDashboard( CriteriaDTO criteriaDTO, int menuId, LoginDTO loginDTO, CancellationToken ct) { try { GB5Trace.Step("parse-criteria-receivable-dashboard", new { menuId }); var criteria = AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); await _accessControlBLL.EnforceForAsOnDateAsync(criteria, DEFAULT_MAX_RESULT_CAP, menuId, loginDTO) .ConfigureAwait(false); GB5Trace.Step("query-receivable-dashboard", new { criteria.AsOnDate }); return await _dal.GetReceivableDashboard(criteria, loginDTO, ct).ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("receivable-dashboard-failed", ex); throw; } } } }