You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug(api/purchases): Total Upfront/Monthly/Annual Savings KPIs include cancelled purchases #736
When an admin clicks Cancel on a pending purchase request in the Approval queue:
Counts for pending and cancelled purchases update correctly.
BUT Total Upfront Spent, Monthly Saving, and Annual Savings all update as if the cancelled purchase had been approved, adding its committed/saved amounts to the KPIs.
A cancelled purchase represents zero committed spend and zero realized savings. The KPIs must exclude cancelled-status executions.
Reproduction
Send a high-cost commitment for approval (so the delta is large and visible).
Note the Total Upfront Spent / Monthly Saving / Annual Savings KPIs on the Purchases page.
Click Cancel on that pending request in the Approval queue.
Observe: pending count -1, cancelled count +1 (correct). But Total Upfront Spent +cost_of_cancelled_purchase, Monthly Saving +its_savings, etc. (wrong — these should stay unchanged.)
Fix direction
Trace the KPI aggregation:
Likely a backend handler that sums all execution rows without filtering on status (or status set is too permissive, e.g., status IN ('approved', 'completed', 'cancelled') instead of status IN ('approved', 'completed')).
Search for "Total Upfront Spent" / "Monthly Saving" / "Annual Savings" in internal/api/ and frontend/src/.
The cancel-purchase mutation likely transitions to cancelled but doesn't subtract from these aggregates (or the GET handler includes cancelled in the SUM).
Whichever is the data source, exclude status='cancelled' from these three aggregates.
Tests required
API integration test: create N approved purchases + 1 pending; capture KPI values; cancel the pending; assert KPIs unchanged.
UI test: same scenario in the browser; assert the displayed numbers don't change after cancellation.
Source of finding
QA verification spreadsheet row 278 (step 1.6 of Approval queue).
Verified shipped: PR #737 (commit 4791743, merged 2026-05-27) is in feat/multicloud-web-frontend. git show origin/feat/multicloud-web-frontend:internal/api/handler_history.go line 821 shows 'case "cancelled": continue' added to summarizePurchaseHistory switch, excluding cancelled purchases from all dollar KPIs.
Activity
fix(api/history): exclude cancelled executions from KPI dollar totals (…
cristim commentedon May 28, 2026
Verified shipped: PR #737 (commit 4791743, merged 2026-05-27) is in feat/multicloud-web-frontend. git show origin/feat/multicloud-web-frontend:internal/api/handler_history.go line 821 shows 'case "cancelled": continue' added to summarizePurchaseHistory switch, excluding cancelled purchases from all dollar KPIs.
fix(purchases): cite #625 in cancelled-KPI regression tests
fix(purchases): cite #625 in cancelled-KPI regression tests
fix(purchases): cite #625 in cancelled-KPI regression tests
fix(purchases): cite #625 in cancelled-KPI regression tests
fix(purchases): cite #625 in cancelled-KPI regression tests
fix(purchases): exclude cancelled rows from summarizePurchaseHistory (c…