Label blank account option "(None)" when no company default is set

The item account dropdowns showed "(Default … account)" on the blank
option even when the company hadn't configured a default — implying a
fallback that didn't exist. Now the blank option reads "(None)" unless a
matching company default is configured, in which case it keeps the
"(Default …)" label (the dropdown pre-selects the real account anyway).
"Has default" flags are computed in the shared dropdown-population helpers
so every render path (Create/Edit GET and invalid-POST) gets them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-20 10:10:04 -04:00
parent ee86d7aaf6
commit 58a0010ae8
6 changed files with 22 additions and 8 deletions
@@ -1667,6 +1667,13 @@ public class InventoryController : Controller
.OrderBy(a => a.AccountNumber)
.Select(a => new SelectListItem($"{a.AccountNumber} {a.Name}", a.Id.ToString()))
.ToList();
// Whether the company has configured default accounts — the views use this to label the
// blank dropdown option "(Default …)" vs "(None)".
var prefs = await _unitOfWork.CompanyPreferences
.FirstOrDefaultAsync(p => p.CompanyId == companyId && !p.IsDeleted);
ViewBag.HasDefaultInventoryAccount = prefs?.DefaultInventoryAccountId != null;
ViewBag.HasDefaultCogsAccount = prefs?.DefaultCogsAccountId != null;
}
/// <summary>