ADM-009: Tablas Fiscales (IVA + IIBB) — append-only versioned ref data #22
123
src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs
Normal file
123
src/api/SIGCM2.Api/Contracts/Fiscal/FiscalContracts.cs
Normal file
@@ -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 ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>ADM-009: Create TipoDeIva request body.</summary>
|
||||
public sealed record CreateTipoDeIvaRequest(
|
||||
string? Codigo,
|
||||
string? Descripcion,
|
||||
decimal? Porcentaje,
|
||||
bool? AplicaIVA,
|
||||
string? VigenciaDesde,
|
||||
string? VigenciaHasta = null);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
public sealed record UpdateTipoDeIvaRequest(
|
||||
string? Codigo,
|
||||
string? Descripcion,
|
||||
bool? AplicaIVA,
|
||||
bool? Activo);
|
||||
|
||||
/// <summary>ADM-009: Create new TipoDeIva version request body.</summary>
|
||||
public sealed record NuevaVersionTipoDeIvaRequest(
|
||||
decimal? Porcentaje,
|
||||
string? VigenciaDesde);
|
||||
|
||||
// ── IIBB Request records ──────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>ADM-009: Create IngresosBrutos request body.</summary>
|
||||
public sealed record CreateIngresosBrutosRequest(
|
||||
string? Provincia,
|
||||
string? Descripcion,
|
||||
decimal? Alicuota,
|
||||
string? VigenciaDesde,
|
||||
string? VigenciaHasta = null);
|
||||
|
||||
/// <summary>
|
||||
/// ADM-009: Update IngresosBrutos request body — only cosmetic fields.
|
||||
/// Alicuota and Provincia are intentionally absent.
|
||||
/// </summary>
|
||||
public sealed record UpdateIngresosBrutosRequest(
|
||||
string? Descripcion,
|
||||
bool? Activo);
|
||||
|
||||
/// <summary>ADM-009: Create new IngresosBrutos version request body.</summary>
|
||||
public sealed record NuevaVersionIngresosBrutosRequest(
|
||||
decimal? Alicuota,
|
||||
string? VigenciaDesde);
|
||||
|
||||
// ── Shared Response records ───────────────────────────────────────────────────
|
||||
|
||||
/// <summary>ADM-009: Response for nueva-version operations.</summary>
|
||||
public sealed record NuevaVersionResponse(
|
||||
int PredecesoraId,
|
||||
int NuevaVersionId);
|
||||
|
||||
// ── Mapper ────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user