search update

This commit is contained in:
seb
2026-07-19 17:09:14 +02:00
parent 06c235055a
commit eea8e99358
2 changed files with 80 additions and 40 deletions

View File

@@ -77,6 +77,22 @@ function shapeCategories(counts, byId) {
return categories;
}
/** Ensure every applied filter id appears in categories (count 0 if no hits). */
function ensureFilterCategories(categories, filter, byId) {
for (const id of filter) {
if (id === '' || id === null || categories[id]) {
continue;
}
const meta = byId[id] ?? {};
categories[id] = {
count: 0,
name: meta.name ?? null,
parent: meta.parent ?? null,
};
}
return categories;
}
function shapeArticle(row, steuersaetze) {
const taxRow = steuersaetze.find((item) => item.kSteuerklasse === row.kSteuerklasse);
const brutto = bruttoFromNetto(row.fVKNEtto, row.kSteuerklasse, steuersaetze);
@@ -184,8 +200,12 @@ export async function searchArticles(target, filter = [''], offset = 0, maxCount
loadCategoryCache(pool),
loadSteuersatz(),
]);
const categories = shapeCategories(
buildKatAgg(result.recordset, categoryData.parentMap),
const categories = ensureFilterCategories(
shapeCategories(
buildKatAgg(result.recordset, categoryData.parentMap),
categoryData.byId
),
filter,
categoryData.byId
);
const length = result.recordset.length;