using AccountsBLL.AccountReports.AccountCashFlow; using AccountsDAL.DTO.AccountsReports; 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 { // Indirect method — genuinely new, no legacy precedent (see CashFlowReportQB.cs class header for // the from-first-principles derivation). A single consolidated statement (Operating/Investing/ // Financing sections, ~6 lines) for the requested period — no GroupType needed, unlike the Direct // method's Account/Group/Schedule breakdown. public class AccountCashFlowIndirectReport : BaseReportEndpoint { private readonly IAccountCashFlowReportBLL _bll; public AccountCashFlowIndirectReport(IAccountCashFlowReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountCashFlowIndirectReport"); AllowAnonymous(); } public record AccountCashFlowIndirectReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountCashFlowIndirectReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var result = await _bll.GetCashFlowIndirectReport( req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login).ConfigureAwait(false); foreach (var row in result.Items) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( AccountCashFlowIndirectReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetCashFlowIndirectReport( req.ReportCallingDTO.CriteriaDTO, req.ReportCallingDTO.MenuId, login).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, 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); } } } }