From 25407583eb78fd47ebcef058ba222dafd53c60ba Mon Sep 17 00:00:00 2001 From: dmolinari Date: Fri, 17 Apr 2026 18:39:58 -0300 Subject: [PATCH] feat(adm-009): Fiscal API DTOs (requests + responses + mapper) --- .../Contracts/Fiscal/FiscalContracts.cs | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs diff --git a/src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs b/src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs new file mode 100644 index 0000000..caf8618 --- /dev/null +++ b/src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs @@ -0,0 +1,123 @@ +using SIGCM2.Application.IngresosBrutos.Dtos; +using SIGCM2.Application.TiposDeIva.Dtos; +using SIGCM2.Domain.Fiscal; + +namespace SIGCM2.Api.Contracts.Fiscal; + +// ── IVA Request records ─────────────────────────────────────────────────────── + +/// ADM-009: Create TipoDeIva request body. +public sealed record CreateTipoDeIvaRequest( + string? Codigo, + string? Descripcion, + decimal? Porcentaje, + bool? AplicaIVA, + string? VigenciaDesde, + string? VigenciaHasta = null); + +/// +/// ADM-009: Update TipoDeIva request body — only cosmetic fields. +/// Porcentaje is intentionally absent; any attempt to pass it in the body +/// is detected via raw JSON inspection and returns 409. +/// +public sealed record UpdateTipoDeIvaRequest( + string? Codigo, + string? Descripcion, + bool? AplicaIVA, + bool? Activo); + +/// ADM-009: Create new TipoDeIva version request body. +public sealed record NuevaVersionTipoDeIvaRequest( + decimal? Porcentaje, + string? VigenciaDesde); + +// ── IIBB Request records ────────────────────────────────────────────────────── + +/// ADM-009: Create IngresosBrutos request body. +public sealed record CreateIngresosBrutosRequest( + string? Provincia, + string? Descripcion, + decimal? Alicuota, + string? VigenciaDesde, + string? VigenciaHasta = null); + +/// +/// ADM-009: Update IngresosBrutos request body — only cosmetic fields. +/// Alicuota and Provincia are intentionally absent. +/// +public sealed record UpdateIngresosBrutosRequest( + string? Descripcion, + bool? Activo); + +/// ADM-009: Create new IngresosBrutos version request body. +public sealed record NuevaVersionIngresosBrutosRequest( + decimal? Alicuota, + string? VigenciaDesde); + +// ── Shared Response records ─────────────────────────────────────────────────── + +/// ADM-009: Response for nueva-version operations. +public sealed record NuevaVersionResponse( + int PredecesoraId, + int NuevaVersionId); + +// ── Mapper ──────────────────────────────────────────────────────────────────── + +/// +/// Maps Application-layer DTOs to API response shapes. +/// Application DTOs are already well-formed for most cases; +/// IIBB Provincia is mapped to its display string for the API. +/// +public static class FiscalContractMapper +{ + public static object ToIvaResponse(TipoDeIvaDto dto) => new + { + dto.Id, + dto.Codigo, + dto.Descripcion, + dto.Porcentaje, + dto.AplicaIVA, + dto.Activo, + dto.VigenciaDesde, + dto.VigenciaHasta, + dto.PredecesorId, + dto.FechaCreacion, + dto.FechaModificacion + }; + + public static object ToIibbResponse(IngresosBrutosDto dto) => new + { + dto.Id, + Provincia = dto.Provincia.ToDisplayString(), + dto.Descripcion, + dto.Alicuota, + dto.Activo, + dto.VigenciaDesde, + dto.VigenciaHasta, + dto.PredecesorId, + dto.FechaCreacion, + dto.FechaModificacion + }; + + public static object ToHistorialIvaResponse(HistorialCadenaDto dto) => new + { + dto.Id, + dto.Codigo, + dto.Porcentaje, + dto.VigenciaDesde, + dto.VigenciaHasta, + dto.PredecesorId, + dto.Version + }; + + public static object ToHistorialIibbResponse(HistorialCadenaIibbDto dto) => new + { + dto.Id, + Provincia = dto.Provincia.ToDisplayString(), + dto.Alicuota, + dto.VigenciaDesde, + dto.VigenciaHasta, + dto.PredecesorId, + dto.Version + }; +}