using AccountsBLL.Voucher; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Voucher; // ReportCallingDTO-accepting wrapper over LoadBRS (Finance Analytics Dashboards Phase 4a -- // Bank Reconciliation drilldown target). The menu-driven report-viewer navigation path // (dynamicdrillDowntoReport -> Framework.ReportMenu.Get -> reportviewer.dbservice.ts) always // POSTs a ReportCallingDTO{CriteriaDTO} envelope; the existing LoadBRS endpoint takes // [FromBody] CriteriaDTO directly and would silently bind to a default/empty instance against // that envelope shape -- same class of wire-shape mismatch as the Compliance dashboard wrappers. public class LoadBRSForDrilldown : BaseEndpoint> { private readonly IVoucherBLL _bll; public LoadBRSForDrilldown(IVoucherBLL bll) => _bll = bll; public override void Configure() { Post("/Voucher/BRSLoadForDrilldown"); AllowAnonymous(); } public record Params( [property: FromHeader] string Login, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override string? GetCacheKey(Params req, LoginDTO login) => null; protected override async Task> ExecuteAsync( Params req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.LoadBRS(req.FirstNumber, req.MaxResult, req.ReportCallingDTO.CriteriaDTO, login).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } }