Hide churned trial accounts from company/health screens by default

- Companies list and Company Health now hide Expired/Canceled accounts
  whose subscription ended 14+ days ago; show/hide toggle via banner
- KPI cards on Company Health exclude churned tenants when hidden
- showChurned param threads through sort, pagination, search, and filter forms
- Powder catalog: fix missing UnitPrice on user-contributed entries;
  add back-sync to fill catalog gaps on existing matches; wire
  AiAugmentFromUrl and manual inventory Create into catalog contribute path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 13:59:12 -04:00
parent a73f14fa7f
commit 2ad6df1195
7 changed files with 164 additions and 15 deletions
@@ -26,11 +26,13 @@
var totalPages = (int)(ViewBag.TotalPages ?? 1);
var totalCount = (int)(ViewBag.TotalCount ?? 0);
var impersonatingId = (int?)(ViewBag.ImpersonatingCompanyId);
var showChurned = (bool)(ViewBag.ShowChurned ?? false);
var churnedCount = (int)(ViewBag.ChurnedCount ?? 0);
string SortLink(string col)
{
var dir = (sortColumn == col && sortDirection == "asc") ? "desc" : "asc";
return Url.Action("Index", new { searchTerm, sortColumn = col, sortDirection = dir, pageNumber = 1, pageSize })!;
return Url.Action("Index", new { searchTerm, sortColumn = col, sortDirection = dir, pageNumber = 1, pageSize, showChurned })!;
}
string SortIcon(string col)
@@ -54,6 +56,7 @@
<input type="hidden" name="sortColumn" value="@sortColumn" />
<input type="hidden" name="sortDirection" value="@sortDirection" />
<input type="hidden" name="pageSize" value="@pageSize" />
<input type="hidden" name="showChurned" value="@showChurned.ToString().ToLower()" />
<div class="col-md-6">
<div class="input-group">
<span class="input-group-text"><i class="bi bi-search"></i></span>
@@ -75,6 +78,25 @@
</div>
</div>
@if (churnedCount > 0 && !showChurned)
{
<div class="alert alert-secondary alert-permanent d-flex align-items-center gap-2 mb-3 py-2">
<i class="bi bi-eye-slash text-muted"></i>
<span class="small"><strong>@churnedCount</strong> churned @(churnedCount == 1 ? "account" : "accounts") (expired or canceled 14+ days ago) hidden.</span>
<a href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = 1, pageSize, showChurned = true })"
class="btn btn-sm btn-outline-secondary ms-auto py-0">Show churned</a>
</div>
}
else if (showChurned && churnedCount > 0)
{
<div class="alert alert-warning alert-permanent d-flex align-items-center gap-2 mb-3 py-2">
<i class="bi bi-eye text-warning"></i>
<span class="small">Showing all accounts including <strong>@churnedCount</strong> churned.</span>
<a href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = 1, pageSize, showChurned = false })"
class="btn btn-sm btn-outline-secondary ms-auto py-0">Hide churned</a>
</div>
}
<div class="card shadow-sm">
<div class="card-body p-0">
@if (Model != null && Model.Any())
@@ -313,18 +335,18 @@
<nav>
<ul class="pagination pagination-sm mb-0">
<li class="page-item @(pageNumber == 1 ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = pageNumber - 1, pageSize })">
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = pageNumber - 1, pageSize, showChurned })">
<i class="bi bi-chevron-left"></i>
</a>
</li>
@for (int p = Math.Max(1, pageNumber - 2); p <= Math.Min(totalPages, pageNumber + 2); p++)
{
<li class="page-item @(p == pageNumber ? "active" : "")">
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = p, pageSize })">@p</a>
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = p, pageSize, showChurned })">@p</a>
</li>
}
<li class="page-item @(pageNumber == totalPages ? "disabled" : "")">
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = pageNumber + 1, pageSize })">
<a class="page-link" href="@Url.Action("Index", new { searchTerm, sortColumn, sortDirection, pageNumber = pageNumber + 1, pageSize, showChurned })">
<i class="bi bi-chevron-right"></i>
</a>
</li>
@@ -464,6 +486,7 @@
const url = new URL(window.location.href);
url.searchParams.set('pageSize', size);
url.searchParams.set('pageNumber', '1');
url.searchParams.set('showChurned', '@showChurned.ToString().ToLower()');
window.location.href = url.toString();
}
@@ -4,6 +4,9 @@
@{
ViewData["Title"] = "Company Health";
var showChurned = (bool)(ViewBag.ShowChurned ?? false);
var churnedCount = (int)(ViewBag.ChurnedCount ?? 0);
string RiskBadge(ChurnRisk r) => r switch {
ChurnRisk.Healthy => "bg-success",
ChurnRisk.AtRisk => "bg-warning text-dark",
@@ -73,6 +76,26 @@
</div>
</div>
@* Churned account visibility banner *@
@if (churnedCount > 0 && !showChurned)
{
<div class="alert alert-secondary alert-permanent d-flex align-items-center gap-2 mb-3 py-2">
<i class="bi bi-eye-slash text-muted"></i>
<span class="small"><strong>@churnedCount</strong> churned @(churnedCount == 1 ? "account" : "accounts") (expired or canceled 14+ days ago) hidden from scores and totals.</span>
<a href="@Url.Action("Index", new { risk = ViewBag.Risk, search = ViewBag.Search, configIssuesOnly = ViewBag.ConfigIssuesOnly, showChurned = true })"
class="btn btn-sm btn-outline-secondary ms-auto py-0">Show churned</a>
</div>
}
else if (showChurned && churnedCount > 0)
{
<div class="alert alert-warning alert-permanent d-flex align-items-center gap-2 mb-3 py-2">
<i class="bi bi-eye text-warning"></i>
<span class="small">Showing all accounts including <strong>@churnedCount</strong> churned.</span>
<a href="@Url.Action("Index", new { risk = ViewBag.Risk, search = ViewBag.Search, configIssuesOnly = ViewBag.ConfigIssuesOnly, showChurned = false })"
class="btn btn-sm btn-outline-secondary ms-auto py-0">Hide churned</a>
</div>
}
@* Summary stat cards *@
<div class="row g-3 mb-3">
<div class="col-6 col-lg-3">
@@ -193,6 +216,7 @@
<label class="form-check-label small" for="configOnly">Config issues only</label>
</div>
</div>
<input type="hidden" name="showChurned" value="@showChurned.ToString().ToLower()" />
<div class="col-auto">
<button class="btn btn-sm btn-primary">Filter</button>
<a asp-action="Index" class="btn btn-sm btn-outline-secondary ms-1">Clear</a>