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 <noreply@anthropic.com>
This commit is contained in:
2026-05-24 17:58:23 -04:00
parent b7fcefa765
commit 026e646295
3 changed files with 39 additions and 1 deletions
@@ -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<Vendor>(dto);
vendor.CompanyId = currentUser!.CompanyId;
vendor.CompanyId = companyId;
if (dto.CategoryIds.Any())
{