fix(ancpi): correct PDF-to-parcel matching + UAT search priority

Critical fix: batch order documents are now matched by CF number
from parsed metadateCereri (documentsByCadastral), not by index.
Prevents PDF content mismatch when ePay returns docs in different order.

UAT search: name matches shown first, county-only matches after.
Typing "cluj" now shows CLUJ-NAPOCA before county "Cluj" matches.

Cleaned MinIO + DB of incorrectly mapped old test data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-23 09:29:11 +02:00
parent a59d9bc923
commit 0c94af75d3
4 changed files with 84 additions and 47 deletions
@@ -606,16 +606,24 @@ export function ParcelSyncModule() {
}
const isDigit = /^\d+$/.test(raw);
const query = normalizeText(raw);
const results = uatData
.filter((item) => {
if (isDigit) return item.siruta.startsWith(raw);
// Match UAT name or county name
if (normalizeText(item.name).includes(query)) return true;
if (item.county && normalizeText(item.county).includes(query))
return true;
return false;
})
.slice(0, 12);
// Filter and sort: UAT name matches first, then county-only matches
const nameMatches: typeof uatData = [];
const countyOnlyMatches: typeof uatData = [];
for (const item of uatData) {
if (isDigit) {
if (item.siruta.startsWith(raw)) nameMatches.push(item);
} else {
const nameMatch = normalizeText(item.name).includes(query);
const countyMatch =
item.county && normalizeText(item.county).includes(query);
if (nameMatch) nameMatches.push(item);
else if (countyMatch) countyOnlyMatches.push(item);
}
}
// UAT name matches first (priority), then county-only matches
const results = [...nameMatches, ...countyOnlyMatches].slice(0, 12);
setUatResults(results);
}, [uatQuery, uatData]);