@7365admin1/module-hygiene 4.24.1 → 4.26.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 +12 -0
- package/dist/index.js +23 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3235,6 +3235,14 @@ function useAreaChecklistRepo() {
|
|
|
3235
3235
|
const namespace_collection = "site.cleaning.schedule.areas";
|
|
3236
3236
|
const collection = db.collection(namespace_collection);
|
|
3237
3237
|
const { delNamespace, setCache, getCache } = useCache5(namespace_collection);
|
|
3238
|
+
async function invalidateNamespaceCache(context) {
|
|
3239
|
+
try {
|
|
3240
|
+
await delNamespace();
|
|
3241
|
+
logger17.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
3242
|
+
} catch (err) {
|
|
3243
|
+
logger17.error(`Failed to clear cache for ${context}`, err);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3238
3246
|
async function createIndex() {
|
|
3239
3247
|
try {
|
|
3240
3248
|
await collection.createIndexes([
|
|
@@ -3289,14 +3297,7 @@ function useAreaChecklistRepo() {
|
|
|
3289
3297
|
}
|
|
3290
3298
|
const processedValue = MAreaChecklist(value);
|
|
3291
3299
|
const result = await collection.insertOne(processedValue, { session });
|
|
3292
|
-
|
|
3293
|
-
logger17.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
3294
|
-
}).catch((err) => {
|
|
3295
|
-
logger17.error(
|
|
3296
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
3297
|
-
err
|
|
3298
|
-
);
|
|
3299
|
-
});
|
|
3300
|
+
await invalidateNamespaceCache("area checklist create");
|
|
3300
3301
|
return result.insertedId;
|
|
3301
3302
|
} catch (error) {
|
|
3302
3303
|
if (error?.code === 11e3) {
|
|
@@ -4033,14 +4034,7 @@ function useAreaChecklistRepo() {
|
|
|
4033
4034
|
if (res.modifiedCount === 0) {
|
|
4034
4035
|
throw new InternalServerError5("Unable to update area checklist unit.");
|
|
4035
4036
|
}
|
|
4036
|
-
|
|
4037
|
-
logger17.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4038
|
-
}).catch((err) => {
|
|
4039
|
-
logger17.error(
|
|
4040
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4041
|
-
err
|
|
4042
|
-
);
|
|
4043
|
-
});
|
|
4037
|
+
await invalidateNamespaceCache("area checklist unit update");
|
|
4044
4038
|
return res.modifiedCount;
|
|
4045
4039
|
} catch (error) {
|
|
4046
4040
|
logger17.error("Error updating area checklist unit:", error.message);
|
|
@@ -4066,14 +4060,7 @@ function useAreaChecklistRepo() {
|
|
|
4066
4060
|
if (res.modifiedCount === 0) {
|
|
4067
4061
|
throw new InternalServerError5("Unable to update area checklist.");
|
|
4068
4062
|
}
|
|
4069
|
-
|
|
4070
|
-
logger17.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4071
|
-
}).catch((err) => {
|
|
4072
|
-
logger17.error(
|
|
4073
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4074
|
-
err
|
|
4075
|
-
);
|
|
4076
|
-
});
|
|
4063
|
+
await invalidateNamespaceCache("area checklist update");
|
|
4077
4064
|
return res.modifiedCount;
|
|
4078
4065
|
} catch (error) {
|
|
4079
4066
|
throw error;
|
|
@@ -4103,14 +4090,7 @@ function useAreaChecklistRepo() {
|
|
|
4103
4090
|
"Unable to update area checklist status."
|
|
4104
4091
|
);
|
|
4105
4092
|
}
|
|
4106
|
-
|
|
4107
|
-
logger17.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
4108
|
-
}).catch((err) => {
|
|
4109
|
-
logger17.error(
|
|
4110
|
-
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
4111
|
-
err
|
|
4112
|
-
);
|
|
4113
|
-
});
|
|
4093
|
+
await invalidateNamespaceCache("area checklist status update");
|
|
4114
4094
|
return res.modifiedCount;
|
|
4115
4095
|
} catch (error) {
|
|
4116
4096
|
throw error;
|
|
@@ -4523,16 +4503,14 @@ function useAreaChecklistService() {
|
|
|
4523
4503
|
if (allUnitsResult && allUnitsResult.items && allUnitsResult.items.length > 0) {
|
|
4524
4504
|
const sets = allUnitsResult.items;
|
|
4525
4505
|
const allUnits = sets.flatMap((set2) => set2.units || []);
|
|
4526
|
-
const openCount = allUnits.filter(
|
|
4527
|
-
(unit) => unit.status === "Open"
|
|
4528
|
-
).length;
|
|
4529
|
-
const completedCount = allUnits.filter(
|
|
4530
|
-
(unit) => unit.status === "Completed"
|
|
4531
|
-
).length;
|
|
4532
4506
|
const totalCount = allUnits.length;
|
|
4533
|
-
|
|
4507
|
+
const actionedCount = allUnits.filter((unit) => {
|
|
4508
|
+
const status = String(unit.status ?? "").toLowerCase();
|
|
4509
|
+
return unit.approve === true || unit.reject === true || status === "completed" || status === "closed";
|
|
4510
|
+
}).length;
|
|
4511
|
+
if (totalCount > 0 && actionedCount === totalCount) {
|
|
4534
4512
|
areaStatus = "completed";
|
|
4535
|
-
} else if (
|
|
4513
|
+
} else if (actionedCount === 0) {
|
|
4536
4514
|
areaStatus = "open";
|
|
4537
4515
|
} else {
|
|
4538
4516
|
areaStatus = "ongoing";
|
|
@@ -4551,11 +4529,12 @@ function useAreaChecklistService() {
|
|
|
4551
4529
|
);
|
|
4552
4530
|
if (allAreasResult && allAreasResult.items && allAreasResult.items.length > 0) {
|
|
4553
4531
|
const areas = allAreasResult.items;
|
|
4532
|
+
const normalizeStatus = (status) => String(status ?? "").toLowerCase();
|
|
4554
4533
|
const openAreasCount = areas.filter(
|
|
4555
|
-
(area) => area.status === "
|
|
4534
|
+
(area) => normalizeStatus(area.status) === "open"
|
|
4556
4535
|
).length;
|
|
4557
4536
|
const completedAreasCount = areas.filter(
|
|
4558
|
-
(area) => area.status === "
|
|
4537
|
+
(area) => normalizeStatus(area.status) === "completed"
|
|
4559
4538
|
).length;
|
|
4560
4539
|
const totalAreasCount = areas.length;
|
|
4561
4540
|
let parentStatus = "open";
|
|
@@ -6099,7 +6078,7 @@ function useCheckOutItemRepository() {
|
|
|
6099
6078
|
{ $match: query },
|
|
6100
6079
|
{
|
|
6101
6080
|
$lookup: {
|
|
6102
|
-
from: "site.
|
|
6081
|
+
from: "site.supplies",
|
|
6103
6082
|
localField: "supply",
|
|
6104
6083
|
foreignField: "_id",
|
|
6105
6084
|
as: "supplyDetails"
|
|
@@ -6120,6 +6099,7 @@ function useCheckOutItemRepository() {
|
|
|
6120
6099
|
qty: 1,
|
|
6121
6100
|
status: 1,
|
|
6122
6101
|
unitOfMeasurement: "$supplyDetails.unitOfMeasurement",
|
|
6102
|
+
stockQty: "$supplyDetails.qty",
|
|
6123
6103
|
attachment: 1
|
|
6124
6104
|
}
|
|
6125
6105
|
}
|