search update
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user