using AccountsBLL.TDSCategory; using FastEndpoints; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.TDSCategory { // Faithful port of GB4 TDSCategory.svc's GetTDSDetailsFromVoucher. Despite the operation // name, GB4 never filters by VoucherId — it returns pending/unpaid TVOUCHERTDS lines for the // caller's current OU, optionally narrowed by TDS category and a credit-date range. Ported // with that same behavior rather than "fixed" to add a VoucherId filter GB4 itself never had. public class GetTDSDetailsFromVoucher : BaseEndpoint> { private readonly ITDSCategoryBLL _TDSCategoryBLL; public GetTDSDetailsFromVoucher(ITDSCategoryBLL TDSCategoryBLL) { _TDSCategoryBLL = TDSCategoryBLL; } public override void Configure() { Post("/TDSCategory/GetTDSDetailsFromVoucher"); AllowAnonymous(); } public record GetTDSDetailsFromVoucherParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetTDSDetailsFromVoucherParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(GetTDSDetailsFromVoucherParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _TDSCategoryBLL.GetTDSDetailsFromVoucher(req.CriteriaDTO, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }