@managesome/eposmatic-toolkit 0.2.486 → 0.2.488
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICategory, IIncludedCategory, IItem } from '../../schemas';
|
|
1
|
+
import { ICategory, IIncludedCategory, IItem, IKitchenInventory } from '../../schemas';
|
|
2
2
|
import { ICatalog, IMinifiedCategory, IMinifiedItem, ISimplifiedCatalog, ISimplifiedCatalogItem, ISimplifiedCategory, ISimplifiedItem, IWarehouseCatalog } from '../types';
|
|
3
3
|
export declare function getPartialSimplifiedItem(item: Partial<ISimplifiedItem>): Partial<ISimplifiedCatalogItem>;
|
|
4
4
|
export declare function getSimplifiedItemWithPrice(item: ISimplifiedItem): ISimplifiedCatalogItem;
|
|
@@ -21,3 +21,19 @@ export declare function getSelectedVendorCatalogs(menus: {
|
|
|
21
21
|
_id: string;
|
|
22
22
|
included_categories: IIncludedCategory[];
|
|
23
23
|
}[], selectedVendorId: string | null, mappedCatalog: Record<string, IWarehouseCatalog>): IWarehouseCatalog[];
|
|
24
|
+
/**
|
|
25
|
+
* Group inventory items by category_id for O(1) lookup.
|
|
26
|
+
* Mirrors the warehouse's mappedCatalog: uses item.category_id directly
|
|
27
|
+
* as the key. Items with a null/undefined category_id are skipped —
|
|
28
|
+
* uncategorized handling belongs in the UI layer.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getInventoryMappedItems(inventory: IKitchenInventory[]): Record<string, IKitchenInventory[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Filter inventory items by a vendor's included_categories (whitelist).
|
|
33
|
+
* Mirrors getSelectedCatalogs: iterates only the vendor's assigned
|
|
34
|
+
* categories, does an O(1) lookup from pre-built mappedInventory,
|
|
35
|
+
* and filters out excluded_items per category.
|
|
36
|
+
*
|
|
37
|
+
* When includedCategories is empty, returns ALL items (no filter).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSelectedVendorInventoryItems(mappedInventory: Record<string, IKitchenInventory[]>, includedCategories: IIncludedCategory[]): IKitchenInventory[];
|
|
@@ -15,6 +15,8 @@ exports.getItemFetchedData = getItemFetchedData;
|
|
|
15
15
|
exports.renderBulkItemsUpdate = renderBulkItemsUpdate;
|
|
16
16
|
exports.getSelectedCatalogs = getSelectedCatalogs;
|
|
17
17
|
exports.getSelectedVendorCatalogs = getSelectedVendorCatalogs;
|
|
18
|
+
exports.getInventoryMappedItems = getInventoryMappedItems;
|
|
19
|
+
exports.getSelectedVendorInventoryItems = getSelectedVendorInventoryItems;
|
|
18
20
|
const utils_1 = require("../utils");
|
|
19
21
|
const catalog_conversion_1 = require("../utils/catalog-conversion");
|
|
20
22
|
const minified_catalog_1 = require("../utils/minified-catalog");
|
|
@@ -214,3 +216,69 @@ function getSelectedCatalogs(menus, selectedId, mappedCatalog) {
|
|
|
214
216
|
function getSelectedVendorCatalogs(menus, selectedVendorId, mappedCatalog) {
|
|
215
217
|
return getSelectedCatalogs(menus, selectedVendorId, mappedCatalog);
|
|
216
218
|
}
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Admin Panel: Inventory utility filtering
|
|
221
|
+
// Mirrors getSelectedCatalogs / getSelectedVendorCatalogs but works with flat
|
|
222
|
+
// IKitchenInventory[] items (inventory utility) instead of IWarehouseCatalog[].
|
|
223
|
+
// ============================================================================
|
|
224
|
+
/**
|
|
225
|
+
* Group inventory items by category_id for O(1) lookup.
|
|
226
|
+
* Mirrors the warehouse's mappedCatalog: uses item.category_id directly
|
|
227
|
+
* as the key. Items with a null/undefined category_id are skipped —
|
|
228
|
+
* uncategorized handling belongs in the UI layer.
|
|
229
|
+
*/
|
|
230
|
+
function getInventoryMappedItems(inventory) {
|
|
231
|
+
const map = {};
|
|
232
|
+
for (let i = 0; i < inventory.length; i++) {
|
|
233
|
+
const item = inventory[i];
|
|
234
|
+
if (!item.category_id)
|
|
235
|
+
continue;
|
|
236
|
+
if (!map[item.category_id])
|
|
237
|
+
map[item.category_id] = [];
|
|
238
|
+
map[item.category_id].push(item);
|
|
239
|
+
}
|
|
240
|
+
return map;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Filter inventory items by a vendor's included_categories (whitelist).
|
|
244
|
+
* Mirrors getSelectedCatalogs: iterates only the vendor's assigned
|
|
245
|
+
* categories, does an O(1) lookup from pre-built mappedInventory,
|
|
246
|
+
* and filters out excluded_items per category.
|
|
247
|
+
*
|
|
248
|
+
* When includedCategories is empty, returns ALL items (no filter).
|
|
249
|
+
*/
|
|
250
|
+
function getSelectedVendorInventoryItems(mappedInventory, includedCategories) {
|
|
251
|
+
if (!includedCategories || includedCategories.length === 0) {
|
|
252
|
+
const all = [];
|
|
253
|
+
const keys = Object.keys(mappedInventory);
|
|
254
|
+
for (let i = 0; i < keys.length; i++) {
|
|
255
|
+
const items = mappedInventory[keys[i]];
|
|
256
|
+
for (let j = 0; j < items.length; j++) {
|
|
257
|
+
all.push(items[j]);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return all;
|
|
261
|
+
}
|
|
262
|
+
const result = [];
|
|
263
|
+
for (let i = 0; i < includedCategories.length; i++) {
|
|
264
|
+
const { category_id, excluded_items } = includedCategories[i];
|
|
265
|
+
if (!category_id)
|
|
266
|
+
continue;
|
|
267
|
+
const items = mappedInventory[category_id];
|
|
268
|
+
if (!items)
|
|
269
|
+
continue;
|
|
270
|
+
if (excluded_items.length === 0) {
|
|
271
|
+
for (let j = 0; j < items.length; j++) {
|
|
272
|
+
result.push(items[j]);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
for (let j = 0; j < items.length; j++) {
|
|
277
|
+
if (!excluded_items.includes(items[j]._id)) {
|
|
278
|
+
result.push(items[j]);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { IWarehouseCategory, IWarehouseItem } from '../../schemas';
|
|
2
|
-
export interface IWarehouseCatalog extends IWarehouseCategory {
|
|
2
|
+
export interface IWarehouseCatalog extends Omit<IWarehouseCategory, '_id' | 'ref_id'> {
|
|
3
|
+
_id: string | null;
|
|
4
|
+
ref_id: string | null;
|
|
3
5
|
items: IWarehouseItem[];
|
|
4
6
|
}
|
|
@@ -95,10 +95,10 @@ function getWarehouseCatalogFetchedData(categories, items) {
|
|
|
95
95
|
.sort((a, b) => a.sort_id - b.sort_id);
|
|
96
96
|
if (uncategorizedItems.length > 0) {
|
|
97
97
|
const uncategorizedCatalog = {
|
|
98
|
-
_id:
|
|
98
|
+
_id: null,
|
|
99
99
|
brand_id: '',
|
|
100
100
|
warehouse_id: '',
|
|
101
|
-
ref_id:
|
|
101
|
+
ref_id: null,
|
|
102
102
|
image_url: null,
|
|
103
103
|
name: 'Uncategorized',
|
|
104
104
|
subtitle: '',
|