using AccountsBLL.Voucher; using AccountsDAL.DTO.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 OpeningBalanceSaveUpdate — distinct from // OpeningBalanceSave.cs above, which just routes through the generic TVP full-voucher save // and does not replicate this operation's existing-header lookup / per-row upsert semantics. public class OpeningBalanceSaveUpdate : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public OpeningBalanceSaveUpdate(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Post("/Voucher/OpeningBalanceSaveUpdate"); AllowAnonymous(); } public record OpeningBalanceSaveUpdateParameters( [property: FromHeader] string Login, [property: FromBody] List VoucherDetailDTOs, [property: QueryParam] int BizTransactionTypeId, [property: QueryParam] int OUId ); protected override string? GetCacheKey(OpeningBalanceSaveUpdateParameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync( OpeningBalanceSaveUpdateParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var result = await _VoucherBLL.SaveUpdateOpeningVoucher( req.VoucherDetailDTOs, req.BizTransactionTypeId, req.OUId, 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); } } } }