@managesome/eposmatic-toolkit 0.2.489 → 0.2.490

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,5 +1,5 @@
1
- import { ICategory, IIncludedCategory, IItem, IKitchenInventory } from '../../schemas';
2
- import { ICatalog, IMinifiedCategory, IMinifiedItem, ISimplifiedCatalog, ISimplifiedCatalogItem, ISimplifiedCategory, ISimplifiedItem, IWarehouseCatalog } from '../types';
1
+ import { ICategory, IIncludedCategory, IInventoryCategory, IItem, IKitchenInventory } from '../../schemas';
2
+ import { ICatalog, IInventoryCategoryWithItems, IInventoryIncludedCategory, 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;
5
5
  export declare function getSimpleCatalogFetchedData(categories: ISimplifiedCategory[], items: ISimplifiedItem[]): ISimplifiedCatalog[];
@@ -36,4 +36,10 @@ export declare function getInventoryMappedItems(inventory: IKitchenInventory[]):
36
36
  *
37
37
  * When includedCategories is empty, returns ALL items (no filter).
38
38
  */
39
- export declare function getSelectedVendorInventoryItems(mappedInventory: Record<string, IKitchenInventory[]>, includedCategories: IIncludedCategory[]): IKitchenInventory[];
39
+ export declare function getSelectedVendorInventoryItems(mappedInventory: Record<string, IKitchenInventory[]>, includedCategories: IInventoryIncludedCategory[]): IKitchenInventory[];
40
+ /**
41
+ * Group inventory categories with their items, including a synthetic
42
+ * "Uncategorized" entry for items without a category_id.
43
+ * Mirrors getWarehouseCatalogFetchedData for the admin panel.
44
+ */
45
+ export declare function getGroupedInventoryCategories(categories: IInventoryCategory[], items: IKitchenInventory[]): IInventoryCategoryWithItems[];
@@ -17,6 +17,7 @@ exports.getSelectedCatalogs = getSelectedCatalogs;
17
17
  exports.getSelectedVendorCatalogs = getSelectedVendorCatalogs;
18
18
  exports.getInventoryMappedItems = getInventoryMappedItems;
19
19
  exports.getSelectedVendorInventoryItems = getSelectedVendorInventoryItems;
20
+ exports.getGroupedInventoryCategories = getGroupedInventoryCategories;
20
21
  const utils_1 = require("../utils");
21
22
  const catalog_conversion_1 = require("../utils/catalog-conversion");
22
23
  const minified_catalog_1 = require("../utils/minified-catalog");
@@ -282,3 +283,56 @@ function getSelectedVendorInventoryItems(mappedInventory, includedCategories) {
282
283
  }
283
284
  return result;
284
285
  }
286
+ // ============================================================================
287
+ // Admin Panel: Group inventory categories with their items (incl. uncategorized)
288
+ // Mirrors getWarehouseCatalogFetchedData but for IInventoryCategory/IKitchenInventory.
289
+ // ============================================================================
290
+ /**
291
+ * Group inventory categories with their items, including a synthetic
292
+ * "Uncategorized" entry for items without a category_id.
293
+ * Mirrors getWarehouseCatalogFetchedData for the admin panel.
294
+ */
295
+ function getGroupedInventoryCategories(categories, items) {
296
+ const result = [];
297
+ // Group items by category_id
298
+ const itemsByCategory = {};
299
+ const uncategorizedItems = [];
300
+ for (let i = 0; i < items.length; i++) {
301
+ const item = items[i];
302
+ if (item.category_id) {
303
+ if (!itemsByCategory[item.category_id])
304
+ itemsByCategory[item.category_id] = [];
305
+ itemsByCategory[item.category_id].push(item);
306
+ }
307
+ else {
308
+ uncategorizedItems.push(item);
309
+ }
310
+ }
311
+ // Add each category with its items, sorted by category sort_id
312
+ const sortedCategories = [...categories].sort((a, b) => a.sort_id - b.sort_id);
313
+ for (const cat of sortedCategories) {
314
+ result.push({
315
+ category: cat,
316
+ items: itemsByCategory[cat.ref_id] || [],
317
+ });
318
+ }
319
+ // Append uncategorized items as a synthetic category (ref_id: null so the API receives null, not a fake string)
320
+ if (uncategorizedItems.length > 0) {
321
+ const maxSortId = categories.length > 0 ? Math.max(...categories.map((c) => c.sort_id)) : 0;
322
+ result.push({
323
+ category: {
324
+ _id: null,
325
+ ref_id: null,
326
+ tenant_id: '',
327
+ name: 'Uncategorized',
328
+ subtitle: '',
329
+ active: true,
330
+ sort_id: maxSortId + 1,
331
+ createdAt: new Date(0),
332
+ updatedAt: new Date(0),
333
+ },
334
+ items: uncategorizedItems,
335
+ });
336
+ }
337
+ return result;
338
+ }
@@ -12,6 +12,7 @@ export * from './hubrise_deliveries';
12
12
  export * from './hubrise_location';
13
13
  export * from './hubrise_orders';
14
14
  export * from './internal-leads';
15
+ export * from './inventory-catalog';
15
16
  export * from './kpra-generate-invoice';
16
17
  export * from './marketing';
17
18
  export * from './order-engine';
@@ -28,6 +28,7 @@ __exportStar(require("./hubrise_deliveries"), exports);
28
28
  __exportStar(require("./hubrise_location"), exports);
29
29
  __exportStar(require("./hubrise_orders"), exports);
30
30
  __exportStar(require("./internal-leads"), exports);
31
+ __exportStar(require("./inventory-catalog"), exports);
31
32
  __exportStar(require("./kpra-generate-invoice"), exports);
32
33
  __exportStar(require("./marketing"), exports);
33
34
  __exportStar(require("./order-engine"), exports);
@@ -0,0 +1,18 @@
1
+ import { IInventoryCategory, IKitchenInventory } from '../../schemas';
2
+ /**
3
+ * Included category entry for the admin panel's vendor inventory context.
4
+ * Allows null category_id for uncategorized items, unlike IIncludedCategory
5
+ * (which uses category_id: string for courses/menus).
6
+ */
7
+ export interface IInventoryIncludedCategory {
8
+ category_id: string | null;
9
+ excluded_items: string[];
10
+ }
11
+ export type IInventoryCategoryDisplay = Omit<IInventoryCategory, '_id' | 'ref_id'> & {
12
+ _id: string | null;
13
+ ref_id: string | null;
14
+ };
15
+ export interface IInventoryCategoryWithItems {
16
+ category: IInventoryCategoryDisplay;
17
+ items: IKitchenInventory[];
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@managesome/eposmatic-toolkit",
3
- "version": "0.2.489",
3
+ "version": "0.2.490",
4
4
  "description": "A Toolkit Library for Eposmatic",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",