fix(receipt-import): route egg items away from allergy dairy
This commit is contained in:
@@ -515,6 +515,28 @@ export class ReceiptImportService {
|
||||
if (fallbackHit) return fallbackHit;
|
||||
}
|
||||
|
||||
// ── Regel: Ägg (saknar egen L2/L3 i nuvarande träd) ────────────────
|
||||
const hasEggSignal =
|
||||
/\bagg\b/.test(normalized) ||
|
||||
/\begg\b/.test(normalized) ||
|
||||
/\binne\b/.test(normalized) ||
|
||||
/\b24p\b/.test(normalized);
|
||||
|
||||
if (hasEggSignal) {
|
||||
const l1DairyEgg = categories.find(
|
||||
(c) => c.path.toLowerCase() === 'mejeri, ost & ägg',
|
||||
);
|
||||
if (l1DairyEgg) {
|
||||
return {
|
||||
categoryId: l1DairyEgg.id,
|
||||
categoryName: l1DairyEgg.name,
|
||||
path: l1DairyEgg.path,
|
||||
confidence: 'high',
|
||||
usedFallback: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ── Regel: Te ────────────────────────────────────────────────────────
|
||||
const isTea =
|
||||
/\bte\b/.test(normalized) ||
|
||||
@@ -693,6 +715,30 @@ export class ReceiptImportService {
|
||||
}
|
||||
}
|
||||
|
||||
const hasEggSignal =
|
||||
/\bagg\b/.test(normalized) ||
|
||||
/\begg\b/.test(normalized) ||
|
||||
/\binne\b/.test(normalized) ||
|
||||
/\b24p\b/.test(normalized);
|
||||
|
||||
if (hasEggSignal && suggestion.path.toLowerCase().includes('allergi mejeri')) {
|
||||
const l1DairyEgg = categories.find(
|
||||
(c) => c.path.toLowerCase() === 'mejeri, ost & ägg',
|
||||
);
|
||||
if (l1DairyEgg) {
|
||||
this.logger.log(
|
||||
`AI contradiction-guard: "${rawName}" remappas från "${suggestion.path}" till "${l1DairyEgg.path}"`,
|
||||
);
|
||||
return {
|
||||
categoryId: l1DairyEgg.id,
|
||||
categoryName: l1DairyEgg.name,
|
||||
path: l1DairyEgg.path,
|
||||
confidence: 'high',
|
||||
usedFallback: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const hasCreamSignal =
|
||||
/\bvispgradde\b/.test(normalized) ||
|
||||
/\bmatlagningsgradde\b/.test(normalized) ||
|
||||
|
||||
Reference in New Issue
Block a user