feat: enhance ingredient matching rules with keyword matching and add chocolate detection
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-08 17:36:06 +02:00
parent bd78b1de81
commit 853e853e5e
2 changed files with 36 additions and 12 deletions
@@ -68,12 +68,11 @@ function hasPorkLikeSignal(normalized: string): boolean {
normalized.includes('bacn') ||
normalized.includes('baco') ||
/\bbac[a-z0-9]{1,5}\b/.test(normalized) ||
/\bsidflask\b/.test(normalized) ||
/\bpancetta\b/.test(normalized) ||
/\bflask\b/.test(normalized) ||
/\bflaskfile\b/.test(normalized) ||
/\bkarr[eé]\b/.test(normalized) ||
/\bkotlett\b/.test(normalized)
normalized.includes('sidflask') ||
normalized.includes('pancetta') ||
normalized.includes('flask') ||
normalized.includes('karre') ||
normalized.includes('kotlett')
);
}
@@ -699,6 +698,24 @@ export class ReceiptImportService {
if (hit) return hit;
}
// ── Regel: Choklad & spreads (Nutella, sjokolade, m.m.) ─────────────
const hasChocolateSignal =
normalized.includes('nutella') ||
normalized.includes('chocolate') ||
normalized.includes('choklad') ||
normalized.includes('sjokolade') ||
normalized.includes('kakao') ||
normalized.includes('spreads');
if (hasChocolateSignal) {
const chocolate = findCategory({
name: 'choklad & spreads',
includes: 'sötsaker',
});
const hit = toSuggestion(chocolate, 'high');
if (hit) return hit;
}
// ── Regel: Korvfamiljen ─────────────────────────────────────────────
const hasSausageSignal =
/\bkorv\b/.test(normalized) ||