@7365admin1/core 3.122.6 → 3.123.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@7365admin1/core",
3
3
  "license": "MIT",
4
- "version": "3.122.6",
4
+ "version": "3.123.0",
5
5
  "author": "7365admin1",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -18,7 +18,26 @@ describe("dashboard supply tile", { concurrency: 1 }, () => {
18
18
  before(async () => {
19
19
  h = await startHarness();
20
20
  const store = new ObjectId();
21
- await h.db.collection("inventory.stores").insertOne({ _id: store, org: new ObjectId(), ownerType: "property", name: "Main", sites: [withStore], status: "active" });
21
+ const cleaner = new ObjectId();
22
+ const guards = new ObjectId();
23
+ const manager = new ObjectId();
24
+ await h.db.collection("organizations").insertMany([
25
+ { _id: cleaner, name: "Cleaner", nature: "cleaning_services" },
26
+ { _id: guards, name: "Guards", nature: "security_agency" },
27
+ { _id: manager, name: "Manager", nature: "property_management_agency" },
28
+ ]);
29
+ await h.db.collection("inventory.stores").insertOne({ _id: store, org: cleaner, ownerType: "service_provider", name: "Main", sites: [withStore], status: "active" });
30
+ // Two more organisations keep their own stores at the same site.
31
+ const guardStore = new ObjectId();
32
+ const propertyStore = new ObjectId();
33
+ await h.db.collection("inventory.stores").insertMany([
34
+ { _id: guardStore, org: guards, ownerType: "service_provider", name: "Guard room", sites: [withStore], status: "active" },
35
+ { _id: propertyStore, org: manager, ownerType: "property", name: "Property store", sites: [withStore], status: "active" },
36
+ ]);
37
+ await h.db.collection("inventory.items").insertMany([
38
+ { store: guardStore, name: "Guard torch battery", onHand: 1, reorderLevel: 5, status: "active" },
39
+ { store: propertyStore, name: "Property LED", onHand: 2, reorderLevel: 10, status: "active" },
40
+ ]);
22
41
  await h.db.collection("inventory.items").insertMany([
23
42
  { store, name: "Tube 18W", onHand: 3, reorderLevel: 10, status: "active" },
24
43
  { store, name: "Holder", onHand: 0, reorderLevel: 5, status: "active" },
@@ -50,6 +69,26 @@ describe("dashboard supply tile", { concurrency: 1 }, () => {
50
69
  assert.equal(supply.thresholdUnavailableReason, undefined);
51
70
  });
52
71
 
72
+ it("another organisation's store at the same site never appears on this app's tile", async () => {
73
+ const supply = await tile(withStore);
74
+ assert.ok(!supply.items.some((i) => i.name === "Guard torch battery" || i.name === "Property LED"));
75
+ });
76
+
77
+ it("the property and security dashboards show Low Stock from their own organisation's store only", async () => {
78
+ const repo = h.core.useNewDashboardRepo();
79
+ const pm = await repo.getPropertyManagementDashboard(withStore.toString());
80
+ assert.equal(pm.supplyAlert.basis, "below-alert-level");
81
+ assert.deepEqual(pm.supplyAlert.items, [{ name: "Property LED", qty: 2 }]);
82
+ const sec = await repo.getSecurityDashboard({ siteId: withStore.toString() });
83
+ assert.deepEqual(sec.supplyAlert.items, [{ name: "Guard torch battery", qty: 1 }]);
84
+ });
85
+
86
+ it("the property and security dashboards carry no supply tile where they have no store", async () => {
87
+ const repo = h.core.useNewDashboardRepo();
88
+ assert.equal((await repo.getPropertyManagementDashboard(withoutStore.toString())).supplyAlert, undefined);
89
+ assert.equal((await repo.getSecurityDashboard({ siteId: withoutStore.toString() })).supplyAlert, undefined);
90
+ });
91
+
53
92
  it("a site without a store keeps the old lowest-quantity list", async () => {
54
93
  const supply = await tile(withoutStore);
55
94
  assert.equal(supply.basis, "lowest-quantity");