using AccountsBLL.Voucher; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Voucher { // Faithful port of GB4 Voucher.svc's GetVoucherDetailForOpeningBalance — read-side sibling // of OpeningBalanceSaveUpdate.cs, fetching existing detail lines for a given // BizTransactionType+OU+Account so they can be edited and re-submitted. public class GetVoucherDetailForOpeningBalance : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public GetVoucherDetailForOpeningBalance(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Get("/Voucher/VoucherDetail"); AllowAnonymous(); } public record GetVoucherDetailForOpeningBalanceParameters( [property: FromHeader] string Login, [property: QueryParam] int BizTransactionTypeId, [property: QueryParam] int OUId, [property: QueryParam] int VoucherAccountId ); protected override string? GetCacheKey(GetVoucherDetailForOpeningBalanceParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( GetVoucherDetailForOpeningBalanceParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _VoucherBLL.GetVoucherDetailForOpeningBalance( req.BizTransactionTypeId, req.OUId, req.VoucherAccountId, 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); } } } }