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 List Report, Type=0 "class list" (Voucher Report Consolidation, Report 3a) -- new // MREPORT/MREPORTVIEW/MMENU. Header-level, one row per voucher, main account only -- genuinely // different shape from AccountVoucherListAccountReport (Type=1), kept as a separate endpoint. public class AccountVoucherListClassReport : BaseReportEndpoint { private readonly IAccountVoucherReportBLL _bll; public AccountVoucherListClassReport(IAccountVoucherReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountVoucherListClassReport"); AllowAnonymous(); } public record AccountVoucherListClassReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: QueryParam] int MenuId ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountVoucherListClassReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var result = await _bll.GetVoucherListClassReport( req.FirstNumber, req.MaxResult, 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( AccountVoucherListClassReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetVoucherListClassReport( req.FirstNumber, req.MaxResult, 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); } } } }