package commandcenter import ( "fmt" "github.com/shopspring/decimal" ) // ExecutiveCard is one executive intelligence card on the Workforce Command Center. Every card is // backed by a real query over the org's own data; when the feeding data does not exist yet the // card says so honestly (NoData true, DataNote naming exactly what feeds it), never a fake number. type ExecutiveCard struct { Key string `json:"key"` Title string `json:"title"` Value string `json:"value"` Detail string `json:"detail"` State string `json:"state"` // ok, watch, risk, empty NoData bool `json:"no_data"` DataNote string `json:"data_note,omitempty"` } // buildExecutiveCards derives the four executive cards from the assembled view plus the screening // confidence counts. Pure: unit testable without a database. func buildExecutiveCards(v View, greenCoveredReqs, activeReqs int64) []ExecutiveCard { cards := make([]ExecutiveCard, 0, 4) // Mission Readiness: the weighted coverage score already assembled. mr := ExecutiveCard{Key: "mission_readiness", Title: "Mission Readiness"} if v.Meta.Empty { mr.NoData = true mr.State = "empty" mr.DataNote = "Feeds from your cleared workforce and active requirements. Add candidates and requirements to light this up." } else { mr.Value = v.MissionReadiness.Score mr.Detail = v.MissionReadiness.Status mr.State = bandToState(v.MissionReadiness.Band) } cards = append(cards, mr) // Revenue at Risk: the exact W2 counted basis summed over the staffing gaps. rar := ExecutiveCard{Key: "revenue_at_risk", Title: "Revenue at Risk"} total := decimal.Zero priced, unpriced, representative := 0, 0, false for _, g := range v.StaffingGaps { if g.ValueAtRisk != nil { if d, err := decimal.NewFromString(*g.ValueAtRisk); err == nil { total = total.Add(d) } } priced += g.PricedOpportunities unpriced += g.UnpricedOpportunities representative = representative || g.ValueRepresentative } switch { case v.Meta.Empty: rar.NoData = true rar.State = "empty" rar.DataNote = "Feeds from dollar values on open opportunities joined to unfilled staffing gaps. Add opportunities and requirements to light this up." case len(v.StaffingGaps) == 0: rar.Value = "$0" rar.Detail = "No unfilled staffing gaps expose revenue right now." rar.State = "ok" case priced == 0: rar.NoData = true rar.State = "empty" rar.DataNote = "Feeds from dollar values on open opportunities joined to unfilled gaps. No impacted opportunity carries a value yet." default: rar.Value = "$" + total.StringFixed(0) basis := fmt.Sprintf("Across %d priced opportunities; %d unpriced excluded.", priced, unpriced) if representative { basis += " Includes representative values." } rar.Detail = basis rar.State = "risk" if total.IsZero() { rar.State = "ok" } } cards = append(cards, rar) // Growth Capacity: proposal ready bench beyond the currently unmet demand. gc := ExecutiveCard{Key: "growth_capacity", Title: "Growth Capacity"} unmet := 0 for _, g := range v.StaffingGaps { unmet += g.Unmet } if v.Banner.TotalClearedWorkforce == 0 { gc.NoData = true gc.State = "empty" gc.DataNote = "Feeds from proposal ready candidates measured against unmet requirement demand. Screen your bench to light this up." } else { surplus := v.Banner.ProposalReadyCandidates - unmet if surplus < 0 { surplus = 0 } gc.Value = fmt.Sprintf("%d", surplus) gc.Detail = fmt.Sprintf("Proposal ready candidates beyond current unmet demand (%d ready, %d unmet slots).", v.Banner.ProposalReadyCandidates, unmet) switch { case surplus > 0: gc.State = "ok" case v.Banner.ProposalReadyCandidates > 0: gc.State = "watch" default: gc.State = "risk" } } cards = append(cards, gc) // Staffing Confidence: how much of the open demand has at least one proposal ready screen. sc := ExecutiveCard{Key: "staffing_confidence", Title: "Staffing Confidence"} if activeReqs == 0 { sc.NoData = true sc.State = "empty" sc.DataNote = "Feeds from stored screening evaluations against active requirements. Add requirements and screen candidates to light this up." } else { pct := decimal.NewFromInt(greenCoveredReqs). Div(decimal.NewFromInt(activeReqs)). Mul(decimal.NewFromInt(100)).Round(0) sc.Value = pct.String() + "%" sc.Detail = fmt.Sprintf("%d of %d active requirements have at least one proposal ready screen.", greenCoveredReqs, activeReqs) switch { case pct.GreaterThanOrEqual(decimal.NewFromInt(75)): sc.State = "ok" case pct.GreaterThanOrEqual(decimal.NewFromInt(40)): sc.State = "watch" default: sc.State = "risk" } } cards = append(cards, sc) return cards } func bandToState(band string) string { switch band { case "green": return "ok" case "yellow": return "watch" default: return "risk" } }