From 58a0010ae87237146fe33d5b731ead45ec6a1ac4 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Sat, 20 Jun 2026 10:10:04 -0400 Subject: [PATCH] Label blank account option "(None)" when no company default is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../Controllers/CatalogItemsController.cs | 7 +++++++ src/PowderCoating.Web/Controllers/InventoryController.cs | 7 +++++++ src/PowderCoating.Web/Views/CatalogItems/Create.cshtml | 4 ++-- src/PowderCoating.Web/Views/CatalogItems/Edit.cshtml | 4 ++-- src/PowderCoating.Web/Views/Inventory/Create.cshtml | 4 ++-- src/PowderCoating.Web/Views/Inventory/Edit.cshtml | 4 ++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/PowderCoating.Web/Controllers/CatalogItemsController.cs b/src/PowderCoating.Web/Controllers/CatalogItemsController.cs index 76dba16..11cf9ce 100644 --- a/src/PowderCoating.Web/Controllers/CatalogItemsController.cs +++ b/src/PowderCoating.Web/Controllers/CatalogItemsController.cs @@ -693,6 +693,13 @@ namespace PowderCoating.Web.Controllers ViewBag.RevenueAccounts = revenueAccounts; ViewBag.CogsAccounts = cogsAccounts; + + // 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.HasDefaultRevenueAccount = prefs?.DefaultRevenueAccountId != null; + ViewBag.HasDefaultCogsAccount = prefs?.DefaultCogsAccountId != null; } /// diff --git a/src/PowderCoating.Web/Controllers/InventoryController.cs b/src/PowderCoating.Web/Controllers/InventoryController.cs index 633ca9e..7dff1ad 100644 --- a/src/PowderCoating.Web/Controllers/InventoryController.cs +++ b/src/PowderCoating.Web/Controllers/InventoryController.cs @@ -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; } /// diff --git a/src/PowderCoating.Web/Views/CatalogItems/Create.cshtml b/src/PowderCoating.Web/Views/CatalogItems/Create.cshtml index 724387b..e6cbadd 100644 --- a/src/PowderCoating.Web/Views/CatalogItems/Create.cshtml +++ b/src/PowderCoating.Web/Views/CatalogItems/Create.cshtml @@ -131,7 +131,7 @@
Account credited when this item is invoiced.
@@ -139,7 +139,7 @@ Account debited when materials are consumed. diff --git a/src/PowderCoating.Web/Views/CatalogItems/Edit.cshtml b/src/PowderCoating.Web/Views/CatalogItems/Edit.cshtml index 56f51ef..41a75ff 100644 --- a/src/PowderCoating.Web/Views/CatalogItems/Edit.cshtml +++ b/src/PowderCoating.Web/Views/CatalogItems/Edit.cshtml @@ -134,7 +134,7 @@
Account credited when this item is invoiced.
@@ -142,7 +142,7 @@ Account debited when materials are consumed. diff --git a/src/PowderCoating.Web/Views/Inventory/Create.cshtml b/src/PowderCoating.Web/Views/Inventory/Create.cshtml index 64d9b7d..bdd41e9 100644 --- a/src/PowderCoating.Web/Views/Inventory/Create.cshtml +++ b/src/PowderCoating.Web/Views/Inventory/Create.cshtml @@ -375,7 +375,7 @@ Asset account where inventory value is tracked (e.g., 1200 Inventory - Powder). @@ -384,7 +384,7 @@ Expense account debited when this material is consumed on a job. diff --git a/src/PowderCoating.Web/Views/Inventory/Edit.cshtml b/src/PowderCoating.Web/Views/Inventory/Edit.cshtml index c4d51a0..d2954bc 100644 --- a/src/PowderCoating.Web/Views/Inventory/Edit.cshtml +++ b/src/PowderCoating.Web/Views/Inventory/Edit.cshtml @@ -374,7 +374,7 @@ Asset account where inventory value is tracked (e.g., 1200 Inventory - Powder). @@ -383,7 +383,7 @@ Expense account debited when this material is consumed on a job.