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 { // Direct method — a faithful port of legacy's real GetCashFlowReport — wired under the EXISTING // legacy "Cash Flow" REPORTID (-1399941983), new MREPORTVIEW rows for the 3 GroupType levels. // Returns a flat FlowType-tagged list (Inflow/Outflow), not legacy's row-paired print-layout // shape — see CashFlowReportQB.cs class header. See AccountCashFlowIndirectReport for the // Indirect method (a distinct endpoint, per the user's explicit request for both methods). public class AccountCashFlowDirectReport : BaseReportEndpoint { private readonly IAccountCashFlowReportBLL _bll; public AccountCashFlowDirectReport(IAccountCashFlowReportBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountCashFlowDirectReport"); AllowAnonymous(); } public record AccountCashFlowDirectReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override async IAsyncEnumerable ExecuteReportAsync( AccountCashFlowDirectReportParameter req, LoginDTO login, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken ct) { var result = await _bll.GetCashFlowDirectReport( 1, int.MaxValue, req.ReportCallingDTO.CriteriaDTO, sortBy: null, req.ReportCallingDTO.MenuId, login).ConfigureAwait(false); foreach (var row in result.Items) { ct.ThrowIfCancellationRequested(); yield return row; } } protected override async Task> ExecutePagedAsync( AccountCashFlowDirectReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetCashFlowDirectReport( req.FirstNumber, req.MaxResult, req.ReportCallingDTO.CriteriaDTO, sortBy: null, 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); } } } }