From f0f3717681814c67e68eb31198d608d616c69e22 Mon Sep 17 00:00:00 2001 From: Scott Pouliot Date: Sun, 24 May 2026 17:58:23 -0400 Subject: [PATCH] Fix three bugs: vendor duplicate check, page size dropdown, label location - Vendor Create: reject duplicate company names (case-insensitive) before saving; works for both the standalone form and the inline quick-add modal - _Pagination: define changePageSize() JS function (was called but never existed, breaking page size dropdown on every paginated list) - Inventory Label: show bin/location on printed QR code labels Co-Authored-By: Claude Sonnet 4.6 --- .../Controllers/VendorsController.cs | 17 ++++++++++++++++- .../Views/Inventory/Label.cshtml | 15 +++++++++++++++ .../Views/Shared/_Pagination.cshtml | 8 ++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/PowderCoating.Web/Controllers/VendorsController.cs b/src/PowderCoating.Web/Controllers/VendorsController.cs index 01f60fd..f1f8d54 100644 --- a/src/PowderCoating.Web/Controllers/VendorsController.cs +++ b/src/PowderCoating.Web/Controllers/VendorsController.cs @@ -215,8 +215,23 @@ public class VendorsController : Controller try { var currentUser = await _userManager.GetUserAsync(User); + var companyId = currentUser!.CompanyId; + + var duplicate = await _unitOfWork.Vendors.FirstOrDefaultAsync( + v => v.CompanyId == companyId && v.CompanyName.ToLower() == dto.CompanyName.ToLower()); + if (duplicate != null) + { + var msg = $"A vendor named '{dto.CompanyName}' already exists."; + if (inline) + return Json(new { success = false, errors = new[] { msg } }); + ModelState.AddModelError(nameof(dto.CompanyName), msg); + await PopulateExpenseAccountsAsync(); + await PopulateVendorCategoriesAsync(dto.CategoryIds); + return View(dto); + } + var vendor = _mapper.Map(dto); - vendor.CompanyId = currentUser!.CompanyId; + vendor.CompanyId = companyId; if (dto.CategoryIds.Any()) { diff --git a/src/PowderCoating.Web/Views/Inventory/Label.cshtml b/src/PowderCoating.Web/Views/Inventory/Label.cshtml index 4661415..32c5c56 100644 --- a/src/PowderCoating.Web/Views/Inventory/Label.cshtml +++ b/src/PowderCoating.Web/Views/Inventory/Label.cshtml @@ -95,6 +95,16 @@ color: #333; } + .label-location { + font-size: 11px; + font-weight: 700; + color: #333; + background: #f0f0f0; + border-radius: 4px; + padding: 2px 8px; + letter-spacing: .03em; + } + .label-scan-hint { font-size: 9px; color: #888; @@ -158,6 +168,11 @@
@Model.Manufacturer
} + @if (!string.IsNullOrEmpty(Model.Location)) + { +
📍 @Model.Location
+ } +
Scan to log usage • Powder Coating Logix
diff --git a/src/PowderCoating.Web/Views/Shared/_Pagination.cshtml b/src/PowderCoating.Web/Views/Shared/_Pagination.cshtml index ef7918a..8a86ae0 100644 --- a/src/PowderCoating.Web/Views/Shared/_Pagination.cshtml +++ b/src/PowderCoating.Web/Views/Shared/_Pagination.cshtml @@ -83,4 +83,12 @@ + }