@7365admin1/core 2.32.0 → 2.34.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.d.ts +14 -3
- package/dist/index.js +484 -170
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +483 -170
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -175,6 +175,7 @@ __export(src_exports, {
|
|
|
175
175
|
remarksSchema: () => remarksSchema,
|
|
176
176
|
robotSchema: () => robotSchema,
|
|
177
177
|
schema: () => schema,
|
|
178
|
+
schemaApprovedBy: () => schemaApprovedBy,
|
|
178
179
|
schemaBilling: () => schemaBilling,
|
|
179
180
|
schemaBillingConfiguration: () => schemaBillingConfiguration,
|
|
180
181
|
schemaBillingItem: () => schemaBillingItem,
|
|
@@ -5866,6 +5867,7 @@ function useRoleRepo() {
|
|
|
5866
5867
|
}).catch((err) => {
|
|
5867
5868
|
import_node_server_utils22.logger.error(`Failed to clear cache for namespace: dashboard`, err);
|
|
5868
5869
|
});
|
|
5870
|
+
return "Successfully deleted role permission.";
|
|
5869
5871
|
} catch (error) {
|
|
5870
5872
|
throw new import_node_server_utils22.InternalServerError("Failed to delete role.");
|
|
5871
5873
|
}
|
|
@@ -13658,7 +13660,8 @@ function useVisitorTransactionRepo() {
|
|
|
13658
13660
|
$project: {
|
|
13659
13661
|
_id: 1,
|
|
13660
13662
|
prefixPass: 1,
|
|
13661
|
-
name: 1
|
|
13663
|
+
name: 1,
|
|
13664
|
+
remarks: 1
|
|
13662
13665
|
}
|
|
13663
13666
|
}
|
|
13664
13667
|
],
|
|
@@ -13671,6 +13674,9 @@ function useVisitorTransactionRepo() {
|
|
|
13671
13674
|
keyId: "$_id",
|
|
13672
13675
|
status: 1,
|
|
13673
13676
|
description: 1,
|
|
13677
|
+
remarks: {
|
|
13678
|
+
$arrayElemAt: ["$template.remarks", 0]
|
|
13679
|
+
},
|
|
13674
13680
|
templatePrefixPass: {
|
|
13675
13681
|
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13676
13682
|
},
|
|
@@ -13707,7 +13713,8 @@ function useVisitorTransactionRepo() {
|
|
|
13707
13713
|
$project: {
|
|
13708
13714
|
_id: 1,
|
|
13709
13715
|
prefixPass: 1,
|
|
13710
|
-
name: 1
|
|
13716
|
+
name: 1,
|
|
13717
|
+
remarks: 1
|
|
13711
13718
|
}
|
|
13712
13719
|
}
|
|
13713
13720
|
],
|
|
@@ -13720,6 +13727,9 @@ function useVisitorTransactionRepo() {
|
|
|
13720
13727
|
keyId: "$_id",
|
|
13721
13728
|
status: 1,
|
|
13722
13729
|
description: 1,
|
|
13730
|
+
remarks: {
|
|
13731
|
+
$arrayElemAt: ["$template.remarks", 0]
|
|
13732
|
+
},
|
|
13723
13733
|
templatePrefixPass: {
|
|
13724
13734
|
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13725
13735
|
},
|
|
@@ -19410,16 +19420,30 @@ function useCustomerSiteRepo() {
|
|
|
19410
19420
|
return cachedData;
|
|
19411
19421
|
}
|
|
19412
19422
|
try {
|
|
19423
|
+
const distinctPipeline = [
|
|
19424
|
+
{ $match: query },
|
|
19425
|
+
{ $sort: sort },
|
|
19426
|
+
{ $group: { _id: { name: "$name", site: "$site" }, doc: { $first: "$$ROOT" } } },
|
|
19427
|
+
{ $replaceRoot: { newRoot: "$doc" } },
|
|
19428
|
+
{ $sort: sort }
|
|
19429
|
+
];
|
|
19413
19430
|
const items = await collection.aggregate(
|
|
19414
19431
|
[
|
|
19415
|
-
|
|
19416
|
-
{ $sort: sort },
|
|
19432
|
+
...distinctPipeline,
|
|
19417
19433
|
{ $skip: page * limit },
|
|
19418
19434
|
{ $limit: limit }
|
|
19419
19435
|
],
|
|
19420
19436
|
{ session }
|
|
19421
19437
|
).toArray();
|
|
19422
|
-
const
|
|
19438
|
+
const countResult = await collection.aggregate(
|
|
19439
|
+
[
|
|
19440
|
+
{ $match: query },
|
|
19441
|
+
{ $group: { _id: { name: "$name", site: "$site" } } },
|
|
19442
|
+
{ $count: "total" }
|
|
19443
|
+
],
|
|
19444
|
+
{ session }
|
|
19445
|
+
).toArray();
|
|
19446
|
+
const length = countResult[0]?.total ?? 0;
|
|
19423
19447
|
const data = (0, import_node_server_utils89.paginate)(items, page, limit, length);
|
|
19424
19448
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
19425
19449
|
import_node_server_utils89.logger.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -21504,7 +21528,8 @@ var KeyRepo = class {
|
|
|
21504
21528
|
location: 1,
|
|
21505
21529
|
prefix: 1,
|
|
21506
21530
|
keyNo: 1,
|
|
21507
|
-
parentId: 1
|
|
21531
|
+
parentId: 1,
|
|
21532
|
+
status: 1
|
|
21508
21533
|
}
|
|
21509
21534
|
}
|
|
21510
21535
|
]).toArray();
|
|
@@ -21747,7 +21772,8 @@ function useVisitorTransactionService() {
|
|
|
21747
21772
|
add: _add,
|
|
21748
21773
|
updateById: _updateVisitorTansactionById,
|
|
21749
21774
|
getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
|
|
21750
|
-
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
|
|
21775
|
+
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus,
|
|
21776
|
+
getVisitorTransactionById: _getVisitorTransactionById
|
|
21751
21777
|
} = useVisitorTransactionRepo();
|
|
21752
21778
|
const { getById } = useBuildingUnitRepo();
|
|
21753
21779
|
const {
|
|
@@ -21766,6 +21792,70 @@ function useVisitorTransactionService() {
|
|
|
21766
21792
|
const { getAllSites: _getAllSites } = useSiteRepo();
|
|
21767
21793
|
const { getByUserId: _getByUserId } = usePersonRepo();
|
|
21768
21794
|
const { add: addVehicle } = useVehicleRepo();
|
|
21795
|
+
function extractKeyId(item) {
|
|
21796
|
+
if (!item)
|
|
21797
|
+
return null;
|
|
21798
|
+
if (typeof item === "string") {
|
|
21799
|
+
return import_mongodb58.ObjectId.isValid(item) ? item : null;
|
|
21800
|
+
}
|
|
21801
|
+
if (typeof item === "object" && item !== null) {
|
|
21802
|
+
if ("keyId" in item) {
|
|
21803
|
+
const keyId = String(item.keyId);
|
|
21804
|
+
return import_mongodb58.ObjectId.isValid(keyId) ? keyId : null;
|
|
21805
|
+
}
|
|
21806
|
+
const value = String(item);
|
|
21807
|
+
return import_mongodb58.ObjectId.isValid(value) ? value : null;
|
|
21808
|
+
}
|
|
21809
|
+
return null;
|
|
21810
|
+
}
|
|
21811
|
+
function normalizeKeyRefs(items) {
|
|
21812
|
+
if (!Array.isArray(items))
|
|
21813
|
+
return [];
|
|
21814
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21815
|
+
const normalized = [];
|
|
21816
|
+
for (const item of items) {
|
|
21817
|
+
const keyId = extractKeyId(item);
|
|
21818
|
+
if (!keyId || seen.has(keyId))
|
|
21819
|
+
continue;
|
|
21820
|
+
seen.add(keyId);
|
|
21821
|
+
normalized.push({ keyId: new import_mongodb58.ObjectId(keyId) });
|
|
21822
|
+
}
|
|
21823
|
+
return normalized;
|
|
21824
|
+
}
|
|
21825
|
+
async function syncTransactionKeys({
|
|
21826
|
+
current,
|
|
21827
|
+
incoming,
|
|
21828
|
+
site,
|
|
21829
|
+
session
|
|
21830
|
+
}) {
|
|
21831
|
+
const currentIds = current.map((item) => item.keyId.toString());
|
|
21832
|
+
const incomingIds = incoming.map((item) => item.keyId.toString());
|
|
21833
|
+
const currentSet = new Set(currentIds);
|
|
21834
|
+
const incomingSet = new Set(incomingIds);
|
|
21835
|
+
const removedIds = currentIds.filter((id) => !incomingSet.has(id));
|
|
21836
|
+
const addedIds = incomingIds.filter((id) => !currentSet.has(id));
|
|
21837
|
+
for (const keyId of removedIds) {
|
|
21838
|
+
const existingKey = await KeyRepo.getById(keyId);
|
|
21839
|
+
if (!existingKey)
|
|
21840
|
+
continue;
|
|
21841
|
+
if (existingKey.status === "In Use" /* IN_USE */) {
|
|
21842
|
+
await KeyRepo.updateKeyById(
|
|
21843
|
+
keyId,
|
|
21844
|
+
{ status: "Available" /* AVAILABLE */ },
|
|
21845
|
+
site,
|
|
21846
|
+
session
|
|
21847
|
+
);
|
|
21848
|
+
}
|
|
21849
|
+
}
|
|
21850
|
+
for (const keyId of addedIds) {
|
|
21851
|
+
await KeyRepo.updateKeyById(
|
|
21852
|
+
keyId,
|
|
21853
|
+
{ status: "In Use" /* IN_USE */ },
|
|
21854
|
+
site,
|
|
21855
|
+
session
|
|
21856
|
+
);
|
|
21857
|
+
}
|
|
21858
|
+
}
|
|
21769
21859
|
async function add(value) {
|
|
21770
21860
|
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
21771
21861
|
const allowedPersonTypes = [
|
|
@@ -22010,7 +22100,7 @@ function useVisitorTransactionService() {
|
|
|
22010
22100
|
session?.endSession();
|
|
22011
22101
|
}
|
|
22012
22102
|
}
|
|
22013
|
-
async function
|
|
22103
|
+
async function updateVisitorTransactionById(id, value) {
|
|
22014
22104
|
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
22015
22105
|
session?.startTransaction();
|
|
22016
22106
|
try {
|
|
@@ -22186,18 +22276,70 @@ function useVisitorTransactionService() {
|
|
|
22186
22276
|
await session?.commitTransaction();
|
|
22187
22277
|
return result;
|
|
22188
22278
|
} catch (error) {
|
|
22189
|
-
import_node_server_utils101.logger.error("Error in
|
|
22279
|
+
import_node_server_utils101.logger.error("Error in visitor transaction invite visitor:", error);
|
|
22190
22280
|
await session.abortTransaction();
|
|
22191
22281
|
throw error;
|
|
22192
22282
|
} finally {
|
|
22193
22283
|
session?.endSession();
|
|
22194
22284
|
}
|
|
22195
22285
|
}
|
|
22286
|
+
async function changeVisitorTransactionKeysById(id, visitorPass, passKeys) {
|
|
22287
|
+
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
22288
|
+
if (!session) {
|
|
22289
|
+
throw new Error(
|
|
22290
|
+
"Unable to start session for visitor transaction service."
|
|
22291
|
+
);
|
|
22292
|
+
}
|
|
22293
|
+
try {
|
|
22294
|
+
session.startTransaction();
|
|
22295
|
+
const visitorTransaction = await _getVisitorTransactionById(id);
|
|
22296
|
+
if (!visitorTransaction) {
|
|
22297
|
+
throw new Error("Visitor transaction not found.");
|
|
22298
|
+
}
|
|
22299
|
+
const updatePayload = {};
|
|
22300
|
+
if (visitorPass !== void 0) {
|
|
22301
|
+
const currentVisitorPass = normalizeKeyRefs(
|
|
22302
|
+
visitorTransaction.visitorPass
|
|
22303
|
+
);
|
|
22304
|
+
const incomingVisitorPass = normalizeKeyRefs(visitorPass);
|
|
22305
|
+
await syncTransactionKeys({
|
|
22306
|
+
current: currentVisitorPass,
|
|
22307
|
+
incoming: incomingVisitorPass,
|
|
22308
|
+
site: visitorTransaction.site,
|
|
22309
|
+
session
|
|
22310
|
+
});
|
|
22311
|
+
updatePayload.visitorPass = incomingVisitorPass;
|
|
22312
|
+
}
|
|
22313
|
+
if (passKeys !== void 0) {
|
|
22314
|
+
const currentPassKeys = normalizeKeyRefs(visitorTransaction.passKeys);
|
|
22315
|
+
const incomingPassKeys = normalizeKeyRefs(passKeys);
|
|
22316
|
+
await syncTransactionKeys({
|
|
22317
|
+
current: currentPassKeys,
|
|
22318
|
+
incoming: incomingPassKeys,
|
|
22319
|
+
site: visitorTransaction.site,
|
|
22320
|
+
session
|
|
22321
|
+
});
|
|
22322
|
+
updatePayload.passKeys = incomingPassKeys;
|
|
22323
|
+
}
|
|
22324
|
+
if (Object.keys(updatePayload).length > 0) {
|
|
22325
|
+
await _updateVisitorTansactionById(id, updatePayload, session);
|
|
22326
|
+
}
|
|
22327
|
+
await session.commitTransaction();
|
|
22328
|
+
return "Successfully changed visitor transaction keys.";
|
|
22329
|
+
} catch (error) {
|
|
22330
|
+
await session.abortTransaction();
|
|
22331
|
+
import_node_server_utils101.logger.error("Error in visitor transaction change keys by id:", error);
|
|
22332
|
+
throw error;
|
|
22333
|
+
} finally {
|
|
22334
|
+
session.endSession();
|
|
22335
|
+
}
|
|
22336
|
+
}
|
|
22196
22337
|
return {
|
|
22197
22338
|
add,
|
|
22198
|
-
|
|
22339
|
+
updateVisitorTransactionById,
|
|
22199
22340
|
processTransactionDahuaStatus,
|
|
22200
|
-
inviteVisitor
|
|
22341
|
+
inviteVisitor,
|
|
22342
|
+
changeVisitorTransactionKeysById
|
|
22201
22343
|
};
|
|
22202
22344
|
}
|
|
22203
22345
|
|
|
@@ -22207,8 +22349,9 @@ var import_node_server_utils102 = require("@7365admin1/node-server-utils");
|
|
|
22207
22349
|
function useVisitorTransactionController() {
|
|
22208
22350
|
const {
|
|
22209
22351
|
add: _add,
|
|
22210
|
-
|
|
22211
|
-
inviteVisitor: _inviteVisitor
|
|
22352
|
+
updateVisitorTransactionById: _updateVisitorTransactionById,
|
|
22353
|
+
inviteVisitor: _inviteVisitor,
|
|
22354
|
+
changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById
|
|
22212
22355
|
} = useVisitorTransactionService();
|
|
22213
22356
|
const {
|
|
22214
22357
|
getAll: _getAll,
|
|
@@ -22350,7 +22493,7 @@ function useVisitorTransactionController() {
|
|
|
22350
22493
|
return;
|
|
22351
22494
|
}
|
|
22352
22495
|
try {
|
|
22353
|
-
await
|
|
22496
|
+
await _updateVisitorTransactionById(_id, req.body);
|
|
22354
22497
|
res.status(200).json({ message: "Successfully updated visitor transaction." });
|
|
22355
22498
|
return;
|
|
22356
22499
|
} catch (error2) {
|
|
@@ -22404,8 +22547,31 @@ function useVisitorTransactionController() {
|
|
|
22404
22547
|
next(new import_node_server_utils102.BadRequestError(messages));
|
|
22405
22548
|
return;
|
|
22406
22549
|
}
|
|
22407
|
-
const {
|
|
22408
|
-
|
|
22550
|
+
const {
|
|
22551
|
+
expectedCheckIn,
|
|
22552
|
+
arrivalTime,
|
|
22553
|
+
duration,
|
|
22554
|
+
name,
|
|
22555
|
+
contact,
|
|
22556
|
+
email,
|
|
22557
|
+
plateNumber,
|
|
22558
|
+
isOvernightParking,
|
|
22559
|
+
numberOfPassengers,
|
|
22560
|
+
purpose,
|
|
22561
|
+
inviterUserId
|
|
22562
|
+
} = value;
|
|
22563
|
+
const rest = {
|
|
22564
|
+
expectedCheckIn,
|
|
22565
|
+
arrivalTime,
|
|
22566
|
+
duration,
|
|
22567
|
+
name,
|
|
22568
|
+
contact,
|
|
22569
|
+
email,
|
|
22570
|
+
plateNumber,
|
|
22571
|
+
isOvernightParking,
|
|
22572
|
+
numberOfPassengers,
|
|
22573
|
+
purpose
|
|
22574
|
+
};
|
|
22409
22575
|
try {
|
|
22410
22576
|
const result = await _inviteVisitor(rest, inviterUserId);
|
|
22411
22577
|
res.status(200).json({ insertedId: result });
|
|
@@ -22416,13 +22582,61 @@ function useVisitorTransactionController() {
|
|
|
22416
22582
|
return;
|
|
22417
22583
|
}
|
|
22418
22584
|
}
|
|
22585
|
+
async function changeVisitorTransactionKeysById(req, res, next) {
|
|
22586
|
+
const idValidation = import_joi55.default.string().hex().length(24).required();
|
|
22587
|
+
const bodyValidation = import_joi55.default.object({
|
|
22588
|
+
visitorPass: import_joi55.default.array().items(
|
|
22589
|
+
import_joi55.default.object({
|
|
22590
|
+
keyId: import_joi55.default.string().hex().length(24).required()
|
|
22591
|
+
})
|
|
22592
|
+
).optional(),
|
|
22593
|
+
passKeys: import_joi55.default.array().items(
|
|
22594
|
+
import_joi55.default.object({
|
|
22595
|
+
keyId: import_joi55.default.string().hex().length(24).required()
|
|
22596
|
+
})
|
|
22597
|
+
).optional()
|
|
22598
|
+
}).or("visitorPass", "passKeys");
|
|
22599
|
+
const _id = req.params.id;
|
|
22600
|
+
const { error: idError } = idValidation.validate(_id);
|
|
22601
|
+
if (idError) {
|
|
22602
|
+
import_node_server_utils102.logger.log({ level: "error", message: idError.message });
|
|
22603
|
+
next(new import_node_server_utils102.BadRequestError(idError.message));
|
|
22604
|
+
return;
|
|
22605
|
+
}
|
|
22606
|
+
const { error, value } = bodyValidation.validate(req.body, {
|
|
22607
|
+
abortEarly: false
|
|
22608
|
+
});
|
|
22609
|
+
if (error) {
|
|
22610
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
22611
|
+
import_node_server_utils102.logger.log({ level: "error", message });
|
|
22612
|
+
next(new import_node_server_utils102.BadRequestError(message));
|
|
22613
|
+
return;
|
|
22614
|
+
}
|
|
22615
|
+
try {
|
|
22616
|
+
const { visitorPass, passKeys } = value;
|
|
22617
|
+
const result = await _changeVisitorTransactionKeysById(
|
|
22618
|
+
_id,
|
|
22619
|
+
visitorPass,
|
|
22620
|
+
passKeys
|
|
22621
|
+
);
|
|
22622
|
+
res.status(200).json({
|
|
22623
|
+
message: result || "Successfully changed visitor transaction keys."
|
|
22624
|
+
});
|
|
22625
|
+
return;
|
|
22626
|
+
} catch (error2) {
|
|
22627
|
+
import_node_server_utils102.logger.log({ level: "error", message: error2.message });
|
|
22628
|
+
next(error2);
|
|
22629
|
+
return;
|
|
22630
|
+
}
|
|
22631
|
+
}
|
|
22419
22632
|
return {
|
|
22420
22633
|
add,
|
|
22421
22634
|
getAll,
|
|
22422
22635
|
updateVisitorTansactionById,
|
|
22423
22636
|
deleteVisitorTransaction,
|
|
22424
22637
|
inviteVisitor,
|
|
22425
|
-
getVisitorTransactionById
|
|
22638
|
+
getVisitorTransactionById,
|
|
22639
|
+
changeVisitorTransactionKeysById
|
|
22426
22640
|
};
|
|
22427
22641
|
}
|
|
22428
22642
|
|
|
@@ -36436,6 +36650,10 @@ var schemaSOABillingItem = import_joi92.default.object({
|
|
|
36436
36650
|
taxPercentage: import_joi92.default.number().optional().allow(null),
|
|
36437
36651
|
taxAmount: import_joi92.default.number().optional().allow(null)
|
|
36438
36652
|
});
|
|
36653
|
+
var schemaApprovedBy = import_joi92.default.object({
|
|
36654
|
+
_id: import_joi92.default.string().hex().optional().allow(null, ""),
|
|
36655
|
+
name: import_joi92.default.string().optional().allow(null, "")
|
|
36656
|
+
});
|
|
36439
36657
|
var schemaStatementOfAccount = import_joi92.default.object({
|
|
36440
36658
|
_id: import_joi92.default.string().hex().optional(),
|
|
36441
36659
|
site: import_joi92.default.string().hex().required(),
|
|
@@ -36449,6 +36667,7 @@ var schemaStatementOfAccount = import_joi92.default.object({
|
|
|
36449
36667
|
category: import_joi92.default.string().optional().allow(null, ""),
|
|
36450
36668
|
status: import_joi92.default.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
|
|
36451
36669
|
billing: import_joi92.default.array().items(schemaSOABillingItem).optional().allow(null, ""),
|
|
36670
|
+
approvedBy: schemaApprovedBy.optional().allow(null, ""),
|
|
36452
36671
|
createdBy: import_joi92.default.string().hex().required(),
|
|
36453
36672
|
createdByName: import_joi92.default.string().optional().allow(null, ""),
|
|
36454
36673
|
createdAt: import_joi92.default.date().optional(),
|
|
@@ -36468,6 +36687,7 @@ var schemaUpdateStatementOfAccount = import_joi92.default.object({
|
|
|
36468
36687
|
category: import_joi92.default.string().optional().allow(null, ""),
|
|
36469
36688
|
status: import_joi92.default.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
|
|
36470
36689
|
billing: import_joi92.default.array().items(schemaSOABillingItem).optional().allow(null, ""),
|
|
36690
|
+
approvedBy: schemaApprovedBy.optional().allow(null, ""),
|
|
36471
36691
|
createdBy: import_joi92.default.string().optional().allow(null, ""),
|
|
36472
36692
|
createdByName: import_joi92.default.string().optional().allow(null, "")
|
|
36473
36693
|
});
|
|
@@ -36532,6 +36752,7 @@ function MStatementOfAccount(value) {
|
|
|
36532
36752
|
status: value.status ?? "pending",
|
|
36533
36753
|
createdBy: value.createdBy,
|
|
36534
36754
|
createdByName: value.createdByName ?? "",
|
|
36755
|
+
approvedBy: value.approvedBy,
|
|
36535
36756
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
36536
36757
|
updatedAt: value.updatedAt ?? "",
|
|
36537
36758
|
deletedAt: value.deletedAt ?? ""
|
|
@@ -36861,6 +37082,35 @@ function useStatementOfAccountRepo() {
|
|
|
36861
37082
|
});
|
|
36862
37083
|
});
|
|
36863
37084
|
}
|
|
37085
|
+
async function reviewSOA(_id, value, session) {
|
|
37086
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
37087
|
+
try {
|
|
37088
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
37089
|
+
} catch (error) {
|
|
37090
|
+
throw new import_node_server_utils164.BadRequestError("Invalid ID format.");
|
|
37091
|
+
}
|
|
37092
|
+
try {
|
|
37093
|
+
const res = await collection.updateOne(
|
|
37094
|
+
{ _id },
|
|
37095
|
+
{ $set: value },
|
|
37096
|
+
{ session }
|
|
37097
|
+
);
|
|
37098
|
+
if (res.modifiedCount === 0) {
|
|
37099
|
+
throw new import_node_server_utils164.InternalServerError(`Unable to ${value.status} soa.`);
|
|
37100
|
+
}
|
|
37101
|
+
delNamespace().then(() => {
|
|
37102
|
+
import_node_server_utils164.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
37103
|
+
}).catch((err) => {
|
|
37104
|
+
import_node_server_utils164.logger.error(
|
|
37105
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
37106
|
+
err
|
|
37107
|
+
);
|
|
37108
|
+
});
|
|
37109
|
+
return res;
|
|
37110
|
+
} catch (error) {
|
|
37111
|
+
throw error;
|
|
37112
|
+
}
|
|
37113
|
+
}
|
|
36864
37114
|
return {
|
|
36865
37115
|
createTextIndex,
|
|
36866
37116
|
add,
|
|
@@ -36869,7 +37119,8 @@ function useStatementOfAccountRepo() {
|
|
|
36869
37119
|
updateById,
|
|
36870
37120
|
deleteById,
|
|
36871
37121
|
updateStatusById,
|
|
36872
|
-
getResidentUserSoa
|
|
37122
|
+
getResidentUserSoa,
|
|
37123
|
+
reviewSOA
|
|
36873
37124
|
};
|
|
36874
37125
|
}
|
|
36875
37126
|
|
|
@@ -36878,9 +37129,10 @@ var import_node_server_utils166 = require("@7365admin1/node-server-utils");
|
|
|
36878
37129
|
|
|
36879
37130
|
// src/services/site-soa.service.ts
|
|
36880
37131
|
var import_node_server_utils165 = require("@7365admin1/node-server-utils");
|
|
37132
|
+
var import_mongodb98 = require("mongodb");
|
|
36881
37133
|
var import_puppeteer = require("puppeteer");
|
|
36882
37134
|
function useStatementOfAccountService() {
|
|
36883
|
-
const { add: _add } = useStatementOfAccountRepo();
|
|
37135
|
+
const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
|
|
36884
37136
|
const { getUnitBillingBySite } = useSiteUnitBillingRepo();
|
|
36885
37137
|
const { getUserById } = useUserRepo();
|
|
36886
37138
|
async function add(value, dateFrom, dateTo) {
|
|
@@ -37008,9 +37260,31 @@ function useStatementOfAccountService() {
|
|
|
37008
37260
|
throw error;
|
|
37009
37261
|
}
|
|
37010
37262
|
}
|
|
37263
|
+
async function reviewSOA(id, value) {
|
|
37264
|
+
const session = import_node_server_utils165.useAtlas.getClient()?.startSession();
|
|
37265
|
+
session?.startTransaction();
|
|
37266
|
+
try {
|
|
37267
|
+
if (value?.approvedBy?._id) {
|
|
37268
|
+
const approvedBy = await getUserById(value?.approvedBy?._id);
|
|
37269
|
+
if (!approvedBy || !approvedBy.name)
|
|
37270
|
+
throw new import_node_server_utils165.BadRequestError("Created by not found.");
|
|
37271
|
+
value.approvedBy.name = approvedBy.name;
|
|
37272
|
+
value.approvedBy._id = new import_mongodb98.ObjectId(approvedBy._id);
|
|
37273
|
+
}
|
|
37274
|
+
await _reviewSOA(id, value, session);
|
|
37275
|
+
await session?.commitTransaction();
|
|
37276
|
+
return `Successfully ${value.status} soa.`;
|
|
37277
|
+
} catch (error) {
|
|
37278
|
+
await session?.abortTransaction();
|
|
37279
|
+
throw error;
|
|
37280
|
+
} finally {
|
|
37281
|
+
session?.endSession();
|
|
37282
|
+
}
|
|
37283
|
+
}
|
|
37011
37284
|
return {
|
|
37012
37285
|
add,
|
|
37013
|
-
generatePDF
|
|
37286
|
+
generatePDF,
|
|
37287
|
+
reviewSOA
|
|
37014
37288
|
};
|
|
37015
37289
|
}
|
|
37016
37290
|
|
|
@@ -37025,7 +37299,11 @@ function useStatementOfAccountController() {
|
|
|
37025
37299
|
updateStatusById: _updateStatusById,
|
|
37026
37300
|
getResidentUserSoa: _getResidentUserSoa
|
|
37027
37301
|
} = useStatementOfAccountRepo();
|
|
37028
|
-
const {
|
|
37302
|
+
const {
|
|
37303
|
+
add: _add,
|
|
37304
|
+
generatePDF: _generatePDF,
|
|
37305
|
+
reviewSOA: _reviewSOA
|
|
37306
|
+
} = useStatementOfAccountService();
|
|
37029
37307
|
async function add(req, res, next) {
|
|
37030
37308
|
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
37031
37309
|
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
@@ -37325,6 +37603,40 @@ function useStatementOfAccountController() {
|
|
|
37325
37603
|
return;
|
|
37326
37604
|
}
|
|
37327
37605
|
}
|
|
37606
|
+
async function reviewSOA(req, res, next) {
|
|
37607
|
+
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
37608
|
+
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
37609
|
+
{}
|
|
37610
|
+
);
|
|
37611
|
+
req.body.approvedBy = {
|
|
37612
|
+
_id: "",
|
|
37613
|
+
name: ""
|
|
37614
|
+
};
|
|
37615
|
+
req.body.approvedBy._id = cookies?.["user"] ? cookies["user"].toString() : req.body.approvedBy._id;
|
|
37616
|
+
const _id = req.params.id;
|
|
37617
|
+
const payload = { _id, ...req.body };
|
|
37618
|
+
const schema2 = import_joi93.default.object({
|
|
37619
|
+
_id: import_joi93.default.string().hex().required(),
|
|
37620
|
+
status: import_joi93.default.string().valid("approved", "rejected").required(),
|
|
37621
|
+
approvedBy: schemaApprovedBy
|
|
37622
|
+
});
|
|
37623
|
+
const { error } = schema2.validate(payload);
|
|
37624
|
+
if (error) {
|
|
37625
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
37626
|
+
import_node_server_utils166.logger.log({ level: "error", message: messages });
|
|
37627
|
+
next(new import_node_server_utils166.BadRequestError(messages));
|
|
37628
|
+
return;
|
|
37629
|
+
}
|
|
37630
|
+
try {
|
|
37631
|
+
const result = await _reviewSOA(_id, req.body);
|
|
37632
|
+
res.status(200).json({ message: result });
|
|
37633
|
+
return;
|
|
37634
|
+
} catch (error2) {
|
|
37635
|
+
import_node_server_utils166.logger.log({ level: "error", message: error2.message });
|
|
37636
|
+
next(error2);
|
|
37637
|
+
return;
|
|
37638
|
+
}
|
|
37639
|
+
}
|
|
37328
37640
|
return {
|
|
37329
37641
|
add,
|
|
37330
37642
|
getAll,
|
|
@@ -37333,13 +37645,14 @@ function useStatementOfAccountController() {
|
|
|
37333
37645
|
deleteById,
|
|
37334
37646
|
generatePDF,
|
|
37335
37647
|
updateStatusById,
|
|
37336
|
-
getResidentUserSoa
|
|
37648
|
+
getResidentUserSoa,
|
|
37649
|
+
reviewSOA
|
|
37337
37650
|
};
|
|
37338
37651
|
}
|
|
37339
37652
|
|
|
37340
37653
|
// src/models/site-entrypass-settings.model.ts
|
|
37341
37654
|
var import_node_server_utils167 = require("@7365admin1/node-server-utils");
|
|
37342
|
-
var
|
|
37655
|
+
var import_mongodb99 = require("mongodb");
|
|
37343
37656
|
var import_joi94 = __toESM(require("joi"));
|
|
37344
37657
|
var schemaEntryPassSettings = import_joi94.default.object({
|
|
37345
37658
|
_id: import_joi94.default.string().hex().optional().allow("", null),
|
|
@@ -37387,21 +37700,21 @@ function MEntryPassSettings(value) {
|
|
|
37387
37700
|
}
|
|
37388
37701
|
if (value._id && typeof value._id === "string") {
|
|
37389
37702
|
try {
|
|
37390
|
-
value._id = new
|
|
37703
|
+
value._id = new import_mongodb99.ObjectId(value._id);
|
|
37391
37704
|
} catch {
|
|
37392
37705
|
throw new import_node_server_utils167.BadRequestError("Invalid _id format");
|
|
37393
37706
|
}
|
|
37394
37707
|
}
|
|
37395
37708
|
if (value.site && typeof value.site === "string") {
|
|
37396
37709
|
try {
|
|
37397
|
-
value.site = new
|
|
37710
|
+
value.site = new import_mongodb99.ObjectId(value.site);
|
|
37398
37711
|
} catch {
|
|
37399
37712
|
throw new import_node_server_utils167.BadRequestError("Invalid site format");
|
|
37400
37713
|
}
|
|
37401
37714
|
}
|
|
37402
37715
|
if (value.org && typeof value.org === "string") {
|
|
37403
37716
|
try {
|
|
37404
|
-
value.org = new
|
|
37717
|
+
value.org = new import_mongodb99.ObjectId(value.org);
|
|
37405
37718
|
} catch {
|
|
37406
37719
|
throw new import_node_server_utils167.BadRequestError("Invalid org format");
|
|
37407
37720
|
}
|
|
@@ -37431,7 +37744,7 @@ function MEntryPassSettings(value) {
|
|
|
37431
37744
|
|
|
37432
37745
|
// src/repositories/site-entrypass-settings.repo.ts
|
|
37433
37746
|
var import_node_server_utils168 = require("@7365admin1/node-server-utils");
|
|
37434
|
-
var
|
|
37747
|
+
var import_mongodb100 = require("mongodb");
|
|
37435
37748
|
function useEntryPassSettingsRepo() {
|
|
37436
37749
|
const db = import_node_server_utils168.useAtlas.getDb();
|
|
37437
37750
|
if (!db) {
|
|
@@ -37541,7 +37854,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37541
37854
|
}
|
|
37542
37855
|
async function getEntryPassSettingsById(_id) {
|
|
37543
37856
|
try {
|
|
37544
|
-
_id = new
|
|
37857
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37545
37858
|
} catch (error) {
|
|
37546
37859
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37547
37860
|
}
|
|
@@ -37608,7 +37921,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37608
37921
|
}
|
|
37609
37922
|
async function updateEntryPassSettingsById(_id, value) {
|
|
37610
37923
|
try {
|
|
37611
|
-
_id = new
|
|
37924
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37612
37925
|
} catch (error) {
|
|
37613
37926
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37614
37927
|
}
|
|
@@ -37636,7 +37949,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37636
37949
|
}
|
|
37637
37950
|
async function deleteEntryPassSettingsById(_id, session) {
|
|
37638
37951
|
try {
|
|
37639
|
-
_id = new
|
|
37952
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37640
37953
|
} catch (error) {
|
|
37641
37954
|
throw new import_node_server_utils168.BadRequestError("Invalid card ID format.");
|
|
37642
37955
|
}
|
|
@@ -37669,7 +37982,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37669
37982
|
}
|
|
37670
37983
|
async function getEntryPassSettingsBySiteId(site) {
|
|
37671
37984
|
try {
|
|
37672
|
-
site = new
|
|
37985
|
+
site = new import_mongodb100.ObjectId(site);
|
|
37673
37986
|
} catch (error) {
|
|
37674
37987
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37675
37988
|
}
|
|
@@ -37736,7 +38049,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37736
38049
|
}
|
|
37737
38050
|
async function updateEntryPassSettingsBySiteId(site, value) {
|
|
37738
38051
|
try {
|
|
37739
|
-
site = new
|
|
38052
|
+
site = new import_mongodb100.ObjectId(site);
|
|
37740
38053
|
} catch (error) {
|
|
37741
38054
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37742
38055
|
}
|
|
@@ -38095,7 +38408,7 @@ function useDashboardController() {
|
|
|
38095
38408
|
}
|
|
38096
38409
|
|
|
38097
38410
|
// src/models/nfc-patrol-route.model.ts
|
|
38098
|
-
var
|
|
38411
|
+
var import_mongodb101 = require("mongodb");
|
|
38099
38412
|
var import_joi97 = __toESM(require("joi"));
|
|
38100
38413
|
var import_node_server_utils172 = require("@7365admin1/node-server-utils");
|
|
38101
38414
|
var schemaNfcPatrolRoute = import_joi97.default.object({
|
|
@@ -38131,23 +38444,23 @@ function MNfcPatrolRoute(value) {
|
|
|
38131
38444
|
}
|
|
38132
38445
|
if (value._id && typeof value._id === "string") {
|
|
38133
38446
|
try {
|
|
38134
|
-
value._id = new
|
|
38447
|
+
value._id = new import_mongodb101.ObjectId(value._id);
|
|
38135
38448
|
} catch (error2) {
|
|
38136
38449
|
throw new import_node_server_utils172.BadRequestError("Invalid _id format");
|
|
38137
38450
|
}
|
|
38138
38451
|
}
|
|
38139
38452
|
try {
|
|
38140
|
-
value.site = new
|
|
38453
|
+
value.site = new import_mongodb101.ObjectId(value.site);
|
|
38141
38454
|
} catch (error2) {
|
|
38142
38455
|
throw new import_node_server_utils172.BadRequestError("Invalid site format");
|
|
38143
38456
|
}
|
|
38144
38457
|
try {
|
|
38145
|
-
value.createdBy = new
|
|
38458
|
+
value.createdBy = new import_mongodb101.ObjectId(value.createdBy);
|
|
38146
38459
|
} catch (error2) {
|
|
38147
38460
|
throw new import_node_server_utils172.BadRequestError("Invalid createdBy format");
|
|
38148
38461
|
}
|
|
38149
38462
|
return {
|
|
38150
|
-
_id: value._id ?? new
|
|
38463
|
+
_id: value._id ?? new import_mongodb101.ObjectId(),
|
|
38151
38464
|
site: value.site,
|
|
38152
38465
|
name: value.name,
|
|
38153
38466
|
checkPointNumber: value.checkPointNumber,
|
|
@@ -38163,7 +38476,7 @@ function MNfcPatrolRoute(value) {
|
|
|
38163
38476
|
|
|
38164
38477
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
38165
38478
|
var import_node_server_utils173 = require("@7365admin1/node-server-utils");
|
|
38166
|
-
var
|
|
38479
|
+
var import_mongodb102 = require("mongodb");
|
|
38167
38480
|
function useNfcPatrolRouteRepo() {
|
|
38168
38481
|
const db = import_node_server_utils173.useAtlas.getDb();
|
|
38169
38482
|
if (!db) {
|
|
@@ -38207,7 +38520,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
38207
38520
|
}, session) {
|
|
38208
38521
|
page = page > 0 ? page - 1 : 0;
|
|
38209
38522
|
try {
|
|
38210
|
-
site = new
|
|
38523
|
+
site = new import_mongodb102.ObjectId(site);
|
|
38211
38524
|
} catch (error) {
|
|
38212
38525
|
throw new import_node_server_utils173.BadRequestError("Invalid site ID format.");
|
|
38213
38526
|
}
|
|
@@ -38278,7 +38591,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
38278
38591
|
}
|
|
38279
38592
|
async function getById(_id, isStart) {
|
|
38280
38593
|
try {
|
|
38281
|
-
_id = new
|
|
38594
|
+
_id = new import_mongodb102.ObjectId(_id);
|
|
38282
38595
|
} catch (error) {
|
|
38283
38596
|
throw new import_node_server_utils173.BadRequestError("Invalid ID.");
|
|
38284
38597
|
}
|
|
@@ -38388,18 +38701,18 @@ function useNfcPatrolRouteRepo() {
|
|
|
38388
38701
|
throw new import_node_server_utils173.BadRequestError(error.message);
|
|
38389
38702
|
}
|
|
38390
38703
|
try {
|
|
38391
|
-
_id = new
|
|
38704
|
+
_id = new import_mongodb102.ObjectId(_id);
|
|
38392
38705
|
} catch (error2) {
|
|
38393
38706
|
throw new import_node_server_utils173.BadRequestError("Invalid ID.");
|
|
38394
38707
|
}
|
|
38395
38708
|
try {
|
|
38396
|
-
value.site = new
|
|
38709
|
+
value.site = new import_mongodb102.ObjectId(value.site);
|
|
38397
38710
|
} catch (error2) {
|
|
38398
38711
|
throw new import_node_server_utils173.BadRequestError("Invalid site format");
|
|
38399
38712
|
}
|
|
38400
38713
|
if (value.updatedBy) {
|
|
38401
38714
|
try {
|
|
38402
|
-
value.updatedBy = new
|
|
38715
|
+
value.updatedBy = new import_mongodb102.ObjectId(value.updatedBy);
|
|
38403
38716
|
} catch (error2) {
|
|
38404
38717
|
throw new import_node_server_utils173.BadRequestError("Invalid createdBy format");
|
|
38405
38718
|
}
|
|
@@ -38624,7 +38937,7 @@ function useNfcPatrolRouteController() {
|
|
|
38624
38937
|
}
|
|
38625
38938
|
|
|
38626
38939
|
// src/models/incident-report.model.ts
|
|
38627
|
-
var
|
|
38940
|
+
var import_mongodb103 = require("mongodb");
|
|
38628
38941
|
var import_joi99 = __toESM(require("joi"));
|
|
38629
38942
|
var residentSchema = import_joi99.default.object({
|
|
38630
38943
|
_id: import_joi99.default.string().hex().optional().allow(null, ""),
|
|
@@ -38828,28 +39141,28 @@ var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
|
38828
39141
|
function MIncidentReport(value) {
|
|
38829
39142
|
if (value._id && typeof value._id === "string") {
|
|
38830
39143
|
try {
|
|
38831
|
-
value._id = new
|
|
39144
|
+
value._id = new import_mongodb103.ObjectId(value._id);
|
|
38832
39145
|
} catch {
|
|
38833
39146
|
throw new Error("Invalid incident report ID.");
|
|
38834
39147
|
}
|
|
38835
39148
|
}
|
|
38836
39149
|
if (value.organization && typeof value.organization === "string") {
|
|
38837
39150
|
try {
|
|
38838
|
-
value.organization = new
|
|
39151
|
+
value.organization = new import_mongodb103.ObjectId(value.organization);
|
|
38839
39152
|
} catch {
|
|
38840
39153
|
throw new Error("Invalid organization ID.");
|
|
38841
39154
|
}
|
|
38842
39155
|
}
|
|
38843
39156
|
if (value.site && typeof value.site === "string") {
|
|
38844
39157
|
try {
|
|
38845
|
-
value.site = new
|
|
39158
|
+
value.site = new import_mongodb103.ObjectId(value.site);
|
|
38846
39159
|
} catch {
|
|
38847
39160
|
throw new Error("Invalid site ID.");
|
|
38848
39161
|
}
|
|
38849
39162
|
}
|
|
38850
39163
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
38851
39164
|
try {
|
|
38852
|
-
value.approvedBy = new
|
|
39165
|
+
value.approvedBy = new import_mongodb103.ObjectId(value.approvedBy);
|
|
38853
39166
|
} catch {
|
|
38854
39167
|
throw new Error("Invalid approvedBy ID.");
|
|
38855
39168
|
}
|
|
@@ -38857,7 +39170,7 @@ function MIncidentReport(value) {
|
|
|
38857
39170
|
const { incidentInformation } = value;
|
|
38858
39171
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
38859
39172
|
try {
|
|
38860
|
-
incidentInformation.siteInfo.site = new
|
|
39173
|
+
incidentInformation.siteInfo.site = new import_mongodb103.ObjectId(
|
|
38861
39174
|
incidentInformation.siteInfo.site
|
|
38862
39175
|
);
|
|
38863
39176
|
} catch {
|
|
@@ -38871,7 +39184,7 @@ function MIncidentReport(value) {
|
|
|
38871
39184
|
incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
|
|
38872
39185
|
}
|
|
38873
39186
|
return {
|
|
38874
|
-
_id: value._id ?? new
|
|
39187
|
+
_id: value._id ?? new import_mongodb103.ObjectId(),
|
|
38875
39188
|
reportId: value.reportId,
|
|
38876
39189
|
incidentInformation: value.incidentInformation,
|
|
38877
39190
|
affectedEntities: value.affectedEntities,
|
|
@@ -38895,7 +39208,7 @@ var import_node_server_utils177 = require("@7365admin1/node-server-utils");
|
|
|
38895
39208
|
|
|
38896
39209
|
// src/repositories/incident-report.repo.ts
|
|
38897
39210
|
var import_node_server_utils176 = require("@7365admin1/node-server-utils");
|
|
38898
|
-
var
|
|
39211
|
+
var import_mongodb104 = require("mongodb");
|
|
38899
39212
|
var incidents_namespace_collection = "incident-reports";
|
|
38900
39213
|
function useIncidentReportRepo() {
|
|
38901
39214
|
const db = import_node_server_utils176.useAtlas.getDb();
|
|
@@ -38962,7 +39275,7 @@ function useIncidentReportRepo() {
|
|
|
38962
39275
|
page = page > 0 ? page - 1 : 0;
|
|
38963
39276
|
let dateExpr = {};
|
|
38964
39277
|
try {
|
|
38965
|
-
site = new
|
|
39278
|
+
site = new import_mongodb104.ObjectId(site);
|
|
38966
39279
|
} catch (error) {
|
|
38967
39280
|
throw new import_node_server_utils176.BadRequestError("Invalid site ID format.");
|
|
38968
39281
|
}
|
|
@@ -39063,7 +39376,7 @@ function useIncidentReportRepo() {
|
|
|
39063
39376
|
page = page > 0 ? page - 1 : 0;
|
|
39064
39377
|
let dateExpr = {};
|
|
39065
39378
|
try {
|
|
39066
|
-
site = new
|
|
39379
|
+
site = new import_mongodb104.ObjectId(site);
|
|
39067
39380
|
} catch (error) {
|
|
39068
39381
|
throw new import_node_server_utils176.BadRequestError("Invalid site ID format.");
|
|
39069
39382
|
}
|
|
@@ -39132,7 +39445,7 @@ function useIncidentReportRepo() {
|
|
|
39132
39445
|
}
|
|
39133
39446
|
async function getIncidentReportById(_id, session) {
|
|
39134
39447
|
try {
|
|
39135
|
-
_id = new
|
|
39448
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39136
39449
|
} catch (error) {
|
|
39137
39450
|
throw new import_node_server_utils176.BadRequestError("Invalid incident report ID format.");
|
|
39138
39451
|
}
|
|
@@ -39163,27 +39476,27 @@ function useIncidentReportRepo() {
|
|
|
39163
39476
|
async function updateIncidentReportById(_id, value, session) {
|
|
39164
39477
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
39165
39478
|
try {
|
|
39166
|
-
_id = new
|
|
39479
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39167
39480
|
} catch (error) {
|
|
39168
39481
|
throw new import_node_server_utils176.BadRequestError("Invalid ID format.");
|
|
39169
39482
|
}
|
|
39170
39483
|
if (value.organization && typeof value.organization === "string") {
|
|
39171
39484
|
try {
|
|
39172
|
-
value.organization = new
|
|
39485
|
+
value.organization = new import_mongodb104.ObjectId(value.organization);
|
|
39173
39486
|
} catch {
|
|
39174
39487
|
throw new Error("Invalid organization ID.");
|
|
39175
39488
|
}
|
|
39176
39489
|
}
|
|
39177
39490
|
if (value.site && typeof value.site === "string") {
|
|
39178
39491
|
try {
|
|
39179
|
-
value.site = new
|
|
39492
|
+
value.site = new import_mongodb104.ObjectId(value.site);
|
|
39180
39493
|
} catch {
|
|
39181
39494
|
throw new Error("Invalid site ID.");
|
|
39182
39495
|
}
|
|
39183
39496
|
}
|
|
39184
39497
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
39185
39498
|
try {
|
|
39186
|
-
value.approvedBy = new
|
|
39499
|
+
value.approvedBy = new import_mongodb104.ObjectId(value.approvedBy);
|
|
39187
39500
|
} catch {
|
|
39188
39501
|
throw new Error("Invalid approvedBy ID.");
|
|
39189
39502
|
}
|
|
@@ -39191,7 +39504,7 @@ function useIncidentReportRepo() {
|
|
|
39191
39504
|
const { incidentInformation } = value;
|
|
39192
39505
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
39193
39506
|
try {
|
|
39194
|
-
incidentInformation.siteInfo.site = new
|
|
39507
|
+
incidentInformation.siteInfo.site = new import_mongodb104.ObjectId(
|
|
39195
39508
|
incidentInformation.siteInfo.site
|
|
39196
39509
|
);
|
|
39197
39510
|
} catch {
|
|
@@ -39226,7 +39539,7 @@ function useIncidentReportRepo() {
|
|
|
39226
39539
|
}
|
|
39227
39540
|
async function deleteIncidentReportById(_id) {
|
|
39228
39541
|
try {
|
|
39229
|
-
_id = new
|
|
39542
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39230
39543
|
} catch (error) {
|
|
39231
39544
|
throw new import_node_server_utils176.BadRequestError("Invalid occurrence subject ID format.");
|
|
39232
39545
|
}
|
|
@@ -39258,7 +39571,7 @@ function useIncidentReportRepo() {
|
|
|
39258
39571
|
async function reviewIncidentReport(_id, value, session) {
|
|
39259
39572
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
39260
39573
|
try {
|
|
39261
|
-
_id = new
|
|
39574
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39262
39575
|
} catch (error) {
|
|
39263
39576
|
throw new import_node_server_utils176.BadRequestError("Invalid ID format.");
|
|
39264
39577
|
}
|
|
@@ -39750,7 +40063,7 @@ function useIncidentReportController() {
|
|
|
39750
40063
|
}
|
|
39751
40064
|
|
|
39752
40065
|
// src/models/nfc-patrol-settings.model.ts
|
|
39753
|
-
var
|
|
40066
|
+
var import_mongodb105 = require("mongodb");
|
|
39754
40067
|
var import_joi101 = __toESM(require("joi"));
|
|
39755
40068
|
var import_node_server_utils179 = require("@7365admin1/node-server-utils");
|
|
39756
40069
|
var objectId = import_joi101.default.string().hex().length(24);
|
|
@@ -39776,7 +40089,7 @@ function MNfcPatrolSettings(value) {
|
|
|
39776
40089
|
}
|
|
39777
40090
|
if (value.site) {
|
|
39778
40091
|
try {
|
|
39779
|
-
value.site = new
|
|
40092
|
+
value.site = new import_mongodb105.ObjectId(value.site);
|
|
39780
40093
|
} catch (error2) {
|
|
39781
40094
|
throw new import_node_server_utils179.BadRequestError("Invalid site ID format.");
|
|
39782
40095
|
}
|
|
@@ -39796,7 +40109,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
39796
40109
|
}
|
|
39797
40110
|
if (value.updatedBy) {
|
|
39798
40111
|
try {
|
|
39799
|
-
value.updatedBy = new
|
|
40112
|
+
value.updatedBy = new import_mongodb105.ObjectId(value.updatedBy);
|
|
39800
40113
|
} catch (error2) {
|
|
39801
40114
|
throw new import_node_server_utils179.BadRequestError("Invalid updatedBy ID format.");
|
|
39802
40115
|
}
|
|
@@ -39810,7 +40123,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
39810
40123
|
|
|
39811
40124
|
// src/repositories/nfc-patrol-settings.repository.ts
|
|
39812
40125
|
var import_node_server_utils180 = require("@7365admin1/node-server-utils");
|
|
39813
|
-
var
|
|
40126
|
+
var import_mongodb106 = require("mongodb");
|
|
39814
40127
|
function useNfcPatrolSettingsRepository() {
|
|
39815
40128
|
const db = import_node_server_utils180.useAtlas.getDb();
|
|
39816
40129
|
if (!db) {
|
|
@@ -39840,7 +40153,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
39840
40153
|
}
|
|
39841
40154
|
async function getNfcPatrolSettingsBySite(site, session) {
|
|
39842
40155
|
try {
|
|
39843
|
-
site = new
|
|
40156
|
+
site = new import_mongodb106.ObjectId(site);
|
|
39844
40157
|
} catch (error) {
|
|
39845
40158
|
throw new import_node_server_utils180.BadRequestError("Invalid nfc patrol settings site ID format.");
|
|
39846
40159
|
}
|
|
@@ -39884,7 +40197,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
39884
40197
|
}
|
|
39885
40198
|
async function updateNfcPatrolSettings(site, value, session) {
|
|
39886
40199
|
try {
|
|
39887
|
-
site = new
|
|
40200
|
+
site = new import_mongodb106.ObjectId(site);
|
|
39888
40201
|
} catch (error) {
|
|
39889
40202
|
throw new import_node_server_utils180.BadRequestError("Invalid attendance settings ID format.");
|
|
39890
40203
|
}
|
|
@@ -40049,13 +40362,13 @@ function useNfcPatrolSettingsController() {
|
|
|
40049
40362
|
|
|
40050
40363
|
// src/services/occurrence-entry.service.ts
|
|
40051
40364
|
var import_node_server_utils184 = require("@7365admin1/node-server-utils");
|
|
40052
|
-
var
|
|
40365
|
+
var import_mongodb109 = require("mongodb");
|
|
40053
40366
|
|
|
40054
40367
|
// src/repositories/occurrence-subject.repo.ts
|
|
40055
40368
|
var import_node_server_utils183 = require("@7365admin1/node-server-utils");
|
|
40056
40369
|
|
|
40057
40370
|
// src/models/occurrence-subject.model.ts
|
|
40058
|
-
var
|
|
40371
|
+
var import_mongodb107 = require("mongodb");
|
|
40059
40372
|
var import_joi103 = __toESM(require("joi"));
|
|
40060
40373
|
var schemaOccurrenceSubject = import_joi103.default.object({
|
|
40061
40374
|
site: import_joi103.default.string().hex().required(),
|
|
@@ -40069,27 +40382,27 @@ var schemaUpdateOccurrenceSubject = import_joi103.default.object({
|
|
|
40069
40382
|
function MOccurrenceSubject(value) {
|
|
40070
40383
|
if (value._id && typeof value._id === "string") {
|
|
40071
40384
|
try {
|
|
40072
|
-
value._id = new
|
|
40385
|
+
value._id = new import_mongodb107.ObjectId(value._id);
|
|
40073
40386
|
} catch {
|
|
40074
40387
|
throw new Error("Invalid ID.");
|
|
40075
40388
|
}
|
|
40076
40389
|
}
|
|
40077
40390
|
if (value.site && typeof value.site === "string") {
|
|
40078
40391
|
try {
|
|
40079
|
-
value.site = new
|
|
40392
|
+
value.site = new import_mongodb107.ObjectId(value.site);
|
|
40080
40393
|
} catch {
|
|
40081
40394
|
throw new Error("Invalid site ID.");
|
|
40082
40395
|
}
|
|
40083
40396
|
}
|
|
40084
40397
|
if (value.addedBy && typeof value.addedBy === "string") {
|
|
40085
40398
|
try {
|
|
40086
|
-
value.addedBy = new
|
|
40399
|
+
value.addedBy = new import_mongodb107.ObjectId(value.addedBy);
|
|
40087
40400
|
} catch {
|
|
40088
40401
|
throw new Error("Invalid addedBy ID.");
|
|
40089
40402
|
}
|
|
40090
40403
|
}
|
|
40091
40404
|
return {
|
|
40092
|
-
_id: value._id ?? new
|
|
40405
|
+
_id: value._id ?? new import_mongodb107.ObjectId(),
|
|
40093
40406
|
site: value.site,
|
|
40094
40407
|
subject: value.subject,
|
|
40095
40408
|
addedBy: value.addedBy ?? "",
|
|
@@ -40100,7 +40413,7 @@ function MOccurrenceSubject(value) {
|
|
|
40100
40413
|
}
|
|
40101
40414
|
|
|
40102
40415
|
// src/repositories/occurrence-subject.repo.ts
|
|
40103
|
-
var
|
|
40416
|
+
var import_mongodb108 = require("mongodb");
|
|
40104
40417
|
function useOccurrenceSubjectRepo() {
|
|
40105
40418
|
const db = import_node_server_utils183.useAtlas.getDb();
|
|
40106
40419
|
if (!db) {
|
|
@@ -40159,7 +40472,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40159
40472
|
}, session) {
|
|
40160
40473
|
page = page > 0 ? page - 1 : 0;
|
|
40161
40474
|
try {
|
|
40162
|
-
site = new
|
|
40475
|
+
site = new import_mongodb108.ObjectId(site);
|
|
40163
40476
|
} catch (error) {
|
|
40164
40477
|
throw new import_node_server_utils183.BadRequestError("Invalid site ID format.");
|
|
40165
40478
|
}
|
|
@@ -40254,7 +40567,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40254
40567
|
}
|
|
40255
40568
|
async function getOccurrenceSubjectById(_id, session) {
|
|
40256
40569
|
try {
|
|
40257
|
-
_id = new
|
|
40570
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40258
40571
|
} catch (error) {
|
|
40259
40572
|
throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
|
|
40260
40573
|
}
|
|
@@ -40271,7 +40584,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40271
40584
|
async function updateOccurrenceSubjectById(_id, value, session) {
|
|
40272
40585
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
40273
40586
|
try {
|
|
40274
|
-
_id = new
|
|
40587
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40275
40588
|
} catch (error) {
|
|
40276
40589
|
throw new import_node_server_utils183.BadRequestError("Invalid ID format.");
|
|
40277
40590
|
}
|
|
@@ -40301,7 +40614,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40301
40614
|
}
|
|
40302
40615
|
async function deleteOccurrenceSubjectById(_id) {
|
|
40303
40616
|
try {
|
|
40304
|
-
_id = new
|
|
40617
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40305
40618
|
} catch (error) {
|
|
40306
40619
|
throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
|
|
40307
40620
|
}
|
|
@@ -40413,8 +40726,8 @@ function useOccurrenceEntryService() {
|
|
|
40413
40726
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40414
40727
|
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
40415
40728
|
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
40416
|
-
value.signature = value.signature ? new
|
|
40417
|
-
value.eSignature = value.eSignature ? new
|
|
40729
|
+
value.signature = value.signature ? new import_mongodb109.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
40730
|
+
value.eSignature = value.eSignature ? new import_mongodb109.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
40418
40731
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
40419
40732
|
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
40420
40733
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
@@ -40614,7 +40927,7 @@ function useOccurrenceEntryController() {
|
|
|
40614
40927
|
|
|
40615
40928
|
// src/models/online-form.model.ts
|
|
40616
40929
|
var import_joi105 = __toESM(require("joi"));
|
|
40617
|
-
var
|
|
40930
|
+
var import_mongodb110 = require("mongodb");
|
|
40618
40931
|
var schemaOnlineForm = import_joi105.default.object({
|
|
40619
40932
|
_id: import_joi105.default.string().hex().optional().allow("", null),
|
|
40620
40933
|
name: import_joi105.default.string().required(),
|
|
@@ -40662,21 +40975,21 @@ function MOnlineForm(value) {
|
|
|
40662
40975
|
}
|
|
40663
40976
|
if (value._id && typeof value._id === "string") {
|
|
40664
40977
|
try {
|
|
40665
|
-
value._id = new
|
|
40978
|
+
value._id = new import_mongodb110.ObjectId(value._id);
|
|
40666
40979
|
} catch (error2) {
|
|
40667
40980
|
throw new Error("Invalid ID.");
|
|
40668
40981
|
}
|
|
40669
40982
|
}
|
|
40670
40983
|
if (value.org && typeof value.org === "string") {
|
|
40671
40984
|
try {
|
|
40672
|
-
value.org = new
|
|
40985
|
+
value.org = new import_mongodb110.ObjectId(value.org);
|
|
40673
40986
|
} catch (error2) {
|
|
40674
40987
|
throw new Error("Invalid org ID.");
|
|
40675
40988
|
}
|
|
40676
40989
|
}
|
|
40677
40990
|
if (value.site && typeof value.site === "string") {
|
|
40678
40991
|
try {
|
|
40679
|
-
value.site = new
|
|
40992
|
+
value.site = new import_mongodb110.ObjectId(value.site);
|
|
40680
40993
|
} catch (error2) {
|
|
40681
40994
|
throw new Error("Invalid site ID.");
|
|
40682
40995
|
}
|
|
@@ -40699,7 +41012,7 @@ function MOnlineForm(value) {
|
|
|
40699
41012
|
|
|
40700
41013
|
// src/repositories/online-form.repo.ts
|
|
40701
41014
|
var import_node_server_utils186 = require("@7365admin1/node-server-utils");
|
|
40702
|
-
var
|
|
41015
|
+
var import_mongodb111 = require("mongodb");
|
|
40703
41016
|
function useOnlineFormRepo() {
|
|
40704
41017
|
const db = import_node_server_utils186.useAtlas.getDb();
|
|
40705
41018
|
if (!db) {
|
|
@@ -40751,7 +41064,7 @@ function useOnlineFormRepo() {
|
|
|
40751
41064
|
}) {
|
|
40752
41065
|
page = page > 0 ? page - 1 : 0;
|
|
40753
41066
|
try {
|
|
40754
|
-
site = new
|
|
41067
|
+
site = new import_mongodb111.ObjectId(site);
|
|
40755
41068
|
} catch (error) {
|
|
40756
41069
|
throw new import_node_server_utils186.BadRequestError("Invalid site ID format.");
|
|
40757
41070
|
}
|
|
@@ -40811,7 +41124,7 @@ function useOnlineFormRepo() {
|
|
|
40811
41124
|
}
|
|
40812
41125
|
async function getOnlineFormById(_id) {
|
|
40813
41126
|
try {
|
|
40814
|
-
_id = new
|
|
41127
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40815
41128
|
} catch (error) {
|
|
40816
41129
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40817
41130
|
}
|
|
@@ -40854,7 +41167,7 @@ function useOnlineFormRepo() {
|
|
|
40854
41167
|
}
|
|
40855
41168
|
async function updateOnlineFormById(_id, value) {
|
|
40856
41169
|
try {
|
|
40857
|
-
_id = new
|
|
41170
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40858
41171
|
} catch (error) {
|
|
40859
41172
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40860
41173
|
}
|
|
@@ -40882,7 +41195,7 @@ function useOnlineFormRepo() {
|
|
|
40882
41195
|
}
|
|
40883
41196
|
async function deleteOnlineFormById(_id, session) {
|
|
40884
41197
|
try {
|
|
40885
|
-
_id = new
|
|
41198
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40886
41199
|
} catch (error) {
|
|
40887
41200
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40888
41201
|
}
|
|
@@ -40915,7 +41228,7 @@ function useOnlineFormRepo() {
|
|
|
40915
41228
|
}
|
|
40916
41229
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
40917
41230
|
try {
|
|
40918
|
-
site = new
|
|
41231
|
+
site = new import_mongodb111.ObjectId(site);
|
|
40919
41232
|
} catch (error) {
|
|
40920
41233
|
throw new import_node_server_utils186.BadRequestError(
|
|
40921
41234
|
"Invalid online form configuration site ID format."
|
|
@@ -41356,7 +41669,7 @@ function useOccurrenceSubjectController() {
|
|
|
41356
41669
|
}
|
|
41357
41670
|
|
|
41358
41671
|
// src/models/nfc-patrol-log.model.ts
|
|
41359
|
-
var
|
|
41672
|
+
var import_mongodb112 = require("mongodb");
|
|
41360
41673
|
var import_joi108 = __toESM(require("joi"));
|
|
41361
41674
|
var import_node_server_utils190 = require("@7365admin1/node-server-utils");
|
|
41362
41675
|
var schemaNfcPatrolLog = import_joi108.default.object({
|
|
@@ -41408,32 +41721,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41408
41721
|
}
|
|
41409
41722
|
if (value._id && typeof value._id === "string") {
|
|
41410
41723
|
try {
|
|
41411
|
-
value._id = new
|
|
41724
|
+
value._id = new import_mongodb112.ObjectId(value._id);
|
|
41412
41725
|
} catch (error2) {
|
|
41413
41726
|
throw new import_node_server_utils190.BadRequestError("Invalid _id format");
|
|
41414
41727
|
}
|
|
41415
41728
|
}
|
|
41416
41729
|
try {
|
|
41417
|
-
value.site = new
|
|
41730
|
+
value.site = new import_mongodb112.ObjectId(value.site);
|
|
41418
41731
|
} catch (error2) {
|
|
41419
41732
|
throw new import_node_server_utils190.BadRequestError("Invalid site format");
|
|
41420
41733
|
}
|
|
41421
41734
|
if (value?.createdBy) {
|
|
41422
41735
|
try {
|
|
41423
|
-
value.createdBy = new
|
|
41736
|
+
value.createdBy = new import_mongodb112.ObjectId(value.createdBy);
|
|
41424
41737
|
} catch (error2) {
|
|
41425
41738
|
throw new import_node_server_utils190.BadRequestError("Invalid createdBy format");
|
|
41426
41739
|
}
|
|
41427
41740
|
}
|
|
41428
41741
|
if (value?.route?._id) {
|
|
41429
41742
|
try {
|
|
41430
|
-
value.route._id = new
|
|
41743
|
+
value.route._id = new import_mongodb112.ObjectId(value.route._id);
|
|
41431
41744
|
} catch (error2) {
|
|
41432
41745
|
throw new import_node_server_utils190.BadRequestError("Invalid route _id format");
|
|
41433
41746
|
}
|
|
41434
41747
|
}
|
|
41435
41748
|
return {
|
|
41436
|
-
_id: value._id ?? new
|
|
41749
|
+
_id: value._id ?? new import_mongodb112.ObjectId(),
|
|
41437
41750
|
site: value.site,
|
|
41438
41751
|
route: value.route,
|
|
41439
41752
|
date: value.date,
|
|
@@ -41447,7 +41760,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41447
41760
|
|
|
41448
41761
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
41449
41762
|
var import_node_server_utils191 = require("@7365admin1/node-server-utils");
|
|
41450
|
-
var
|
|
41763
|
+
var import_mongodb113 = require("mongodb");
|
|
41451
41764
|
function useNfcPatrolLogRepo() {
|
|
41452
41765
|
const db = import_node_server_utils191.useAtlas.getDb();
|
|
41453
41766
|
if (!db) {
|
|
@@ -41500,7 +41813,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41500
41813
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
41501
41814
|
let siteId;
|
|
41502
41815
|
try {
|
|
41503
|
-
siteId = typeof site === "string" ? new
|
|
41816
|
+
siteId = typeof site === "string" ? new import_mongodb113.ObjectId(site) : site;
|
|
41504
41817
|
} catch {
|
|
41505
41818
|
throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
|
|
41506
41819
|
}
|
|
@@ -41511,7 +41824,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41511
41824
|
query.date = date;
|
|
41512
41825
|
}
|
|
41513
41826
|
if (route?._id) {
|
|
41514
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
41827
|
+
query["route._id"] = typeof route._id === "string" ? new import_mongodb113.ObjectId(route._id) : route._id;
|
|
41515
41828
|
}
|
|
41516
41829
|
if (route?.startTime) {
|
|
41517
41830
|
query["route.startTime"] = route.startTime;
|
|
@@ -42370,7 +42683,7 @@ function useNewDashboardController() {
|
|
|
42370
42683
|
|
|
42371
42684
|
// src/models/manpower-monitoring.model.ts
|
|
42372
42685
|
var import_joi111 = __toESM(require("joi"));
|
|
42373
|
-
var
|
|
42686
|
+
var import_mongodb114 = require("mongodb");
|
|
42374
42687
|
var shiftSchema = import_joi111.default.object({
|
|
42375
42688
|
name: import_joi111.default.string().required(),
|
|
42376
42689
|
checkIn: import_joi111.default.string().optional().allow("", null),
|
|
@@ -42395,7 +42708,7 @@ var manpowerMonitoringSchema = import_joi111.default.object({
|
|
|
42395
42708
|
});
|
|
42396
42709
|
var MManpowerMonitoring = class {
|
|
42397
42710
|
constructor(data) {
|
|
42398
|
-
this._id = new
|
|
42711
|
+
this._id = new import_mongodb114.ObjectId();
|
|
42399
42712
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42400
42713
|
this.siteId = data.siteId || "";
|
|
42401
42714
|
this.siteName = data.siteName;
|
|
@@ -42861,7 +43174,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
42861
43174
|
};
|
|
42862
43175
|
|
|
42863
43176
|
// src/repositories/manpower-monitoring.repo.ts
|
|
42864
|
-
var
|
|
43177
|
+
var import_mongodb115 = require("mongodb");
|
|
42865
43178
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
42866
43179
|
function useManpowerMonitoringRepo() {
|
|
42867
43180
|
const db = import_node_server_utils196.useAtlas.getDb();
|
|
@@ -42875,11 +43188,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42875
43188
|
try {
|
|
42876
43189
|
value = new MManpowerMonitoring(value);
|
|
42877
43190
|
if (value.createdBy)
|
|
42878
|
-
value.createdBy = new
|
|
43191
|
+
value.createdBy = new import_mongodb115.ObjectId(value.createdBy);
|
|
42879
43192
|
if (value.siteId)
|
|
42880
|
-
value.siteId = new
|
|
43193
|
+
value.siteId = new import_mongodb115.ObjectId(value.siteId);
|
|
42881
43194
|
if (value.serviceProviderId)
|
|
42882
|
-
value.serviceProviderId = new
|
|
43195
|
+
value.serviceProviderId = new import_mongodb115.ObjectId(value.serviceProviderId);
|
|
42883
43196
|
const result = await collection.insertOne(value, { session });
|
|
42884
43197
|
return result;
|
|
42885
43198
|
} catch (error) {
|
|
@@ -42920,8 +43233,8 @@ function useManpowerMonitoringRepo() {
|
|
|
42920
43233
|
}
|
|
42921
43234
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
42922
43235
|
try {
|
|
42923
|
-
_id = new
|
|
42924
|
-
serviceProviderId = new
|
|
43236
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
43237
|
+
serviceProviderId = new import_mongodb115.ObjectId(serviceProviderId);
|
|
42925
43238
|
} catch (error) {
|
|
42926
43239
|
throw new Error("Invalid Site ID format.");
|
|
42927
43240
|
}
|
|
@@ -42937,7 +43250,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42937
43250
|
}
|
|
42938
43251
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
42939
43252
|
try {
|
|
42940
|
-
_id = new
|
|
43253
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
42941
43254
|
} catch (error) {
|
|
42942
43255
|
throw new import_node_server_utils196.BadRequestError("Invalid ID format.");
|
|
42943
43256
|
}
|
|
@@ -42964,7 +43277,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42964
43277
|
for (let item of value) {
|
|
42965
43278
|
item = new MManpowerMonitoring(item);
|
|
42966
43279
|
const data = await collection.findOne({
|
|
42967
|
-
siteId: new
|
|
43280
|
+
siteId: new import_mongodb115.ObjectId(item.siteId)
|
|
42968
43281
|
});
|
|
42969
43282
|
if (data) {
|
|
42970
43283
|
let updateValue;
|
|
@@ -42989,11 +43302,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42989
43302
|
}
|
|
42990
43303
|
} else {
|
|
42991
43304
|
if (item.createdBy)
|
|
42992
|
-
item.createdBy = new
|
|
43305
|
+
item.createdBy = new import_mongodb115.ObjectId(item.createdBy);
|
|
42993
43306
|
if (item.siteId)
|
|
42994
|
-
item.siteId = new
|
|
43307
|
+
item.siteId = new import_mongodb115.ObjectId(item.siteId);
|
|
42995
43308
|
if (item.serviceProviderId)
|
|
42996
|
-
item.serviceProviderId = new
|
|
43309
|
+
item.serviceProviderId = new import_mongodb115.ObjectId(item.serviceProviderId);
|
|
42997
43310
|
const result = await collection.insertOne(item);
|
|
42998
43311
|
if (result.insertedId) {
|
|
42999
43312
|
results.inserted++;
|
|
@@ -43017,7 +43330,7 @@ function useManpowerMonitoringRepo() {
|
|
|
43017
43330
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
43018
43331
|
try {
|
|
43019
43332
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
43020
|
-
_id: new
|
|
43333
|
+
_id: new import_mongodb115.ObjectId(serviceProviderId)
|
|
43021
43334
|
});
|
|
43022
43335
|
if (!serviceProvider) {
|
|
43023
43336
|
throw new Error("Service Provider not found.");
|
|
@@ -43059,7 +43372,7 @@ var import_node_server_utils197 = require("@7365admin1/node-server-utils");
|
|
|
43059
43372
|
|
|
43060
43373
|
// src/models/manpower-remarks.model.ts
|
|
43061
43374
|
var import_joi112 = __toESM(require("joi"));
|
|
43062
|
-
var
|
|
43375
|
+
var import_mongodb116 = require("mongodb");
|
|
43063
43376
|
var remarksSchema = import_joi112.default.object({
|
|
43064
43377
|
name: import_joi112.default.string().required(),
|
|
43065
43378
|
remark: import_joi112.default.object({
|
|
@@ -43083,7 +43396,7 @@ var manpowerRemarksSchema = import_joi112.default.object({
|
|
|
43083
43396
|
});
|
|
43084
43397
|
var MManpowerRemarks = class {
|
|
43085
43398
|
constructor(data) {
|
|
43086
|
-
this._id = new
|
|
43399
|
+
this._id = new import_mongodb116.ObjectId();
|
|
43087
43400
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
43088
43401
|
this.siteId = data.siteId || "";
|
|
43089
43402
|
this.siteName = data.siteName || "";
|
|
@@ -43101,7 +43414,7 @@ var MManpowerRemarks = class {
|
|
|
43101
43414
|
};
|
|
43102
43415
|
|
|
43103
43416
|
// src/repositories/manpower-remarks.repo.ts
|
|
43104
|
-
var
|
|
43417
|
+
var import_mongodb117 = require("mongodb");
|
|
43105
43418
|
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
43106
43419
|
function useManpowerRemarksRepo() {
|
|
43107
43420
|
const db = import_node_server_utils197.useAtlas.getDb();
|
|
@@ -43114,9 +43427,9 @@ function useManpowerRemarksRepo() {
|
|
|
43114
43427
|
try {
|
|
43115
43428
|
value = new MManpowerRemarks(value);
|
|
43116
43429
|
if (value.siteId)
|
|
43117
|
-
value.siteId = new
|
|
43430
|
+
value.siteId = new import_mongodb117.ObjectId(value.siteId);
|
|
43118
43431
|
if (value.serviceProviderId)
|
|
43119
|
-
value.serviceProviderId = new
|
|
43432
|
+
value.serviceProviderId = new import_mongodb117.ObjectId(value.serviceProviderId);
|
|
43120
43433
|
const result = await collection.insertOne(value, { session });
|
|
43121
43434
|
return result;
|
|
43122
43435
|
} catch (error) {
|
|
@@ -43136,7 +43449,7 @@ function useManpowerRemarksRepo() {
|
|
|
43136
43449
|
limit = limit || 10;
|
|
43137
43450
|
const searchQuery = {};
|
|
43138
43451
|
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
43139
|
-
searchQuery.serviceProviderId = new
|
|
43452
|
+
searchQuery.serviceProviderId = new import_mongodb117.ObjectId(serviceProviderId);
|
|
43140
43453
|
if (search != "") {
|
|
43141
43454
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
43142
43455
|
}
|
|
@@ -43168,8 +43481,8 @@ function useManpowerRemarksRepo() {
|
|
|
43168
43481
|
}
|
|
43169
43482
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
43170
43483
|
try {
|
|
43171
|
-
_id = new
|
|
43172
|
-
serviceProviderId = new
|
|
43484
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43485
|
+
serviceProviderId = new import_mongodb117.ObjectId(serviceProviderId);
|
|
43173
43486
|
} catch (error) {
|
|
43174
43487
|
throw new Error("Invalid Site ID format.");
|
|
43175
43488
|
}
|
|
@@ -43186,13 +43499,13 @@ function useManpowerRemarksRepo() {
|
|
|
43186
43499
|
}
|
|
43187
43500
|
async function updateManpowerRemarks(_id, value) {
|
|
43188
43501
|
try {
|
|
43189
|
-
_id = new
|
|
43502
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43190
43503
|
} catch (error) {
|
|
43191
43504
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
43192
43505
|
}
|
|
43193
43506
|
try {
|
|
43194
43507
|
if (value.createdBy) {
|
|
43195
|
-
value.createdBy = new
|
|
43508
|
+
value.createdBy = new import_mongodb117.ObjectId(value.createdBy);
|
|
43196
43509
|
}
|
|
43197
43510
|
const updateValue = {
|
|
43198
43511
|
...value,
|
|
@@ -43209,7 +43522,7 @@ function useManpowerRemarksRepo() {
|
|
|
43209
43522
|
}
|
|
43210
43523
|
async function updateRemarksStatus(_id, value) {
|
|
43211
43524
|
try {
|
|
43212
|
-
_id = new
|
|
43525
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43213
43526
|
} catch (error) {
|
|
43214
43527
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
43215
43528
|
}
|
|
@@ -43481,7 +43794,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
43481
43794
|
|
|
43482
43795
|
// src/models/manpower-designations.model.ts
|
|
43483
43796
|
var import_joi114 = __toESM(require("joi"));
|
|
43484
|
-
var
|
|
43797
|
+
var import_mongodb118 = require("mongodb");
|
|
43485
43798
|
var designationsSchema = import_joi114.default.object({
|
|
43486
43799
|
title: import_joi114.default.string().required(),
|
|
43487
43800
|
shifts: import_joi114.default.object({
|
|
@@ -43500,7 +43813,7 @@ var manpowerDesignationsSchema = import_joi114.default.object({
|
|
|
43500
43813
|
});
|
|
43501
43814
|
var MManpowerDesignations = class {
|
|
43502
43815
|
constructor(data) {
|
|
43503
|
-
this._id = new
|
|
43816
|
+
this._id = new import_mongodb118.ObjectId();
|
|
43504
43817
|
this.siteId = data.siteId || "";
|
|
43505
43818
|
this.siteName = data.siteName || "";
|
|
43506
43819
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -43514,7 +43827,7 @@ var MManpowerDesignations = class {
|
|
|
43514
43827
|
|
|
43515
43828
|
// src/repositories/manpower-designations.repo.ts
|
|
43516
43829
|
var import_node_server_utils200 = require("@7365admin1/node-server-utils");
|
|
43517
|
-
var
|
|
43830
|
+
var import_mongodb119 = require("mongodb");
|
|
43518
43831
|
function useManpowerDesignationRepo() {
|
|
43519
43832
|
const db = import_node_server_utils200.useAtlas.getDb();
|
|
43520
43833
|
if (!db) {
|
|
@@ -43526,11 +43839,11 @@ function useManpowerDesignationRepo() {
|
|
|
43526
43839
|
try {
|
|
43527
43840
|
value = new MManpowerDesignations(value);
|
|
43528
43841
|
if (value.createdBy)
|
|
43529
|
-
value.createdBy = new
|
|
43842
|
+
value.createdBy = new import_mongodb119.ObjectId(value.createdBy);
|
|
43530
43843
|
if (value.siteId)
|
|
43531
|
-
value.siteId = new
|
|
43844
|
+
value.siteId = new import_mongodb119.ObjectId(value.siteId);
|
|
43532
43845
|
if (value.serviceProviderId)
|
|
43533
|
-
value.serviceProviderId = new
|
|
43846
|
+
value.serviceProviderId = new import_mongodb119.ObjectId(value.serviceProviderId);
|
|
43534
43847
|
const result = await collection.insertOne(value);
|
|
43535
43848
|
return result;
|
|
43536
43849
|
} catch (error) {
|
|
@@ -43539,8 +43852,8 @@ function useManpowerDesignationRepo() {
|
|
|
43539
43852
|
}
|
|
43540
43853
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
43541
43854
|
try {
|
|
43542
|
-
_id = new
|
|
43543
|
-
serviceProviderId = new
|
|
43855
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
43856
|
+
serviceProviderId = new import_mongodb119.ObjectId(serviceProviderId);
|
|
43544
43857
|
} catch (error) {
|
|
43545
43858
|
throw new Error("Invalid Site ID format.");
|
|
43546
43859
|
}
|
|
@@ -43556,7 +43869,7 @@ function useManpowerDesignationRepo() {
|
|
|
43556
43869
|
}
|
|
43557
43870
|
async function updateManpowerDesignations(_id, value) {
|
|
43558
43871
|
try {
|
|
43559
|
-
_id = new
|
|
43872
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
43560
43873
|
} catch (error) {
|
|
43561
43874
|
throw new Error("Invalid ID format.");
|
|
43562
43875
|
}
|
|
@@ -43659,7 +43972,7 @@ function useManpowerDesignationCtrl() {
|
|
|
43659
43972
|
|
|
43660
43973
|
// src/models/overnight-parking.model.ts
|
|
43661
43974
|
var import_joi116 = __toESM(require("joi"));
|
|
43662
|
-
var
|
|
43975
|
+
var import_mongodb120 = require("mongodb");
|
|
43663
43976
|
var dayScheduleSchema = import_joi116.default.object({
|
|
43664
43977
|
isEnabled: import_joi116.default.boolean().required(),
|
|
43665
43978
|
startTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -43701,7 +44014,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
43701
44014
|
}
|
|
43702
44015
|
if (value.site && typeof value.site === "string") {
|
|
43703
44016
|
try {
|
|
43704
|
-
value.site = new
|
|
44017
|
+
value.site = new import_mongodb120.ObjectId(value.site);
|
|
43705
44018
|
} catch {
|
|
43706
44019
|
throw new Error("Invalid site ID.");
|
|
43707
44020
|
}
|
|
@@ -45306,7 +45619,7 @@ function useManpowerRemarkCtrl() {
|
|
|
45306
45619
|
|
|
45307
45620
|
// src/models/manpower-sites.model.ts
|
|
45308
45621
|
var import_joi122 = __toESM(require("joi"));
|
|
45309
|
-
var
|
|
45622
|
+
var import_mongodb121 = require("mongodb");
|
|
45310
45623
|
var manpowerSitesSchema = import_joi122.default.object({
|
|
45311
45624
|
id: import_joi122.default.string().hex().required(),
|
|
45312
45625
|
text: import_joi122.default.string().hex().optional().allow("", null),
|
|
@@ -45317,7 +45630,7 @@ var manpowerSitesSchema = import_joi122.default.object({
|
|
|
45317
45630
|
});
|
|
45318
45631
|
var MManpowerSites = class {
|
|
45319
45632
|
constructor(data) {
|
|
45320
|
-
this._id = new
|
|
45633
|
+
this._id = new import_mongodb121.ObjectId();
|
|
45321
45634
|
this.id = data.id || "";
|
|
45322
45635
|
this.text = data.text || "";
|
|
45323
45636
|
this.contractID = data.contractID || "";
|
|
@@ -45527,7 +45840,7 @@ function useManpowerSitesCtrl() {
|
|
|
45527
45840
|
|
|
45528
45841
|
// src/utils/cron.util.ts
|
|
45529
45842
|
var import_node_server_utils214 = require("@7365admin1/node-server-utils");
|
|
45530
|
-
var
|
|
45843
|
+
var import_mongodb122 = require("mongodb");
|
|
45531
45844
|
var import_moment_timezone4 = __toESM(require("moment-timezone"));
|
|
45532
45845
|
var createManpowerRemarksDaily = async () => {
|
|
45533
45846
|
const db = import_node_server_utils214.useAtlas.getDb();
|
|
@@ -45687,7 +46000,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
45687
46000
|
for (const id of updatedIds) {
|
|
45688
46001
|
const doc = await remarks.findOne({ _id: id });
|
|
45689
46002
|
const setting = await settings.findOne(
|
|
45690
|
-
{ siteId: new
|
|
46003
|
+
{ siteId: new import_mongodb122.ObjectId(doc?.siteId) },
|
|
45691
46004
|
{ projection: { emails: 1 } }
|
|
45692
46005
|
);
|
|
45693
46006
|
const payload = {
|
|
@@ -45773,7 +46086,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
45773
46086
|
for (const doc of docs) {
|
|
45774
46087
|
let shiftsToCheck = [];
|
|
45775
46088
|
const endShiftTime = await settings.findOne(
|
|
45776
|
-
{ siteId: new
|
|
46089
|
+
{ siteId: new import_mongodb122.ObjectId(doc.siteId) },
|
|
45777
46090
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45778
46091
|
);
|
|
45779
46092
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -45879,7 +46192,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
45879
46192
|
|
|
45880
46193
|
// src/events/manpower.event.ts
|
|
45881
46194
|
var import_node_server_utils215 = require("@7365admin1/node-server-utils");
|
|
45882
|
-
var
|
|
46195
|
+
var import_mongodb123 = require("mongodb");
|
|
45883
46196
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
45884
46197
|
async function manpowerEvents(io) {
|
|
45885
46198
|
let intervalId = null;
|
|
@@ -45905,7 +46218,7 @@ async function manpowerEvents(io) {
|
|
|
45905
46218
|
}).toArray();
|
|
45906
46219
|
for (const doc of docs) {
|
|
45907
46220
|
const siteSettings = await settings.findOne(
|
|
45908
|
-
{ siteId: new
|
|
46221
|
+
{ siteId: new import_mongodb123.ObjectId(doc.siteId), enabled: true },
|
|
45909
46222
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45910
46223
|
);
|
|
45911
46224
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -46024,7 +46337,7 @@ function genericSignature(params, secretKey) {
|
|
|
46024
46337
|
}
|
|
46025
46338
|
|
|
46026
46339
|
// src/repositories/reddot-payment.repository.ts
|
|
46027
|
-
var
|
|
46340
|
+
var import_mongodb127 = require("mongodb");
|
|
46028
46341
|
|
|
46029
46342
|
// src/utils/date-format.util.ts
|
|
46030
46343
|
var import_moment_timezone6 = __toESM(require("moment-timezone"));
|
|
@@ -46049,11 +46362,11 @@ function formatDateString(today, format, dateRange) {
|
|
|
46049
46362
|
}
|
|
46050
46363
|
|
|
46051
46364
|
// src/models/credit-card.model.ts
|
|
46052
|
-
var
|
|
46365
|
+
var import_mongodb124 = require("mongodb");
|
|
46053
46366
|
var MCardInfo = class {
|
|
46054
46367
|
// this is coming from RDP transaction
|
|
46055
46368
|
constructor({
|
|
46056
|
-
_id = new
|
|
46369
|
+
_id = new import_mongodb124.ObjectId(),
|
|
46057
46370
|
userId,
|
|
46058
46371
|
cardType,
|
|
46059
46372
|
cardNumber,
|
|
@@ -46088,11 +46401,11 @@ var MCardInfo = class {
|
|
|
46088
46401
|
};
|
|
46089
46402
|
|
|
46090
46403
|
// src/models/cart.model.ts
|
|
46091
|
-
var
|
|
46404
|
+
var import_mongodb125 = require("mongodb");
|
|
46092
46405
|
var MUnitBillings = class {
|
|
46093
46406
|
// transaction response messages
|
|
46094
46407
|
constructor({
|
|
46095
|
-
_id = new
|
|
46408
|
+
_id = new import_mongodb125.ObjectId(),
|
|
46096
46409
|
unit,
|
|
46097
46410
|
unitId,
|
|
46098
46411
|
unitBill,
|
|
@@ -46133,7 +46446,7 @@ var MUnitBillings = class {
|
|
|
46133
46446
|
};
|
|
46134
46447
|
|
|
46135
46448
|
// src/repositories/payment.repository.ts
|
|
46136
|
-
var
|
|
46449
|
+
var import_mongodb126 = require("mongodb");
|
|
46137
46450
|
var import_node_server_utils216 = require("@7365admin1/node-server-utils");
|
|
46138
46451
|
var PaymentBillRepo = () => {
|
|
46139
46452
|
const getDB2 = () => {
|
|
@@ -46167,7 +46480,7 @@ var PaymentBillRepo = () => {
|
|
|
46167
46480
|
if (unitBillInfo?.status === "Inactive" /* inactive */) {
|
|
46168
46481
|
throw new Error("This Bill is Inactive!");
|
|
46169
46482
|
}
|
|
46170
|
-
const billId = new
|
|
46483
|
+
const billId = new import_mongodb126.ObjectId(unitBillInfo?.billId);
|
|
46171
46484
|
const billInfo = await billCollection().findOne({ _id: billId });
|
|
46172
46485
|
if (!billInfo) {
|
|
46173
46486
|
throw new Error("Bill info not found");
|
|
@@ -46206,13 +46519,13 @@ var PaymentBillRepo = () => {
|
|
|
46206
46519
|
const saveCreditCardInfo = async (payload) => {
|
|
46207
46520
|
try {
|
|
46208
46521
|
if (payload.userId)
|
|
46209
|
-
payload.userId = new
|
|
46522
|
+
payload.userId = new import_mongodb126.ObjectId(payload.userId);
|
|
46210
46523
|
if (payload.site)
|
|
46211
|
-
payload.site = new
|
|
46524
|
+
payload.site = new import_mongodb126.ObjectId(payload.site);
|
|
46212
46525
|
if (payload.organization)
|
|
46213
|
-
payload.organization = new
|
|
46526
|
+
payload.organization = new import_mongodb126.ObjectId(payload.organization);
|
|
46214
46527
|
if (payload.createdBy)
|
|
46215
|
-
payload.createdBy = new
|
|
46528
|
+
payload.createdBy = new import_mongodb126.ObjectId(payload.createdBy);
|
|
46216
46529
|
const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46217
46530
|
payload.createdAt = createdAt;
|
|
46218
46531
|
const result = await creditCollection().insertOne(new MCardInfo(payload));
|
|
@@ -46224,19 +46537,19 @@ var PaymentBillRepo = () => {
|
|
|
46224
46537
|
const checkOutUnitBills = async (payload) => {
|
|
46225
46538
|
try {
|
|
46226
46539
|
if (payload.unitId)
|
|
46227
|
-
payload.unitId = new
|
|
46540
|
+
payload.unitId = new import_mongodb126.ObjectId(payload.unitId);
|
|
46228
46541
|
if (payload.site)
|
|
46229
|
-
payload.site = new
|
|
46542
|
+
payload.site = new import_mongodb126.ObjectId(payload.site);
|
|
46230
46543
|
if (payload.organization)
|
|
46231
|
-
payload.organization = new
|
|
46544
|
+
payload.organization = new import_mongodb126.ObjectId(payload.organization);
|
|
46232
46545
|
payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46233
46546
|
const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
|
|
46234
46547
|
const unitId = payload.unitId;
|
|
46235
46548
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
|
|
46236
46549
|
const unit = unitId?.toString().slice(-4);
|
|
46237
|
-
const newId = new
|
|
46550
|
+
const newId = new import_mongodb126.ObjectId(addToCart?.insertedId).toString().slice(-4);
|
|
46238
46551
|
const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
|
|
46239
|
-
const result = await cartCollection().findOneAndUpdate({ _id: new
|
|
46552
|
+
const result = await cartCollection().findOneAndUpdate({ _id: new import_mongodb126.ObjectId(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
|
|
46240
46553
|
return result;
|
|
46241
46554
|
} catch (error) {
|
|
46242
46555
|
throw new Error(error.message || error || "Server Internal Error");
|
|
@@ -46267,7 +46580,7 @@ var PaymentBillRepo = () => {
|
|
|
46267
46580
|
for (const ref of refNumber) {
|
|
46268
46581
|
const unitBillInfo = await collection().findOne({ referenceNumber: ref });
|
|
46269
46582
|
const billId = unitBillInfo?.billId;
|
|
46270
|
-
const billInfo = await billCollection().findOne({ _id: new
|
|
46583
|
+
const billInfo = await billCollection().findOne({ _id: new import_mongodb126.ObjectId(billId) });
|
|
46271
46584
|
const billAmount = billInfo?.price;
|
|
46272
46585
|
payload.updatedAt = updatedAt;
|
|
46273
46586
|
payload.amountPaid = billAmount;
|
|
@@ -46418,7 +46731,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46418
46731
|
throw new Error("Failed to Add Merchant Details");
|
|
46419
46732
|
}
|
|
46420
46733
|
const merchantId = merchant?.insertedId;
|
|
46421
|
-
const orgId = new
|
|
46734
|
+
const orgId = new import_mongodb127.ObjectId(_id);
|
|
46422
46735
|
const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
|
|
46423
46736
|
returnDocument: "after"
|
|
46424
46737
|
});
|
|
@@ -46447,7 +46760,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46447
46760
|
const getMerchantDetailsById = async (_id) => {
|
|
46448
46761
|
try {
|
|
46449
46762
|
if (_id)
|
|
46450
|
-
_id = new
|
|
46763
|
+
_id = new import_mongodb127.ObjectId(_id);
|
|
46451
46764
|
const result = await redDotMerchantCollection().aggregate([
|
|
46452
46765
|
{
|
|
46453
46766
|
$match: {
|
|
@@ -46702,7 +47015,7 @@ function useRedDotPaymentController() {
|
|
|
46702
47015
|
|
|
46703
47016
|
// src/repositories/verification-v2.repo.ts
|
|
46704
47017
|
var import_node_server_utils218 = require("@7365admin1/node-server-utils");
|
|
46705
|
-
var
|
|
47018
|
+
var import_mongodb128 = require("mongodb");
|
|
46706
47019
|
function useVerificationRepoV2() {
|
|
46707
47020
|
const db = import_node_server_utils218.useAtlas.getDb();
|
|
46708
47021
|
if (!db) {
|
|
@@ -46755,7 +47068,7 @@ function useVerificationRepoV2() {
|
|
|
46755
47068
|
}
|
|
46756
47069
|
async function updateVerificationStatusById(_id, status, session) {
|
|
46757
47070
|
try {
|
|
46758
|
-
_id = new
|
|
47071
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
46759
47072
|
} catch (error) {
|
|
46760
47073
|
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46761
47074
|
}
|
|
@@ -46898,7 +47211,7 @@ function useVerificationRepoV2() {
|
|
|
46898
47211
|
}
|
|
46899
47212
|
async function updateStatusById(_id, status, session) {
|
|
46900
47213
|
try {
|
|
46901
|
-
_id = new
|
|
47214
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
46902
47215
|
} catch (error) {
|
|
46903
47216
|
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46904
47217
|
}
|
|
@@ -47484,7 +47797,7 @@ var import_node_server_utils222 = require("@7365admin1/node-server-utils");
|
|
|
47484
47797
|
var import_uuid2 = require("uuid");
|
|
47485
47798
|
|
|
47486
47799
|
// src/repositories/user-v2.repo.ts
|
|
47487
|
-
var
|
|
47800
|
+
var import_mongodb129 = require("mongodb");
|
|
47488
47801
|
var import_node_server_utils221 = require("@7365admin1/node-server-utils");
|
|
47489
47802
|
function useUserRepoV2() {
|
|
47490
47803
|
const { updateFeedbackCreatedByName } = useFeedbackRepo();
|
|
@@ -47685,7 +47998,7 @@ function useUserRepoV2() {
|
|
|
47685
47998
|
}
|
|
47686
47999
|
if (organization) {
|
|
47687
48000
|
try {
|
|
47688
|
-
query.defaultOrg = new
|
|
48001
|
+
query.defaultOrg = new import_mongodb129.ObjectId(organization);
|
|
47689
48002
|
cacheOptions.organization = organization.toString();
|
|
47690
48003
|
} catch (error) {
|
|
47691
48004
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID format.");
|
|
@@ -47824,13 +48137,13 @@ function useUserRepoV2() {
|
|
|
47824
48137
|
);
|
|
47825
48138
|
}
|
|
47826
48139
|
try {
|
|
47827
|
-
_id = new
|
|
48140
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47828
48141
|
} catch (error) {
|
|
47829
48142
|
throw new import_node_server_utils221.BadRequestError("Invalid ID.");
|
|
47830
48143
|
}
|
|
47831
48144
|
if (field === "defaultOrg") {
|
|
47832
48145
|
try {
|
|
47833
|
-
value = new
|
|
48146
|
+
value = new import_mongodb129.ObjectId(value);
|
|
47834
48147
|
} catch (error) {
|
|
47835
48148
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID.");
|
|
47836
48149
|
}
|
|
@@ -47871,7 +48184,7 @@ function useUserRepoV2() {
|
|
|
47871
48184
|
year
|
|
47872
48185
|
}, session) {
|
|
47873
48186
|
try {
|
|
47874
|
-
_id = new
|
|
48187
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47875
48188
|
} catch (error) {
|
|
47876
48189
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47877
48190
|
}
|
|
@@ -47901,7 +48214,7 @@ function useUserRepoV2() {
|
|
|
47901
48214
|
}
|
|
47902
48215
|
async function updatePassword({ _id, password }, session) {
|
|
47903
48216
|
try {
|
|
47904
|
-
_id = new
|
|
48217
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47905
48218
|
} catch (error) {
|
|
47906
48219
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47907
48220
|
}
|
|
@@ -48748,6 +49061,7 @@ function useUserControllerV2() {
|
|
|
48748
49061
|
remarksSchema,
|
|
48749
49062
|
robotSchema,
|
|
48750
49063
|
schema,
|
|
49064
|
+
schemaApprovedBy,
|
|
48751
49065
|
schemaBilling,
|
|
48752
49066
|
schemaBillingConfiguration,
|
|
48753
49067
|
schemaBillingItem,
|