revert(backend): eliminar handlers/endpoints/excepciones de reserva de numero ADM-008
Eliminar SecuenciaComprobante entity, TipoComprobante enum, DeadlockTransientException, PuntoDeVentaInactivoException, carpetas Reservar/ y ProximoNumero/ de Application, métodos ReservarNumeroAsync/GetUltimoNumeroAsync del repositorio, endpoints POST /secuencias/.../reservar y GET /secuencias/.../proximo del controller, y mapping PuntoDeVentaInactivoException del ExceptionFilter.
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using Dapper;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using SIGCM2.Application.Abstractions.Persistence;
|
||||
using SIGCM2.Application.Common;
|
||||
using SIGCM2.Domain.Entities;
|
||||
using SIGCM2.Domain.Enums;
|
||||
using SIGCM2.Domain.Exceptions;
|
||||
|
||||
namespace SIGCM2.Infrastructure.Persistence;
|
||||
@@ -153,56 +151,6 @@ public sealed class PuntoDeVentaRepository : IPuntoDeVentaRepository
|
||||
return new PagedResult<PuntoDeVenta>(items, page, pageSize, total);
|
||||
}
|
||||
|
||||
public async Task<int> ReservarNumeroAsync(int puntoDeVentaId, TipoComprobante tipo, CancellationToken ct = default)
|
||||
{
|
||||
var parameters = new DynamicParameters();
|
||||
parameters.Add("PuntoDeVentaId", puntoDeVentaId, DbType.Int32);
|
||||
parameters.Add("TipoComprobante", (byte)tipo, DbType.Byte);
|
||||
parameters.Add("NumeroReservado", dbType: DbType.Int32, direction: ParameterDirection.Output);
|
||||
|
||||
await using var connection = _connectionFactory.CreateConnection();
|
||||
await connection.OpenAsync(ct);
|
||||
|
||||
try
|
||||
{
|
||||
await connection.ExecuteAsync(
|
||||
"dbo.usp_ReservarNumeroComprobante",
|
||||
parameters,
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
throw ex.Number switch
|
||||
{
|
||||
50001 => new PuntoDeVentaInactivoException(puntoDeVentaId),
|
||||
50002 => new MedioInactivoException(puntoDeVentaId),
|
||||
50003 => new PuntoDeVentaNotFoundException(puntoDeVentaId),
|
||||
1205 => new DeadlockTransientException(ex),
|
||||
_ => ex,
|
||||
};
|
||||
}
|
||||
|
||||
return parameters.Get<int>("NumeroReservado");
|
||||
}
|
||||
|
||||
public async Task<int?> GetUltimoNumeroAsync(int puntoDeVentaId, TipoComprobante tipo, CancellationToken ct = default)
|
||||
{
|
||||
const string sql = """
|
||||
SELECT UltimoNumero
|
||||
FROM dbo.SecuenciaComprobante
|
||||
WHERE PuntoDeVentaId = @PuntoDeVentaId AND TipoComprobante = @TipoComprobante
|
||||
""";
|
||||
|
||||
await using var connection = _connectionFactory.CreateConnection();
|
||||
await connection.OpenAsync(ct);
|
||||
|
||||
return await connection.QuerySingleOrDefaultAsync<int?>(sql, new
|
||||
{
|
||||
PuntoDeVentaId = puntoDeVentaId,
|
||||
TipoComprobante = (byte)tipo,
|
||||
});
|
||||
}
|
||||
|
||||
// ── mapping ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static PuntoDeVenta MapRow(PdvRow r)
|
||||
|
||||
Reference in New Issue
Block a user