+
+ Showing all accounts including @churnedCount churned.
+ Hide churned
+
+ }
+
@* Summary stat cards *@
@@ -193,6 +216,7 @@
+
Clear
diff --git a/src/PowderCoating.Web/wwwroot/js/inventory-catalog-lookup.js b/src/PowderCoating.Web/wwwroot/js/inventory-catalog-lookup.js
index 6c845d3..7748a31 100644
--- a/src/PowderCoating.Web/wwwroot/js/inventory-catalog-lookup.js
+++ b/src/PowderCoating.Web/wwwroot/js/inventory-catalog-lookup.js
@@ -62,23 +62,25 @@
const items = await resp.json();
if (items.length === 0) {
- // No catalog match — fall back to AI if available
- hideStatus();
- if (typeof window._runInventoryAiLookup === 'function') {
- showStatus('info', 'Not in catalog — searching with AI…');
- await window._runInventoryAiLookup();
- } else {
- showStatus('warning', 'No match found in the catalog. Enter details manually or enable AI Lookup.');
- }
+ // Nothing in catalog — go straight to AI
+ await runAiOrWarn();
return;
}
- if (items.length === 1) {
+ // Single exact match (vendor + color name both match precisely) — auto-fill
+ if (items.length === 1 && items[0].isExact) {
await fillFields(items[0]);
return;
}
- // Multiple matches — let the user pick via modal
+ // Exact match exists but so do other results — auto-fill the exact one
+ const exactMatches = items.filter(i => i.isExact);
+ if (exactMatches.length === 1) {
+ await fillFields(exactMatches[0]);
+ return;
+ }
+
+ // No exact match (or ambiguous) — show picker modal with "Not Listed" escape hatch
hideStatus();
showPickerModal(items);
@@ -89,6 +91,18 @@
}
});
+ // ── AI fallback helper ───────────────────────────────────────────────────
+
+ async function runAiOrWarn() {
+ hideStatus();
+ if (typeof window._runInventoryAiLookup === 'function') {
+ showStatus('info', 'Not in catalog — searching online with AI…');
+ await window._runInventoryAiLookup();
+ } else {
+ showStatus('warning', 'No match found in the catalog. Enter details manually or enable AI Lookup.');
+ }
+ }
+
// ── Fill fields from a catalog result ────────────────────────────────────
async function fillFields(item) {
@@ -368,6 +382,12 @@