using AccountsBLL.AccountReports.AccountVoucherReport; using AccountsDAL.DTO.AccountsReports; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; namespace AccountsSL.EndPoints.AccountReports { // Voucher Summary Report (Voucher Report Consolidation, Report 2) -- new MREPORT/MREPORTVIEW/ // MMENU. GroupType (0=AccountGroup default/1=Account/2=ControlAccount-collapse/3=ControlAccount+ // Account pair) selects which of legacy's 4 near-duplicate summary shapes this returns, via one // shared query + VoucherSummaryGroupByBuilder -- see VoucherReportQB.cs. public class AccountVoucherSummaryReport : BaseReportEndpoint { private readonly IAccountVoucherReportBLL _bll; public AccountVoucherSummaryReport(IAccountVoucherReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountVoucherSummaryReport"); AllowAnonymous(); } public record AccountVoucherSummaryReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: QueryParam] int MenuId, [property: QueryParam] int GroupType ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountVoucherSummaryReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var result = await _bll.GetVoucherSummaryReport( req.FirstNumber, req.MaxResult, req.GroupType, req.ReportCallingDTO.CriteriaDTO, req.MenuId, login, ct).ConfigureAwait(false); foreach (var row in result.Items) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( AccountVoucherSummaryReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetVoucherSummaryReport( req.FirstNumber, req.MaxResult, req.GroupType, req.ReportCallingDTO.CriteriaDTO, req.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); } } } }