using AccountsBLL.AccountReports.AccountOutstanding; 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 { // Backs the Receivable Dashboard's 4 KPI cards (Amount/Overdue/Unadjusted/Balance) — a single // aggregate object, not a row list, so this is a plain BaseEndpoint rather than // BaseReportEndpoint (no Excel/PDF/CSV export machinery makes sense for one KPI object). public class AccountOutstandingKpiReport : BaseEndpoint> { private readonly IAccountOutstandingKpiBLL _bll; public AccountOutstandingKpiReport(IAccountOutstandingKpiBLL bll) { _bll = bll; } public override void Configure() { Post("/AccountReports/AccountOutstandingKpi"); AllowAnonymous(); } public record AccountOutstandingKpiReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO ); protected override string? GetCacheKey(AccountOutstandingKpiReportParameter req, LoginDTO login) => null; protected override async Task> ExecuteAsync( AccountOutstandingKpiReportParameter req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetOutstandingKpiSummary( 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); } } } }