Function: flagAmountAnomaly()
flagAmountAnomaly(
amountCents,recentCents):object
Defined in: src/lib/invoice/index.ts:157
Advisory anomaly check for a draft invoice's amount vs the facility's recent ISSUED invoices. Baseline = mean of the recent amounts (needs ≥2 to give a meaningful signal); the draft is flagged when its amount is below ANOMALY_LOW_FACTOR× or above ANOMALY_HIGH_FACTOR× the baseline. This only surfaces a "this bill looks unusual — double-check" nudge before sending; it never blocks a send.
Parameters
amountCents
number
The draft invoice's total amount, in integer USD cents.
recentCents
readonly number[]
Amounts (integer cents) of the facility's recent ISSUED invoices.
Returns
object
{ baselineCents, anomaly }. baselineCents is the rounded mean of recentCents, or
null when there are fewer than 2 samples (and then anomaly is false). When the baseline is
≤ 0 the result is non-anomalous. Otherwise anomaly is true iff the amount is outside
[baseline × ANOMALY_LOW_FACTOR, baseline × ANOMALY_HIGH_FACTOR].
anomaly
anomaly:
boolean
baselineCents
baselineCents:
number|null