using AccountsBLL.AccountReports.AccountReceivableDashboard; using AccountsDAL.DTO.AccountsReports; using AccountsDAL.DTO.Reports; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; namespace AccountsSL.EndPoints.AccountReports { // Receivable Dashboard (Finance Dashboard Migration Phase 3) -- reuses the EXISTING legacy // MREPORT -1399930116 ("Receivable DashBoard") and MREPORTVIEW -1399962495 ("Receivable // DashBoard View", the one already-live MMENU rows point at) rather than creating new ones. // Single-consolidated-object response (Kpi + InchargeWise + AgeingWise), same pattern as // AccountCashFlowIndirectReport/AccountProfitLossDashboardReport. public class AccountReceivableDashboardReport : BaseReportEndpoint { private readonly IAccountReceivableDashboardBLL _bll; public AccountReceivableDashboardReport(IAccountReceivableDashboardBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountReceivableDashboardReport"); AllowAnonymous(); } public record AccountReceivableDashboardReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountReceivableDashboardReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var result = await _bll.GetReceivableDashboard( req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login, ct).ConfigureAwait(false); foreach (var row in result.InchargeWise) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( AccountReceivableDashboardReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetReceivableDashboard( req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, GB5Shared.GB5Constant.Constant.CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, GB5Shared.GB5Constant.Constant.CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }