using AccountsBLL.AccountReports.RatioAnalysis; using AccountsBLL.AccountReports; using AccountsDAL.DTO.AccountsReports; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; namespace AccountsSL.EndPoints.AccountReports { // Ratio Analysis Dashboard — reads from the already-posted FFINANCE fact table instead of live // TVOUCHER aggregation, the first report in this migration wave to do so (see the plan file's // "Ratio Analysis Dashboard" section). Wired under the EXISTING legacy REPORTID -1399896764 // ("Ratio Analysis Dashboard") and its REPORTVIEWID -1399999760 ("Ratio Analysis View") — both // confirmed live via sqlcmd, never created fresh. Result set is small and bounded (~12 ratios x // their own element count) so the default ExecutePagedAsync (caps at 500 rows) is left // un-overridden, per BaseReportEndpoint's own guidance for reports too small to bother with // real SQL-level paging. public class AccountRatioAnalysisReport : BaseReportEndpoint { private readonly IRatioAnalysisReportBLL _bll; public AccountRatioAnalysisReport(IRatioAnalysisReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountRatioAnalysisReport"); AllowAnonymous(); } public record AccountRatioAnalysisReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountRatioAnalysisReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var criteria = AccountReportCriteriaParser.Parse(req.ReportCallingDTO.CriteriaDTO, login); var ouIds = criteria.OUIds is { Count: > 0 } ? criteria.OUIds : null; var rows = await _bll.GetRatioAnalysisDashboard( criteria.PeriodFromDate, criteria.PeriodToDate, ouIds, criteria.OUGroupId, login, ct).ConfigureAwait(false); foreach (var row in rows) { ct.ThrowIfCancellationRequested(); yield return row; } } } }