using SIGCM2.Domain.Pricing.ChargeableChars; namespace SIGCM2.Application.Abstractions.Persistence; /// /// PRC-001 — Write + query access to dbo.ChargeableCharConfig. /// Implemented by ChargeableCharConfigRepository (Dapper) in Infrastructure. /// /// InsertWithCloseAsync: invokes usp_ChargeableCharConfig_InsertWithClose which atomically /// closes any active row for (MedioId, Symbol) and inserts the new row. /// /// GetActiveForMedioAsync: invokes usp_ChargeableCharConfig_GetActiveForMedio which returns /// both per-medio rows AND global (MedioId IS NULL) rows for the given asOfDate. /// The Application service applies the per-medio > global priority rule. /// public interface IChargeableCharConfigRepository { /// /// Invokes usp_ChargeableCharConfig_InsertWithClose inside the ambient TransactionScope. /// Closes any active row matching (MedioId, Symbol) and inserts a new one. /// Returns the Id of the newly inserted row. /// Throws: /// - ChargeableCharConfigForwardOnlyException on SQL THROW 50409 /// - ChargeableCharConfigInvalidException on SQL THROW 50404 (not-found guard) /// Task InsertWithCloseAsync( long? medioId, string symbol, string category, decimal price, DateOnly validFrom, CancellationToken ct = default); /// /// Returns all active rows whose [ValidFrom, ValidTo] window covers the given asOfDate /// for the specified medio, including global rows (MedioId IS NULL). /// The SP returns both per-medio AND global rows — callers apply priority. /// Task> GetActiveForMedioAsync( long medioId, DateOnly asOfDate, CancellationToken ct = default); /// /// Returns paginated rows filtered by MedioId and IsActive. /// Skip = (page - 1) * pageSize computed by the caller. /// Task> ListAsync( long? medioId, bool activeOnly, int skip, int take, CancellationToken ct = default); /// /// Returns total row count for the given filters (used for pagination metadata). /// Task CountAsync( long? medioId, bool activeOnly, CancellationToken ct = default); /// /// Returns the row with the given Id, or null if not found. /// Task GetByIdAsync( long id, CancellationToken ct = default); /// /// Deactivates the row with the given Id by setting IsActive = false and ValidTo = today. /// Idempotent: no-op if already inactive. /// Called inside the ambient TransactionScope of the handler. /// Task DeactivateAsync( long id, DateOnly today, CancellationToken ct = default); }