using AccountsBLL.Voucher; 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.Voucher { // Legacy GB4 route: Voucher.svc/VoucherTDS/SelectList (POST, CriteriaDTO body). A lightweight // pick-list (Id/ReferenceNumber/ReferenceDate/Amount/PaidAmount), filtered by AccountId/Number // (ReferenceNumber). Its exclusion logic hides BOTH sides of any TDS-to-TDS allotment pairing — // distinct from GetVoucherTDS's simpler "ALLOTEDVOUCHERLINEID = -1" filter. public class GetSelectListVoucherTDS : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public GetSelectListVoucherTDS(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/VoucherTDS/SelectList"); AllowAnonymous(); } public record GetSelectListVoucherTDSParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(GetSelectListVoucherTDSParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(GetSelectListVoucherTDSParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.GetSelectListVoucherTDS(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); } } } }