5977c81002
- German-dialect scalar parsers in Core (GermanNumber/Money/Date, ValueCell): decimal comma, thousands dot, unit suffixes, € currency, both date shapes. - Declarative MappingProfile + RowClassifier (skip summary/blank/all-zero rows) + CsvImporter (CsvHelper) staging readings/events/manual-costs, with auto swap detection on register decreases and month-end anchoring for interleaved oil dates. - Four built-in ReferenceProfiles (Strom/Wasser/Heizöl/Kosten). - ImportService: commit as revertible import_batch + wholesale consumption recompute per affected meter (NormalizationService/MeterConfigFactory), revert by batch. - Reconciliation tests: all 4 CSVs match the sheet's own columns within tolerance (electricity 5 meters + Netz Einsparung, water swap→12, oil tank incl. deliveries + burner hours, cost category totals). Commit/revert round-trip verified on Timescale. 69 tests green (53 Core + 16 integration). Known follow-up (polish): historical imports can contend with the 30-day compression policy's background job; tests pause it. Consider retry-on-deadlock or deferred compression for large historical imports in production. Claude-Session: https://claude.ai/code/session_01WujdMtMJPbxDpDnMeK22rr
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using MeterVault.Core.Domain;
|
|
using MeterVault.Core.Normalization;
|
|
using MeterVault.Infrastructure.Import;
|
|
using static MeterVault.Integration.Tests.Reconciliation.ReconciliationSupport;
|
|
|
|
namespace MeterVault.Integration.Tests.Reconciliation;
|
|
|
|
/// <summary>
|
|
/// Reconciles the water meter against the Wasser sheet's Wasserverbrauch column, exercising the
|
|
/// mid-series register swap …861 → 2 (SDD §2.3). The importer detects the register drop and seeds
|
|
/// a swap event whose consumption override comes from the sheet's own column.
|
|
/// </summary>
|
|
public sealed class WaterReconciliationTests
|
|
{
|
|
[Fact]
|
|
public void Water_consumption_matches_the_sheet_across_the_swap()
|
|
{
|
|
var staged = Stage(ReferenceProfiles.Water(), Water);
|
|
|
|
// A swap event must have been auto-detected at the 861→2 drop.
|
|
Assert.Contains(staged.Events, e => e.EventType == MeterEventType.MeterSwap);
|
|
|
|
var config = new MeterConfig
|
|
{
|
|
MeterId = ReferenceProfiles.Wasser,
|
|
Mode = MeterMode.CumulativeCounter,
|
|
Unit = "m3",
|
|
InitialBaseline = 820, // pre-existing meter's register when tracking began (Nov 2022).
|
|
};
|
|
|
|
var computed = ByMonth(Normalize(staged, config));
|
|
var oracle = OracleByMonth(ReadRows(Water), dateColumn: 0, valueColumn: 2, firstDataRow: 1);
|
|
|
|
AssertReconciles(computed, oracle, tolerance: 1.0, "water", minMatches: 12);
|
|
|
|
// Explicitly assert the swap month reconciles to 12.
|
|
Assert.Equal(12d, computed[new DateOnly(2023, 3, 1)], 3);
|
|
}
|
|
}
|