using AccountsBLL.AccountReports.BSReport; using AccountsDAL.DTO.Reports; 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.AccountReports { // GB5-native replacement for the GB4 legacy gb4/as/AccountsReports.svc/BalanceSheetVertical // endpoint — MREPORT -1399971488 "Balance Sheet Vertical", live menus AC20087 (Schedule)/ // AC20088 (Group)/AC20089 (Account). Cut over via MWEBSERVICE.SECONDURITEMPLATE — see the // companion migration and BSVerticalHorizontalReportQB.cs's class header. public class BSVerticalReport : BaseReportEndpoint { private readonly IBSReportBLL _bll; public BSVerticalReport(IBSReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/BSVerticalReport"); AllowAnonymous(); } public record BSVerticalReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, // String, not int — matches the live {Type} substitution on AC20087/88/89's own // MMENU.URIPARAMETERVALUE ('ACCOUNTSCHEDULE'/'ACCOUNTGROUP'/'ACCOUNT'). [property: QueryParam] string? Type, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); private static int ToGroupType(string? type) => type?.ToUpperInvariant() switch { "ACCOUNTGROUP" => 1, "ACCOUNTSCHEDULE" => 2, _ => 0, }; protected override async IAsyncEnumerable ExecuteReportAsync( BSVerticalReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var rows = await _bll.GetBSVertical( ToGroupType(req.Type), req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login).ConfigureAwait(false); foreach (var row in rows) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( BSVerticalReportParameter req, LoginDTO login, CancellationToken ct) { try { var rows = await _bll.GetBSVertical( ToGroupType(req.Type), req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( rows, CacheKeyLevel.NOT_REQUIRED, login).ConfigureAwait(false); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500).ConfigureAwait(false); } } } }