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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user