@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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +37 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/e2e/dashboard-inventory-low-stock.e2e.test.mjs +40 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/core
|
|
2
2
|
|
|
3
|
+
## 3.123.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 028e4ad: 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.
|
|
8
|
+
|
|
3
9
|
## 3.122.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -15466,6 +15466,47 @@ declare function useNewDashboardRepo(): {
|
|
|
15466
15466
|
period?: Period | undefined;
|
|
15467
15467
|
type?: string | undefined;
|
|
15468
15468
|
}) => Promise<{
|
|
15469
|
+
supplyAlert: {
|
|
15470
|
+
items: {
|
|
15471
|
+
name: any;
|
|
15472
|
+
qty: any;
|
|
15473
|
+
}[];
|
|
15474
|
+
basis: "below-alert-level";
|
|
15475
|
+
};
|
|
15476
|
+
openWorkOrder: {
|
|
15477
|
+
count: any;
|
|
15478
|
+
inProgress: any;
|
|
15479
|
+
percentage: number | null;
|
|
15480
|
+
};
|
|
15481
|
+
openIncidents: {
|
|
15482
|
+
count: any;
|
|
15483
|
+
highSeverity: number | null;
|
|
15484
|
+
highSeverityUnavailableReason: string;
|
|
15485
|
+
percentage: number | null;
|
|
15486
|
+
};
|
|
15487
|
+
visitors: {
|
|
15488
|
+
count: any;
|
|
15489
|
+
currentlyOnSite: number;
|
|
15490
|
+
percentage: number | null;
|
|
15491
|
+
};
|
|
15492
|
+
patrolCompliance: {
|
|
15493
|
+
count: number | null;
|
|
15494
|
+
checkpointsDue: any;
|
|
15495
|
+
unavailableReason: string | null;
|
|
15496
|
+
missedCheckpoints: any;
|
|
15497
|
+
missed: any;
|
|
15498
|
+
percentage: number | null;
|
|
15499
|
+
};
|
|
15500
|
+
activePatrolItems: {
|
|
15501
|
+
id: string;
|
|
15502
|
+
title: any;
|
|
15503
|
+
subtitle: string;
|
|
15504
|
+
person: any;
|
|
15505
|
+
status: any;
|
|
15506
|
+
time: string;
|
|
15507
|
+
}[];
|
|
15508
|
+
} | {
|
|
15509
|
+
supplyAlert?: undefined;
|
|
15469
15510
|
openWorkOrder: {
|
|
15470
15511
|
count: any;
|
|
15471
15512
|
inProgress: any;
|
|
@@ -15500,6 +15541,56 @@ declare function useNewDashboardRepo(): {
|
|
|
15500
15541
|
}[];
|
|
15501
15542
|
}>;
|
|
15502
15543
|
getPropertyManagementDashboard: (siteId: string, period?: Period, type?: string, facility?: string) => Promise<{
|
|
15544
|
+
supplyAlert: {
|
|
15545
|
+
items: {
|
|
15546
|
+
name: any;
|
|
15547
|
+
qty: any;
|
|
15548
|
+
}[];
|
|
15549
|
+
basis: "below-alert-level";
|
|
15550
|
+
};
|
|
15551
|
+
openWorkOrder: {
|
|
15552
|
+
count: any;
|
|
15553
|
+
inProgress: any;
|
|
15554
|
+
percentage: number | null;
|
|
15555
|
+
};
|
|
15556
|
+
openIncidents: {
|
|
15557
|
+
count: any;
|
|
15558
|
+
highSeverity: number | null;
|
|
15559
|
+
highSeverityUnavailableReason: string;
|
|
15560
|
+
percentage: number | null;
|
|
15561
|
+
};
|
|
15562
|
+
visitors: {
|
|
15563
|
+
count: any;
|
|
15564
|
+
currentlyOnSite: number;
|
|
15565
|
+
percentage: number | null;
|
|
15566
|
+
};
|
|
15567
|
+
facilityBooking: {
|
|
15568
|
+
count: any;
|
|
15569
|
+
ongoing: any;
|
|
15570
|
+
waitingApproval: any;
|
|
15571
|
+
byStatus: {
|
|
15572
|
+
Pending: number;
|
|
15573
|
+
Approved: number;
|
|
15574
|
+
Ongoing: number;
|
|
15575
|
+
"For Review": number;
|
|
15576
|
+
"With Balance": number;
|
|
15577
|
+
"With Refund": number;
|
|
15578
|
+
Completed: number;
|
|
15579
|
+
Rejected: number;
|
|
15580
|
+
Cancelled: number;
|
|
15581
|
+
};
|
|
15582
|
+
percentage: number | null;
|
|
15583
|
+
};
|
|
15584
|
+
workOrderStatus: {
|
|
15585
|
+
pending: number;
|
|
15586
|
+
inProgress: number;
|
|
15587
|
+
completed: number;
|
|
15588
|
+
};
|
|
15589
|
+
upcomingEvents: mongodb.WithId<bson.Document>[];
|
|
15590
|
+
todayReminders: mongodb.WithId<bson.Document>[];
|
|
15591
|
+
todayAttentions: any[];
|
|
15592
|
+
} | {
|
|
15593
|
+
supplyAlert?: undefined;
|
|
15503
15594
|
openWorkOrder: {
|
|
15504
15595
|
count: any;
|
|
15505
15596
|
inProgress: any;
|
package/dist/index.js
CHANGED
|
@@ -90264,7 +90264,7 @@ function useNewDashboardRepo() {
|
|
|
90264
90264
|
},
|
|
90265
90265
|
activePatrolItems
|
|
90266
90266
|
};
|
|
90267
|
-
return data;
|
|
90267
|
+
return { ...data, ...await inventorySupplyTile(siteIdObj, "security_agency") };
|
|
90268
90268
|
}
|
|
90269
90269
|
async function getPropertyManagementDashboard(siteId, period = "today" /* TODAY */, type, facility) {
|
|
90270
90270
|
const siteIdObj = (0, import_node_server_utils261.toObjectId)(siteId);
|
|
@@ -90703,7 +90703,7 @@ function useNewDashboardRepo() {
|
|
|
90703
90703
|
todayReminders,
|
|
90704
90704
|
todayAttentions
|
|
90705
90705
|
};
|
|
90706
|
-
return data;
|
|
90706
|
+
return { ...data, ...await inventorySupplyTile(siteIdObj, "property_management_agency") };
|
|
90707
90707
|
}
|
|
90708
90708
|
function areaChecklistScheduleLookup(site, serviceType, createdAtRange) {
|
|
90709
90709
|
return [
|
|
@@ -90728,24 +90728,38 @@ function useNewDashboardRepo() {
|
|
|
90728
90728
|
{ $unwind: { path: "$scheduleDoc", preserveNullAndEmptyArrays: false } }
|
|
90729
90729
|
];
|
|
90730
90730
|
}
|
|
90731
|
+
async function inventoryLowStock(site, serviceType) {
|
|
90732
|
+
const natures = serviceType === "property_management_agency" ? ["property_management_agency", "real_estate_developer"] : [serviceType];
|
|
90733
|
+
const siteStores = await db2.collection("inventory.stores").find({ sites: site, status: "active" }, { projection: { _id: 1, org: 1 } }).toArray();
|
|
90734
|
+
if (!siteStores.length)
|
|
90735
|
+
return null;
|
|
90736
|
+
const ownOrgs = new Set(
|
|
90737
|
+
(await db2.collection("organizations").find(
|
|
90738
|
+
{ _id: { $in: siteStores.map((store) => store.org) }, nature: { $in: natures } },
|
|
90739
|
+
{ projection: { _id: 1 } }
|
|
90740
|
+
).toArray()).map((org) => org._id.toString())
|
|
90741
|
+
);
|
|
90742
|
+
const stores = siteStores.filter((store) => ownOrgs.has(String(store.org)));
|
|
90743
|
+
if (!stores.length)
|
|
90744
|
+
return null;
|
|
90745
|
+
return db2.collection("inventory.items").aggregate([
|
|
90746
|
+
{
|
|
90747
|
+
$match: {
|
|
90748
|
+
store: { $in: stores.map((store) => store._id) },
|
|
90749
|
+
status: "active",
|
|
90750
|
+
reorderLevel: { $gt: 0 },
|
|
90751
|
+
$expr: { $lte: ["$onHand", "$reorderLevel"] }
|
|
90752
|
+
}
|
|
90753
|
+
},
|
|
90754
|
+
{ $sort: { onHand: 1 } },
|
|
90755
|
+
{ $limit: 5 },
|
|
90756
|
+
{ $project: { _id: 1, name: 1, qty: "$onHand" } }
|
|
90757
|
+
]).toArray();
|
|
90758
|
+
}
|
|
90731
90759
|
async function lowStockItems(site, serviceType) {
|
|
90732
|
-
const
|
|
90733
|
-
if (
|
|
90734
|
-
|
|
90735
|
-
{
|
|
90736
|
-
$match: {
|
|
90737
|
-
store: { $in: stores.map((store) => store._id) },
|
|
90738
|
-
status: "active",
|
|
90739
|
-
reorderLevel: { $gt: 0 },
|
|
90740
|
-
$expr: { $lte: ["$onHand", "$reorderLevel"] }
|
|
90741
|
-
}
|
|
90742
|
-
},
|
|
90743
|
-
{ $sort: { onHand: 1 } },
|
|
90744
|
-
{ $limit: 5 },
|
|
90745
|
-
{ $project: { _id: 1, name: 1, qty: "$onHand" } }
|
|
90746
|
-
]).toArray();
|
|
90747
|
-
return { items: items2, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
|
|
90748
|
-
}
|
|
90760
|
+
const inventory = await inventoryLowStock(site, serviceType);
|
|
90761
|
+
if (inventory)
|
|
90762
|
+
return { items: inventory, basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL };
|
|
90749
90763
|
const items = await supplyCollection.aggregate([
|
|
90750
90764
|
{ $match: { site, serviceType, status: "active" } },
|
|
90751
90765
|
{ $sort: { qty: 1 } },
|
|
@@ -90754,6 +90768,10 @@ function useNewDashboardRepo() {
|
|
|
90754
90768
|
]).toArray();
|
|
90755
90769
|
return { items, basis: SUPPLY_BASIS_LOWEST_QUANTITY };
|
|
90756
90770
|
}
|
|
90771
|
+
async function inventorySupplyTile(site, serviceType) {
|
|
90772
|
+
const items = await inventoryLowStock(site, serviceType);
|
|
90773
|
+
return items ? { supplyAlert: { items: items.map((item) => ({ name: item.name, qty: item.qty })), basis: SUPPLY_BASIS_BELOW_ALERT_LEVEL } } : {};
|
|
90774
|
+
}
|
|
90757
90775
|
async function getServiceDashboard({
|
|
90758
90776
|
site,
|
|
90759
90777
|
serviceType,
|