Fix account dropdowns: vendor auto-select + sub-type filtering
Inventory vendor auto-select: match the dropdown off the Manufacturer field (almost always populated and equal to the vendor for the shop's distributors) instead of the AI's price-conditional vendorName, which was only returned when a price was scraped. Centralizes the logic in a shared inventory-vendor-match.js used by catalog lookup, AI lookup, label scan, and manual entry; skips brands sold by multiple distributors (PPG, KP Pigments) so those stay manual. Account dropdowns filtered by sub-type now filter by parent AccountType, so accounts a company classifies under a non-standard sub-type still appear: Inventory account (Asset), AP account (Liability), pay-from/bank and Bank Reconciliation pickers (Asset + Liability). Deposit account is now a user-selectable dropdown on the Job and Quote deposit modals (Asset + Liability accounts) instead of a silent auto-pick of the first Checking/Cash account; falls back to the old behavior when left blank, and validates the chosen account belongs to the company. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1642,10 +1642,15 @@ public class InventoryController : Controller
|
||||
|
||||
var accounts = await _unitOfWork.Accounts.FindAsync(a => a.CompanyId == companyId && a.IsActive);
|
||||
|
||||
// Show ALL asset accounts, not just the Inventory sub-type. Companies that created
|
||||
// their inventory account manually often land on a different asset sub-type (e.g.
|
||||
// Other Current Asset), which previously left this dropdown empty. Listing every
|
||||
// asset account lets them pick whatever they actually use; Inventory sub-type
|
||||
// accounts are surfaced first as the recommended choice.
|
||||
ViewBag.InventoryAccounts = accounts
|
||||
.Where(a => a.AccountType == AccountType.Asset
|
||||
&& a.AccountSubType == AccountSubType.Inventory)
|
||||
.OrderBy(a => a.AccountNumber)
|
||||
.Where(a => a.AccountType == AccountType.Asset)
|
||||
.OrderByDescending(a => a.AccountSubType == AccountSubType.Inventory)
|
||||
.ThenBy(a => a.AccountNumber)
|
||||
.Select(a => new SelectListItem($"{a.AccountNumber} – {a.Name}", a.Id.ToString()))
|
||||
.ToList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user