import { sapToEpc } from "@/app/utils";

/**
 * The portfolio "Expected EPC" — the post-retrofit band of a property's default
 * plan. The plan engine already models interactions, SAP 10 and the effective
 * baseline, so we trust `plan.post_epc_rating` (falling back to deriving it from
 * `post_sap_points`) rather than adding raw recommendation SAP onto the current
 * score, which double-counts across plans and overshoots. See ADR-0002 and the
 * grilling notes for property 732385 (read A, should read C).
 *
 * Returns "" when there is no default plan — the column renders blank, not the
 * current rating.
 */
export function expectedEpcRating(
  plan: { postEpcRating: string | null; postSapPoints: number | null } | null,
): string {
  if (!plan) return "";
  return plan.postEpcRating ?? sapToEpc(plan.postSapPoints);
}
