using AccountsBLL.ETDS; 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 TDSUndoPosting. Despite living under TDSCategory.svc, // GB4's actual logic lives in EtdsBLL/EtdsDAL, not TDSCategoryBLL — this is a reversal of an // e-TDS quarterly return FILING batch (TTDSRETURN and its children), not a voucher/TDS-payment // posting undo. Destructive: hard-deletes every row tied to the matching TDSRETURNID(s) for the // given OU+Period+FormType+PeriodType, with no downstream-usage guard beyond "records found". public class TDSUndoPosting : BaseEndpoint> { private readonly IEtdsBLL _etdsBLL; public TDSUndoPosting(IEtdsBLL etdsBLL) { _etdsBLL = etdsBLL; } public override void Configure() { Post("/TDSCategory/ETDS/TDSUndoPosting"); AllowAnonymous(); } public record TDSUndoPostingParameters( [property: FromHeader] string Login, [property: FromBody] CriteriaDTO CriteriaDTO ); protected override string? GetCacheKey(TDSUndoPostingParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(TDSUndoPostingParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _etdsBLL.TDSUndoPosting(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); } } } }