mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
plannedValueExpr matched a target only when its period_type and period_start equalled the report's bucket exactly, so a monthly plan vanished the moment you viewed by quarter, by year, or by day. The plan column simply went empty and the implement rate read 0%. plannedRowsSql replaces it with a derived table: each target is spread evenly over the days it covers, then re-gathered into whichever bucket the report shows. Three monthly targets add up to a quarter exactly, a daily view gets a thirty-first of the month, and a week straddling a month boundary draws proportionally on both. The even spread is an assumption and the only one available — a monthly figure says nothing about which days inside it were busier — so PLAN_GRANULARITY_NOTE says so in each report's description. The share is clipped to the user's date filter as well as to the bucket, or filtering to July and viewing by year would sit a whole year's plan next to one month's work. Reports FULL OUTER JOIN it so a category that was planned but never ran still publishes, at 0% — dropping the row would hide a total miss, which is the one thing a plan-versus-actual table is for.