Summary
Change onDemandMonthly() in frontend/src/recommendations.ts to return the
provider-supplied r.on_demand_cost directly instead of reconstructing it from
monthly_cost + savings + (upfront_cost / months_in_term). When
on_demand_cost is missing or zero, render — instead of falling back to a
reconstructed value.
Why
PR #322 deliberately scoped the On-Demand Monthly column to a
reconstruction-only helper (its commit comment says: "It does NOT use
on_demand_cost even when available, because the column's purpose is to display
the reconstructed denominator so users can verify the formula against the raw
fields visible in the same row").
In practice, post-#277 / #312 / #324 every supported provider (AWS, Azure, GCP)
plumbs on_demand_cost through to the frontend, and effectiveSavingsPct()
already prefers the provider value when present (see
frontend/src/recommendations.ts:738-756 — hasOnDemand branch). The two
columns therefore disagree for any row where the formula reconstruction drifts
from the provider's billed on-demand price (rounding, partial-day proration,
provider-specific list price quirks, AWS On-Demand Capacity Reservations, etc.).
The product decision: surface the authoritative number from the provider,
not a teaching-tool reconstruction. Users who want to verify the formula can
still see monthly_cost + savings + upfront_cost/term in the row's other
columns and do the arithmetic themselves; making On-Demand Monthly match
effectiveSavingsPct's denominator is more important than making it
reconstructible.
Scope
onDemandMonthly(): drop the reconstruction. Return r.on_demand_cost when
it's a positive number; return null otherwise (so the cell shows —,
consistent with the existing monthly_cost == null em-dash rendering).
- Update the doc comment on
onDemandMonthly() to reflect the new contract.
- Update the unit tests in
frontend/src/__tests__/recommendations.test.ts:
- keep "prefer explicit
on_demand_cost",
- replace "fall back to reconstruction" tests with "return null when
on_demand_cost is null/missing/zero",
- the existing reconstruction-arithmetic tests can be deleted — they're
asserting behaviour we're explicitly removing.
Out of scope
Acceptance criteria
Related
Summary
Change
onDemandMonthly()infrontend/src/recommendations.tsto return theprovider-supplied
r.on_demand_costdirectly instead of reconstructing it frommonthly_cost + savings + (upfront_cost / months_in_term). Whenon_demand_costis missing or zero, render—instead of falling back to areconstructed value.
Why
PR #322 deliberately scoped the On-Demand Monthly column to a
reconstruction-only helper (its commit comment says: "It does NOT use
on_demand_cost even when available, because the column's purpose is to display
the reconstructed denominator so users can verify the formula against the raw
fields visible in the same row").
In practice, post-#277 / #312 / #324 every supported provider (AWS, Azure, GCP)
plumbs
on_demand_costthrough to the frontend, andeffectiveSavingsPct()already prefers the provider value when present (see
frontend/src/recommendations.ts:738-756—hasOnDemandbranch). The twocolumns therefore disagree for any row where the formula reconstruction drifts
from the provider's billed on-demand price (rounding, partial-day proration,
provider-specific list price quirks, AWS On-Demand Capacity Reservations, etc.).
The product decision: surface the authoritative number from the provider,
not a teaching-tool reconstruction. Users who want to verify the formula can
still see
monthly_cost + savings + upfront_cost/termin the row's othercolumns and do the arithmetic themselves; making
On-Demand MonthlymatcheffectiveSavingsPct's denominator is more important than making itreconstructible.
Scope
onDemandMonthly(): drop the reconstruction. Returnr.on_demand_costwhenit's a positive number; return
nullotherwise (so the cell shows—,consistent with the existing
monthly_cost == nullem-dash rendering).onDemandMonthly()to reflect the new contract.frontend/src/__tests__/recommendations.test.ts:on_demand_cost",on_demand_costis null/missing/zero",asserting behaviour we're explicitly removing.
Out of scope
effectiveSavingsPctkeeps its existing fallback (it's the canonicalEffective Savings % calculation and is needed for backward compatibility on
legacy cached rows that pre-date fix(recommendations/aws): plumb on_demand_cost for canonical Effective Savings % (closes #303) #312/fix(recommendations/aws): flush stale on_demand_cost cache + parser visibility (closes #321) #324).
Acceptance criteria
onDemandMonthly()returnsr.on_demand_costwhen it's> 0.nullwhenr.on_demand_costisnull,undefined, or0.—for null cases (same asmonthly_cost-null today).on_demand_monthlystill treat null as bottom(POSITIVE_INFINITY for sort, NaN for filter — already in place).
Related
on_demand_costto frontend (AWS/Azure/GCP)effectiveSavingsPctthat design choice)
on_demand_costJSONB cache