feat(adm-009): TipoDeIva + IngresosBrutos handlers, DTOs, DI registration

This commit is contained in:
2026-04-17 18:09:52 -03:00
parent 2cd25e1036
commit bd0c4deea7
47 changed files with 1134 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
using System.Transactions;
using SIGCM2.Application.Abstractions;
using SIGCM2.Application.Abstractions.Persistence;
using SIGCM2.Application.Audit;
using SIGCM2.Application.IngresosBrutos.Dtos;
namespace SIGCM2.Application.IngresosBrutos.Create;
public sealed class CreateIngresosBrutosCommandHandler
: ICommandHandler<CreateIngresosBrutosCommand, IngresosBrutosDto>
{
private readonly IIngresosBrutosRepository _repo;
private readonly IAuditLogger _audit;
public CreateIngresosBrutosCommandHandler(IIngresosBrutosRepository repo, IAuditLogger audit)
{
_repo = repo;
_audit = audit;
}
public async Task<IngresosBrutosDto> Handle(CreateIngresosBrutosCommand command)
{
var entity = Domain.Entities.IngresosBrutos.ForCreation(
command.Provincia,
command.Descripcion,
command.Alicuota,
command.VigenciaDesde,
command.VigenciaHasta);
using var tx = new TransactionScope(
TransactionScopeOption.Required,
new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted },
TransactionScopeAsyncFlowOption.Enabled);
var newId = await _repo.InsertAsync(entity);
await _audit.LogAsync(
action: "ingresos_brutos.create",
targetType: "IngresosBrutos",
targetId: newId.ToString(),
metadata: new { entity.Provincia, entity.Alicuota, entity.VigenciaDesde });
tx.Complete();
return IngresosBrutosMapper.ToDto(Domain.Entities.IngresosBrutos.FromDb(
id: newId,
provincia: entity.Provincia,
descripcion: entity.Descripcion,
alicuota: entity.Alicuota,
activo: entity.Activo,
vigenciaDesde: entity.VigenciaDesde,
vigenciaHasta: entity.VigenciaHasta,
predecesorId: entity.PredecesorId,
fechaCreacion: DateTime.UtcNow,
fechaModificacion: null));
}
}