@welldot/utils

getMeterIntervals

Derives the volume of every interval between consecutive readings of the same meter (.well v2.3 volume derivation, normative). Only effective (non-retracted) meterreading entries count; readings of each meter are ordered by instant, then sequence (lower first, absent first), then file order.

getMeterIntervals(well): MeterInterval

Derives the volume of every interval between consecutive readings of the same meter (.well v2.3 volume derivation, normative). Only effective (non-retracted) meter_reading entries count; readings of each meter are ordered by instant, then sequence (lower first, absent first), then file order.

  • r₂ ≥ r₁ → r₂ − r₁.
  • r₂ < r₁ with max_reading → (max_reading − r₁) + r₂ (rollover).
  • r₂ < r₁ without max_reading → volume: null (unknown).

Intervals never span two meters, so a meter swap leaves the gap between the removal and installation readings unmetered. Production before a meter's first reading is unknown and yields no interval. Readings whose meter_id does not resolve are still paired (without rollover). The result is sorted by end instant.

Parameters

well

Well

Returns

MeterInterval