@7365admin1/core 3.76.0 → 3.77.0

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.
package/dist/index.mjs CHANGED
@@ -8925,6 +8925,20 @@ var NOTIFICATION_CATEGORIES = [
8925
8925
  vendorDefault: true,
8926
8926
  rendered: true
8927
8927
  },
8928
+ // Inventory (2026-09-17). Sent from `iservice365-API-core`'s inventory
8929
+ // module: a stock request waiting for approval and stock falling to its alert
8930
+ // level go to that store's staff; a decided request goes to the person who
8931
+ // asked. The caller checks `rendered` before it sends, so the sender and this
8932
+ // switch cannot land out of order.
8933
+ {
8934
+ key: "inventory",
8935
+ label: "Inventory",
8936
+ description: "When a stock request needs your approval or has been decided, or stock you look after runs low.",
8937
+ channels: { inApp: true, push: true, email: false },
8938
+ channelNote: { email: NO_EMAIL_RECIPIENT },
8939
+ permissionResources: ["inventory"],
8940
+ rendered: true
8941
+ },
8928
8942
  {
8929
8943
  key: "serviceProviderInvite",
8930
8944
  label: "Service Provider Invitations",
@@ -76478,6 +76492,7 @@ function highSeverityIncidentCount(severities) {
76478
76492
  ).length;
76479
76493
  }
76480
76494
  var SUPPLY_BASIS_LOWEST_QUANTITY = "lowest-quantity";
76495
+ var SUPPLY_BASIS_BELOW_ALERT_LEVEL = "below-alert-level";
76481
76496
  var SUPPLY_THRESHOLD_NOT_IN_MODEL = "Supplies do not record a stock threshold, so these are the lowest-quantity items rather than items below a level.";
76482
76497
 
76483
76498
  // src/repositories/new-dashboard.repo.ts
@@ -77336,6 +77351,32 @@ function useNewDashboardRepo() {
77336
77351
  { $unwind: { path: "$scheduleDoc", preserveNullAndEmptyArrays: false } }
77337
77352
  ];
77338
77353
  }
77354
+ async function lowStockItems(site, serviceType) {
77355
+ const stores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1 } }).toArray();
77356
+ if (stores.length) {
77357
+ const items2 = await db2.collection("inventory.items").aggregate([
77358
+ {
77359
+ $match: {
77360
+ store: { $in: stores.map((store) => store._id) },
77361
+ status: "active",
77362
+ reorderLevel: { $gt: 0 },
77363
+ $expr: { $lte: ["$onHand", "$reorderLevel"] }
77364
+ }
77365
+ },
77366
+ { $sort: { onHand: 1 } },
77367
+ { $limit: 5 },
77368
+ { $project: { _id: 1, name: 1, qty: "$onHand" } }
77369
+ ]).toArray();
77370
+ return { items: items2, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
77371
+ }
77372
+ const items = await supplyCollection.aggregate([
77373
+ { $match: { site, serviceType, status: "active" } },
77374
+ { $sort: { qty: 1 } },
77375
+ { $limit: 3 },
77376
+ { $project: { _id: 1, name: 1, qty: 1 } }
77377
+ ]).toArray();
77378
+ return { items, basis: SUPPLY_BASIS_LOWEST_QUANTITY };
77379
+ }
77339
77380
  async function getServiceDashboard({
77340
77381
  site,
77341
77382
  serviceType,
@@ -77393,12 +77434,7 @@ function useNewDashboardRepo() {
77393
77434
  }
77394
77435
  }
77395
77436
  ]).toArray(),
77396
- supplyCollection.aggregate([
77397
- { $match: { site, serviceType, status: "active" } },
77398
- { $sort: { qty: 1 } },
77399
- { $limit: 3 },
77400
- { $project: { _id: 1, name: 1, qty: 1 } }
77401
- ]).toArray(),
77437
+ lowStockItems(site, serviceType),
77402
77438
  areaChecklistCollection.aggregate([
77403
77439
  ...areaChecklistScheduleLookup(site, serviceType, periodRange),
77404
77440
  {
@@ -77460,7 +77496,7 @@ function useNewDashboardRepo() {
77460
77496
  )
77461
77497
  },
77462
77498
  supplyAlert: {
77463
- items: supplyAlertReport.map((item) => ({
77499
+ items: supplyAlertReport.items.map((item) => ({
77464
77500
  name: item.name,
77465
77501
  qty: item.qty
77466
77502
  })),
@@ -77468,8 +77504,8 @@ function useNewDashboardRepo() {
77468
77504
  // with no threshold, because `site.supplies` records no stock level to
77469
77505
  // compare against. Naming the ordering stops 900 gloves being drawn as
77470
77506
  // a warning. No threshold is invented here.
77471
- basis: SUPPLY_BASIS_LOWEST_QUANTITY,
77472
- thresholdUnavailableReason: SUPPLY_THRESHOLD_NOT_IN_MODEL
77507
+ basis: supplyAlertReport.basis,
77508
+ ...supplyAlertReport.basis === SUPPLY_BASIS_LOWEST_QUANTITY ? { thresholdUnavailableReason: SUPPLY_THRESHOLD_NOT_IN_MODEL } : {}
77473
77509
  },
77474
77510
  taskCompleted: {
77475
77511
  completed: tFacet.completed[0]?.count ?? 0,