Warn on label scan when product already exists in tenant inventory
After resolving manufacturer + SKU from the scan, ScanLabel now queries the tenant's InventoryItems: first by ManufacturerPartNumber exact match (most precise), then by ColorName + Manufacturer fuzzy match as fallback. If a match is found, the response includes existingInventoryId and existingInventoryName. The JS fillFromScan() shows a warning banner with a direct link to the existing item instead of the normal success message. Form fields are still pre-filled so the user can proceed to add a new entry (e.g. a different lot or bag size) if that was the intent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -404,7 +404,16 @@
|
||||
? ' <span class="badge bg-success ms-1">Added to platform catalog</span>'
|
||||
: '';
|
||||
|
||||
if (filled.length > 0) {
|
||||
if (data.existingInventoryId) {
|
||||
const itemName = data.existingInventoryName || data.colorName || 'This product';
|
||||
const filledNote = filled.length > 0 ? ` Fields pre-filled from scan.` : '';
|
||||
showFormStatus('warning',
|
||||
`<i class="bi bi-exclamation-triangle-fill me-1"></i>` +
|
||||
`<strong>${itemName}</strong> is already in your inventory. ` +
|
||||
`<a href="/Inventory/Details/${data.existingInventoryId}" class="alert-link fw-semibold">View existing item</a>` +
|
||||
` — or continue below to add a new entry (e.g. a new lot or bag size).${filledNote}${catalogNote}`
|
||||
);
|
||||
} else if (filled.length > 0) {
|
||||
showFormStatus('success', `Filled from label scan: ${filled.join(', ')}.${catalogNote}`);
|
||||
} else {
|
||||
showFormStatus('warning', `Label scanned but no empty fields to fill.${catalogNote}`);
|
||||
|
||||
Reference in New Issue
Block a user