@7365admin1/core 3.99.1-staging.407 → 3.99.1-staging.409

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": minor
3
+ ---
4
+
5
+ Console audit: new action `inventory.store-type-repaired` (target `inventory-store`, keeps only `ownerType` and `name`) for the Super Admin inventory store-type repair in API-core.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": minor
3
+ ---
4
+
5
+ Dashboard Low Stock: each app's tile now lists only its own kind of organisation's inventory store at the site (a cleaning company no longer sees the security company's store, and the other way round), and the Property Management and Security dashboards gain the Low Stock tile (`supplyAlert`, basis `below-alert-level`) wherever their store serves the site. Sites without such a store are unchanged.
package/dist/index.d.ts CHANGED
@@ -808,7 +808,13 @@ declare enum ConsoleAuditAction {
808
808
  ROBOT_MAP_UPDATED = "robot.map-updated",
809
809
  ROBOT_MAP_REMOVED = "robot.map-removed",
810
810
  ROBOT_LIFT_REQUESTED = "robot.lift-requested",
811
- ROBOT_LIFT_RELEASED = "robot.lift-released"
811
+ ROBOT_LIFT_RELEASED = "robot.lift-released",
812
+ /**
813
+ * Seven365 staff correcting the kind of an inventory store (property store
814
+ * vs a service provider's own store) that was saved wrong. One row per store
815
+ * changed, recorded by API-core's inventory repair endpoint.
816
+ */
817
+ INVENTORY_STORE_TYPE_REPAIRED = "inventory.store-type-repaired"
812
818
  }
813
819
  /**
814
820
  * The three actions that live in `organization.controller.ts`.
@@ -832,7 +838,8 @@ declare enum ConsoleAuditTarget {
832
838
  CAMERA = "camera",
833
839
  SITE = "site",
834
840
  ROBOT = "robot",
835
- ROBOT_MAP = "robot-map"
841
+ ROBOT_MAP = "robot-map",
842
+ INVENTORY_STORE = "inventory-store"
836
843
  }
837
844
  /** A stored value is a primitive or it is not stored. */
838
845
  declare const AUDIT_VALUE_MAX_LENGTH = 120;
@@ -15643,6 +15650,47 @@ declare function useNewDashboardRepo(): {
15643
15650
  period?: Period | undefined;
15644
15651
  type?: string | undefined;
15645
15652
  }) => Promise<{
15653
+ supplyAlert: {
15654
+ items: {
15655
+ name: any;
15656
+ qty: any;
15657
+ }[];
15658
+ basis: "below-alert-level";
15659
+ };
15660
+ openWorkOrder: {
15661
+ count: any;
15662
+ inProgress: any;
15663
+ percentage: number | null;
15664
+ };
15665
+ openIncidents: {
15666
+ count: any;
15667
+ highSeverity: number | null;
15668
+ highSeverityUnavailableReason: string;
15669
+ percentage: number | null;
15670
+ };
15671
+ visitors: {
15672
+ count: any;
15673
+ currentlyOnSite: number;
15674
+ percentage: number | null;
15675
+ };
15676
+ patrolCompliance: {
15677
+ count: number | null;
15678
+ checkpointsDue: any;
15679
+ unavailableReason: string | null;
15680
+ missedCheckpoints: any;
15681
+ missed: any;
15682
+ percentage: number | null;
15683
+ };
15684
+ activePatrolItems: {
15685
+ id: string;
15686
+ title: any;
15687
+ subtitle: string;
15688
+ person: any;
15689
+ status: any;
15690
+ time: string;
15691
+ }[];
15692
+ } | {
15693
+ supplyAlert?: undefined;
15646
15694
  openWorkOrder: {
15647
15695
  count: any;
15648
15696
  inProgress: any;
@@ -15677,6 +15725,56 @@ declare function useNewDashboardRepo(): {
15677
15725
  }[];
15678
15726
  }>;
15679
15727
  getPropertyManagementDashboard: (siteId: string, period?: Period, type?: string, facility?: string) => Promise<{
15728
+ supplyAlert: {
15729
+ items: {
15730
+ name: any;
15731
+ qty: any;
15732
+ }[];
15733
+ basis: "below-alert-level";
15734
+ };
15735
+ openWorkOrder: {
15736
+ count: any;
15737
+ inProgress: any;
15738
+ percentage: number | null;
15739
+ };
15740
+ openIncidents: {
15741
+ count: any;
15742
+ highSeverity: number | null;
15743
+ highSeverityUnavailableReason: string;
15744
+ percentage: number | null;
15745
+ };
15746
+ visitors: {
15747
+ count: any;
15748
+ currentlyOnSite: number;
15749
+ percentage: number | null;
15750
+ };
15751
+ facilityBooking: {
15752
+ count: any;
15753
+ ongoing: any;
15754
+ waitingApproval: any;
15755
+ byStatus: {
15756
+ Pending: number;
15757
+ Approved: number;
15758
+ Ongoing: number;
15759
+ "For Review": number;
15760
+ "With Balance": number;
15761
+ "With Refund": number;
15762
+ Completed: number;
15763
+ Rejected: number;
15764
+ Cancelled: number;
15765
+ };
15766
+ percentage: number | null;
15767
+ };
15768
+ workOrderStatus: {
15769
+ pending: number;
15770
+ inProgress: number;
15771
+ completed: number;
15772
+ };
15773
+ upcomingEvents: mongodb.WithId<bson.Document>[];
15774
+ todayReminders: mongodb.WithId<bson.Document>[];
15775
+ todayAttentions: any[];
15776
+ } | {
15777
+ supplyAlert?: undefined;
15680
15778
  openWorkOrder: {
15681
15779
  count: any;
15682
15780
  inProgress: any;
package/dist/index.js CHANGED
@@ -11401,6 +11401,7 @@ var ConsoleAuditAction = /* @__PURE__ */ ((ConsoleAuditAction3) => {
11401
11401
  ConsoleAuditAction3["ROBOT_MAP_REMOVED"] = "robot.map-removed";
11402
11402
  ConsoleAuditAction3["ROBOT_LIFT_REQUESTED"] = "robot.lift-requested";
11403
11403
  ConsoleAuditAction3["ROBOT_LIFT_RELEASED"] = "robot.lift-released";
11404
+ ConsoleAuditAction3["INVENTORY_STORE_TYPE_REPAIRED"] = "inventory.store-type-repaired";
11404
11405
  return ConsoleAuditAction3;
11405
11406
  })(ConsoleAuditAction || {});
11406
11407
  var CLIENT_ACTIONS = [
@@ -11438,7 +11439,8 @@ var CONSOLE_AUDIT_LABELS = {
11438
11439
  ["robot.map-updated" /* ROBOT_MAP_UPDATED */]: "Building map edited",
11439
11440
  ["robot.map-removed" /* ROBOT_MAP_REMOVED */]: "Building map removed",
11440
11441
  ["robot.lift-requested" /* ROBOT_LIFT_REQUESTED */]: "Robot asked for a lift",
11441
- ["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released"
11442
+ ["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released",
11443
+ ["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: "Inventory store type corrected"
11442
11444
  };
11443
11445
  var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
11444
11446
  ConsoleAuditTarget2["ORGANIZATION"] = "organization";
@@ -11450,6 +11452,7 @@ var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
11450
11452
  ConsoleAuditTarget2["SITE"] = "site";
11451
11453
  ConsoleAuditTarget2["ROBOT"] = "robot";
11452
11454
  ConsoleAuditTarget2["ROBOT_MAP"] = "robot-map";
11455
+ ConsoleAuditTarget2["INVENTORY_STORE"] = "inventory-store";
11453
11456
  return ConsoleAuditTarget2;
11454
11457
  })(ConsoleAuditTarget || {});
11455
11458
  var CAMERA_AUDIT_FIELDS = [
@@ -11497,6 +11500,7 @@ var ROBOT_MAP_AUDIT_FIELDS = [
11497
11500
  ];
11498
11501
  var ROBOT_LIFT_AUDIT_FIELDS = ["name", "liftName", "fromFloor", "toFloor"];
11499
11502
  var AUDIT_FIELDS = {
11503
+ ["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: ["ownerType", "name"],
11500
11504
  ["robot.map-saved" /* ROBOT_MAP_SAVED */]: ROBOT_MAP_AUDIT_FIELDS,
11501
11505
  ["robot.map-updated" /* ROBOT_MAP_UPDATED */]: ROBOT_MAP_AUDIT_FIELDS,
11502
11506
  ["robot.map-removed" /* ROBOT_MAP_REMOVED */]: ROBOT_MAP_AUDIT_FIELDS,
@@ -92248,7 +92252,7 @@ function useNewDashboardRepo() {
92248
92252
  },
92249
92253
  activePatrolItems
92250
92254
  };
92251
- return data;
92255
+ return { ...data, ...await inventorySupplyTile(siteIdObj, "security_agency") };
92252
92256
  }
92253
92257
  async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
92254
92258
  const siteIdObj = (0, import_node_server_utils261.toObjectId)(siteId);
@@ -92687,7 +92691,7 @@ function useNewDashboardRepo() {
92687
92691
  todayReminders,
92688
92692
  todayAttentions
92689
92693
  };
92690
- return data;
92694
+ return { ...data, ...await inventorySupplyTile(siteIdObj, "property_management_agency") };
92691
92695
  }
92692
92696
  function areaChecklistScheduleLookup(site, serviceType, createdAtRange) {
92693
92697
  return [
@@ -92712,24 +92716,38 @@ function useNewDashboardRepo() {
92712
92716
  { $unwind: { path: "$scheduleDoc", preserveNullAndEmptyArrays: false } }
92713
92717
  ];
92714
92718
  }
92719
+ async function inventoryLowStock(site, serviceType) {
92720
+ const natures = serviceType === "property_management_agency" ? ["property_management_agency", "real_estate_developer"] : [serviceType];
92721
+ const siteStores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1, org: 1 } }).toArray();
92722
+ if (!siteStores.length)
92723
+ return null;
92724
+ const ownOrgs = new Set(
92725
+ (await db2.collection("organizations").find(
92726
+ { _id: { $in: siteStores.map((store) => store.org) }, nature: { $in: natures } },
92727
+ { projection: { _id: 1 } }
92728
+ ).toArray()).map((org) => org._id.toString())
92729
+ );
92730
+ const stores = siteStores.filter((store) => ownOrgs.has(String(store.org)));
92731
+ if (!stores.length)
92732
+ return null;
92733
+ return db2.collection("inventory.items").aggregate([
92734
+ {
92735
+ $match: {
92736
+ store: { $in: stores.map((store) => store._id) },
92737
+ status: "active",
92738
+ reorderLevel: { $gt: 0 },
92739
+ $expr: { $lte: ["$onHand", "$reorderLevel"] }
92740
+ }
92741
+ },
92742
+ { $sort: { onHand: 1 } },
92743
+ { $limit: 5 },
92744
+ { $project: { _id: 1, name: 1, qty: "$onHand" } }
92745
+ ]).toArray();
92746
+ }
92715
92747
  async function lowStockItems(site, serviceType) {
92716
- const stores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1 } }).toArray();
92717
- if (stores.length) {
92718
- const items2 = await db2.collection("inventory.items").aggregate([
92719
- {
92720
- $match: {
92721
- store: { $in: stores.map((store) => store._id) },
92722
- status: "active",
92723
- reorderLevel: { $gt: 0 },
92724
- $expr: { $lte: ["$onHand", "$reorderLevel"] }
92725
- }
92726
- },
92727
- { $sort: { onHand: 1 } },
92728
- { $limit: 5 },
92729
- { $project: { _id: 1, name: 1, qty: "$onHand" } }
92730
- ]).toArray();
92731
- return { items: items2, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
92732
- }
92748
+ const inventory = await inventoryLowStock(site, serviceType);
92749
+ if (inventory)
92750
+ return { items: inventory, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
92733
92751
  const items = await supplyCollection.aggregate([
92734
92752
  { $match: { site, serviceType, status: "active" } },
92735
92753
  { $sort: { qty: 1 } },
@@ -92738,6 +92756,10 @@ function useNewDashboardRepo() {
92738
92756
  ]).toArray();
92739
92757
  return { items, basis: SUPPLY_BASIS_LOWEST_QUANTITY };
92740
92758
  }
92759
+ async function inventorySupplyTile(site, serviceType) {
92760
+ const items = await inventoryLowStock(site, serviceType);
92761
+ return items ? { supplyAlert: { items: items.map((item) => ({ name: item.name, qty: item.qty })), basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL } } : {};
92762
+ }
92741
92763
  async function getServiceDashboard({
92742
92764
  site,
92743
92765
  serviceType,