@7365admin1/core 2.30.2 → 2.31.1
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 +40 -1
- package/dist/index.js +410 -250
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +410 -250
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -13112,7 +13112,7 @@ var schemaVisitorTransaction = Joi36.object({
|
|
|
13112
13112
|
arrivalTime: Joi36.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
13113
13113
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
13114
13114
|
}),
|
|
13115
|
-
duration: Joi36.number().integer().optional().allow(null),
|
|
13115
|
+
duration: Joi36.number().integer().optional().allow(null, ""),
|
|
13116
13116
|
isOvernightParking: Joi36.boolean().optional().default(false),
|
|
13117
13117
|
email: Joi36.string().email().optional().allow(null, ""),
|
|
13118
13118
|
numberOfPassengers: Joi36.number().integer().optional().allow(null, ""),
|
|
@@ -13129,7 +13129,8 @@ var schemaVisitorTransaction = Joi36.object({
|
|
|
13129
13129
|
checkInRemarks: Joi36.string().optional().allow("", null),
|
|
13130
13130
|
checkOutRemarks: Joi36.string().optional().allow("", null),
|
|
13131
13131
|
expectedCheckIn: Joi36.string().isoDate().optional(),
|
|
13132
|
-
purpose: Joi36.string().optional().allow(null, "")
|
|
13132
|
+
purpose: Joi36.string().optional().allow(null, ""),
|
|
13133
|
+
invitedId: Joi36.any().optional().allow(null, "")
|
|
13133
13134
|
});
|
|
13134
13135
|
var schemaUpdateVisTrans = Joi36.object({
|
|
13135
13136
|
_id: Joi36.string().hex().length(24).required(),
|
|
@@ -13158,12 +13159,16 @@ var schemaUpdateVisTrans = Joi36.object({
|
|
|
13158
13159
|
expiredAt: Joi36.date().iso().optional().allow(null, ""),
|
|
13159
13160
|
visitorPass: Joi36.array().items(
|
|
13160
13161
|
Joi36.object({
|
|
13161
|
-
keyId: Joi36.string().hex().length(24).required()
|
|
13162
|
+
keyId: Joi36.string().hex().length(24).required(),
|
|
13163
|
+
status: Joi36.string().optional().allow(null, ""),
|
|
13164
|
+
remarks: Joi36.string().optional().allow(null, "")
|
|
13162
13165
|
})
|
|
13163
13166
|
).optional().allow(null),
|
|
13164
13167
|
passKeys: Joi36.array().items(
|
|
13165
13168
|
Joi36.object({
|
|
13166
|
-
keyId: Joi36.string().hex().length(24).required()
|
|
13169
|
+
keyId: Joi36.string().hex().length(24).required(),
|
|
13170
|
+
status: Joi36.string().optional().allow(null, ""),
|
|
13171
|
+
remarks: Joi36.string().optional().allow(null, "")
|
|
13167
13172
|
})
|
|
13168
13173
|
).optional().allow(null),
|
|
13169
13174
|
checkInRemarks: Joi36.string().optional().allow("", null),
|
|
@@ -13269,7 +13274,17 @@ function MVisitorTransaction(value) {
|
|
|
13269
13274
|
expiredAt: value.expiredAt ?? null,
|
|
13270
13275
|
createdAt: value.createdAt ?? newDate,
|
|
13271
13276
|
updatedAt: value.updatedAt ?? "",
|
|
13272
|
-
deletedAt: value.deletedAt ?? ""
|
|
13277
|
+
deletedAt: value.deletedAt ?? "",
|
|
13278
|
+
purpose: value.purpose,
|
|
13279
|
+
numberOfPassengers: value.numberOfPassengers ?? null,
|
|
13280
|
+
email: value.email,
|
|
13281
|
+
isOvernightParking: value.isOvernightParking ?? false,
|
|
13282
|
+
invitedId: new ObjectId39(String(value.invitedId)) ?? null,
|
|
13283
|
+
overnightParking: value.isOvernightParking == true ? {
|
|
13284
|
+
status: "pending approval",
|
|
13285
|
+
remarks: "",
|
|
13286
|
+
updatedBy: new ObjectId39(String(value.invitedId)) ?? null
|
|
13287
|
+
} : null
|
|
13273
13288
|
};
|
|
13274
13289
|
}
|
|
13275
13290
|
|
|
@@ -13401,16 +13416,40 @@ function useVisitorTransactionRepo() {
|
|
|
13401
13416
|
localField: "visitorPass.keyId",
|
|
13402
13417
|
foreignField: "_id",
|
|
13403
13418
|
pipeline: [
|
|
13419
|
+
{
|
|
13420
|
+
$lookup: {
|
|
13421
|
+
from: "qr-code-templates",
|
|
13422
|
+
localField: "template",
|
|
13423
|
+
foreignField: "_id",
|
|
13424
|
+
pipeline: [
|
|
13425
|
+
{
|
|
13426
|
+
$project: {
|
|
13427
|
+
_id: 1,
|
|
13428
|
+
prefixPass: 1,
|
|
13429
|
+
name: 1
|
|
13430
|
+
}
|
|
13431
|
+
}
|
|
13432
|
+
],
|
|
13433
|
+
as: "template"
|
|
13434
|
+
}
|
|
13435
|
+
},
|
|
13404
13436
|
{
|
|
13405
13437
|
$project: {
|
|
13406
13438
|
_id: 0,
|
|
13407
|
-
// remove original _id
|
|
13408
13439
|
keyId: "$_id",
|
|
13409
13440
|
status: 1,
|
|
13410
13441
|
description: 1,
|
|
13442
|
+
templatePrefixPass: {
|
|
13443
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13444
|
+
},
|
|
13411
13445
|
prefixAndName: {
|
|
13412
13446
|
$concat: [
|
|
13413
|
-
{
|
|
13447
|
+
{
|
|
13448
|
+
$ifNull: [
|
|
13449
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13450
|
+
""
|
|
13451
|
+
]
|
|
13452
|
+
},
|
|
13414
13453
|
{ $ifNull: ["$name", ""] }
|
|
13415
13454
|
]
|
|
13416
13455
|
}
|
|
@@ -13423,145 +13462,50 @@ function useVisitorTransactionRepo() {
|
|
|
13423
13462
|
{
|
|
13424
13463
|
$lookup: {
|
|
13425
13464
|
from: "keys",
|
|
13426
|
-
localField: "
|
|
13465
|
+
localField: "passKeys.keyId",
|
|
13427
13466
|
foreignField: "_id",
|
|
13428
13467
|
pipeline: [
|
|
13429
13468
|
{
|
|
13430
|
-
$
|
|
13431
|
-
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
|
|
13435
|
-
|
|
13436
|
-
|
|
13437
|
-
|
|
13438
|
-
|
|
13439
|
-
|
|
13440
|
-
as: "visitorPassDetails"
|
|
13441
|
-
}
|
|
13442
|
-
},
|
|
13443
|
-
{
|
|
13444
|
-
$addFields: {
|
|
13445
|
-
visitorPass: {
|
|
13446
|
-
$map: {
|
|
13447
|
-
input: "$visitorPass",
|
|
13448
|
-
as: "vp",
|
|
13449
|
-
in: {
|
|
13450
|
-
$let: {
|
|
13451
|
-
vars: {
|
|
13452
|
-
matchedKey: {
|
|
13453
|
-
$arrayElemAt: [
|
|
13454
|
-
{
|
|
13455
|
-
$filter: {
|
|
13456
|
-
input: "$visitorPassDetails",
|
|
13457
|
-
as: "kd",
|
|
13458
|
-
cond: { $eq: ["$$kd._id", "$$vp.keyId"] }
|
|
13459
|
-
}
|
|
13460
|
-
},
|
|
13461
|
-
0
|
|
13462
|
-
]
|
|
13463
|
-
}
|
|
13464
|
-
},
|
|
13465
|
-
in: {
|
|
13466
|
-
keyId: "$$vp.keyId",
|
|
13467
|
-
receivedDate: "$$vp.receivedDate",
|
|
13468
|
-
status: "$$vp.status",
|
|
13469
|
-
lastUpdate: {
|
|
13470
|
-
$max: [
|
|
13471
|
-
"$$matchedKey.createdAt",
|
|
13472
|
-
"$$matchedKey.updatedAt"
|
|
13473
|
-
]
|
|
13474
|
-
},
|
|
13475
|
-
remarks: "$$vp.remarks",
|
|
13476
|
-
description: "$$matchedKey.description",
|
|
13477
|
-
prefixAndName: {
|
|
13478
|
-
$concat: [
|
|
13479
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13480
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13481
|
-
]
|
|
13469
|
+
$lookup: {
|
|
13470
|
+
from: "qr-code-templates",
|
|
13471
|
+
localField: "template",
|
|
13472
|
+
foreignField: "_id",
|
|
13473
|
+
pipeline: [
|
|
13474
|
+
{
|
|
13475
|
+
$project: {
|
|
13476
|
+
_id: 1,
|
|
13477
|
+
prefixPass: 1,
|
|
13478
|
+
name: 1
|
|
13482
13479
|
}
|
|
13483
13480
|
}
|
|
13484
|
-
|
|
13481
|
+
],
|
|
13482
|
+
as: "template"
|
|
13485
13483
|
}
|
|
13486
|
-
}
|
|
13487
|
-
}
|
|
13488
|
-
}
|
|
13489
|
-
},
|
|
13490
|
-
{
|
|
13491
|
-
$project: {
|
|
13492
|
-
visitorPassDetails: 0
|
|
13493
|
-
}
|
|
13494
|
-
},
|
|
13495
|
-
{
|
|
13496
|
-
$lookup: {
|
|
13497
|
-
from: "keys",
|
|
13498
|
-
localField: "passKeys.keyId",
|
|
13499
|
-
foreignField: "_id",
|
|
13500
|
-
pipeline: [
|
|
13484
|
+
},
|
|
13501
13485
|
{
|
|
13502
13486
|
$project: {
|
|
13503
|
-
_id:
|
|
13504
|
-
|
|
13505
|
-
|
|
13487
|
+
_id: 0,
|
|
13488
|
+
keyId: "$_id",
|
|
13489
|
+
status: 1,
|
|
13506
13490
|
description: 1,
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
$addFields: {
|
|
13517
|
-
passKeys: {
|
|
13518
|
-
$map: {
|
|
13519
|
-
input: "$passKeys",
|
|
13520
|
-
as: "pk",
|
|
13521
|
-
in: {
|
|
13522
|
-
$let: {
|
|
13523
|
-
vars: {
|
|
13524
|
-
matchedKey: {
|
|
13525
|
-
$arrayElemAt: [
|
|
13526
|
-
{
|
|
13527
|
-
$filter: {
|
|
13528
|
-
input: "$passKeysDetails",
|
|
13529
|
-
as: "kd",
|
|
13530
|
-
cond: { $eq: ["$$kd._id", "$$pk.keyId"] }
|
|
13531
|
-
}
|
|
13532
|
-
},
|
|
13533
|
-
0
|
|
13534
|
-
]
|
|
13535
|
-
}
|
|
13536
|
-
},
|
|
13537
|
-
in: {
|
|
13538
|
-
keyId: "$$pk.keyId",
|
|
13539
|
-
receivedDate: "$$pk.receivedDate",
|
|
13540
|
-
status: "$$pk.status",
|
|
13541
|
-
lastUpdate: {
|
|
13542
|
-
$max: [
|
|
13543
|
-
"$$matchedKey.createdAt",
|
|
13544
|
-
"$$matchedKey.updatedAt"
|
|
13491
|
+
templatePrefixPass: {
|
|
13492
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13493
|
+
},
|
|
13494
|
+
prefixAndName: {
|
|
13495
|
+
$concat: [
|
|
13496
|
+
{
|
|
13497
|
+
$ifNull: [
|
|
13498
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13499
|
+
""
|
|
13545
13500
|
]
|
|
13546
13501
|
},
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
prefixAndName: {
|
|
13550
|
-
$concat: [
|
|
13551
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13552
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13553
|
-
]
|
|
13554
|
-
}
|
|
13555
|
-
}
|
|
13502
|
+
{ $ifNull: ["$name", ""] }
|
|
13503
|
+
]
|
|
13556
13504
|
}
|
|
13557
13505
|
}
|
|
13558
13506
|
}
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
},
|
|
13562
|
-
{
|
|
13563
|
-
$project: {
|
|
13564
|
-
passKeysDetails: 0
|
|
13507
|
+
],
|
|
13508
|
+
as: "passKeys"
|
|
13565
13509
|
}
|
|
13566
13510
|
},
|
|
13567
13511
|
{ $sort: sort },
|
|
@@ -21598,8 +21542,8 @@ var KeyRepo = class {
|
|
|
21598
21542
|
static async updateKeyById(keyId, key, site, session, isChild) {
|
|
21599
21543
|
try {
|
|
21600
21544
|
keyId = new ObjectId57(keyId);
|
|
21601
|
-
|
|
21602
|
-
|
|
21545
|
+
if (site)
|
|
21546
|
+
site = new ObjectId57(site);
|
|
21603
21547
|
if (key.updatedBy)
|
|
21604
21548
|
key.updatedBy = await convertObjectIdUtil(key.updatedBy);
|
|
21605
21549
|
if (!key.status)
|
|
@@ -21609,7 +21553,8 @@ var KeyRepo = class {
|
|
|
21609
21553
|
}
|
|
21610
21554
|
try {
|
|
21611
21555
|
key.updatedAt = /* @__PURE__ */ new Date();
|
|
21612
|
-
|
|
21556
|
+
const query = { _id: keyId, ...site && { site } };
|
|
21557
|
+
let find = query;
|
|
21613
21558
|
if (isChild)
|
|
21614
21559
|
find = { parentId: keyId, site };
|
|
21615
21560
|
const result = await this.collection().updateMany(
|
|
@@ -21669,6 +21614,7 @@ function useVisitorTransactionService() {
|
|
|
21669
21614
|
getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
|
|
21670
21615
|
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
|
|
21671
21616
|
} = useVisitorTransactionRepo();
|
|
21617
|
+
const { getById } = useBuildingUnitRepo();
|
|
21672
21618
|
const {
|
|
21673
21619
|
add: _addPerson,
|
|
21674
21620
|
getByNRIC,
|
|
@@ -21761,7 +21707,7 @@ function useVisitorTransactionService() {
|
|
|
21761
21707
|
if (member.visitorPass && Array.isArray(member.visitorPass) && member.visitorPass.length > 0) {
|
|
21762
21708
|
for (const vp of member.visitorPass) {
|
|
21763
21709
|
try {
|
|
21764
|
-
const updatePayload = { status: "
|
|
21710
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21765
21711
|
const visitorPassId = typeof vp === "string" || vp instanceof ObjectId58 ? vp : vp.keyId;
|
|
21766
21712
|
await KeyRepo.updateKeyById(
|
|
21767
21713
|
visitorPassId,
|
|
@@ -21776,7 +21722,7 @@ function useVisitorTransactionService() {
|
|
|
21776
21722
|
if (member.passKeys && Array.isArray(member.passKeys) && member.passKeys.length > 0) {
|
|
21777
21723
|
for (const pk of member.passKeys) {
|
|
21778
21724
|
try {
|
|
21779
|
-
const updatePayload = { status: "
|
|
21725
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21780
21726
|
const passKeyId = typeof pk === "string" || pk instanceof ObjectId58 ? pk : pk.keyId;
|
|
21781
21727
|
await KeyRepo.updateKeyById(
|
|
21782
21728
|
passKeyId,
|
|
@@ -21892,7 +21838,7 @@ function useVisitorTransactionService() {
|
|
|
21892
21838
|
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
21893
21839
|
for (const vp of value.visitorPass) {
|
|
21894
21840
|
try {
|
|
21895
|
-
const updatePayload = { status: "
|
|
21841
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21896
21842
|
const visitorPassId = typeof vp === "string" || vp instanceof ObjectId58 ? vp : vp.keyId;
|
|
21897
21843
|
await KeyRepo.updateKeyById(
|
|
21898
21844
|
visitorPassId,
|
|
@@ -21907,7 +21853,7 @@ function useVisitorTransactionService() {
|
|
|
21907
21853
|
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
21908
21854
|
for (const pk of value.passKeys) {
|
|
21909
21855
|
try {
|
|
21910
|
-
const updatePayload = { status: "
|
|
21856
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21911
21857
|
const passKeyId = typeof pk === "string" || pk instanceof ObjectId58 ? pk : pk.keyId;
|
|
21912
21858
|
await KeyRepo.updateKeyById(
|
|
21913
21859
|
passKeyId,
|
|
@@ -21933,6 +21879,52 @@ function useVisitorTransactionService() {
|
|
|
21933
21879
|
const session = useAtlas48.getClient()?.startSession();
|
|
21934
21880
|
session?.startTransaction();
|
|
21935
21881
|
try {
|
|
21882
|
+
if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
21883
|
+
const keptVisitorPass = [];
|
|
21884
|
+
for (const vp of value.visitorPass) {
|
|
21885
|
+
const updatePayload = {
|
|
21886
|
+
...vp.status && { status: vp.status },
|
|
21887
|
+
...vp.remarks && { remarks: vp.remarks }
|
|
21888
|
+
};
|
|
21889
|
+
const visitorPassId = typeof vp === "string" || vp instanceof ObjectId58 ? vp : vp.keyId;
|
|
21890
|
+
await KeyRepo.updateKeyById(
|
|
21891
|
+
visitorPassId,
|
|
21892
|
+
updatePayload,
|
|
21893
|
+
value.site
|
|
21894
|
+
);
|
|
21895
|
+
if (typeof vp !== "string" && !(vp instanceof ObjectId58)) {
|
|
21896
|
+
keptVisitorPass.push({
|
|
21897
|
+
keyId: new ObjectId58(visitorPassId)
|
|
21898
|
+
});
|
|
21899
|
+
}
|
|
21900
|
+
}
|
|
21901
|
+
value.visitorPass = keptVisitorPass;
|
|
21902
|
+
}
|
|
21903
|
+
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
21904
|
+
const keptPassKeys = [];
|
|
21905
|
+
for (const pk of value.passKeys) {
|
|
21906
|
+
try {
|
|
21907
|
+
const updatePayload = {
|
|
21908
|
+
...pk.status && { status: pk.status },
|
|
21909
|
+
...pk.remarks && { remarks: pk.remarks }
|
|
21910
|
+
};
|
|
21911
|
+
const passKeyId = typeof pk === "string" || pk instanceof ObjectId58 ? pk : pk.keyId;
|
|
21912
|
+
await KeyRepo.updateKeyById(
|
|
21913
|
+
passKeyId,
|
|
21914
|
+
updatePayload,
|
|
21915
|
+
value.site
|
|
21916
|
+
);
|
|
21917
|
+
if (typeof pk !== "string" && !(pk instanceof ObjectId58)) {
|
|
21918
|
+
keptPassKeys.push({
|
|
21919
|
+
keyId: new ObjectId58(passKeyId)
|
|
21920
|
+
});
|
|
21921
|
+
}
|
|
21922
|
+
} catch (error) {
|
|
21923
|
+
throw error;
|
|
21924
|
+
}
|
|
21925
|
+
}
|
|
21926
|
+
value.passKeys = keptPassKeys;
|
|
21927
|
+
}
|
|
21936
21928
|
await _updateVisitorTansactionById(id, value, session);
|
|
21937
21929
|
await session?.commitTransaction();
|
|
21938
21930
|
return "Successfully updated visitor transaction.";
|
|
@@ -22021,6 +22013,7 @@ function useVisitorTransactionService() {
|
|
|
22021
22013
|
try {
|
|
22022
22014
|
session.startTransaction();
|
|
22023
22015
|
const inviter = await _getByUserId(userId);
|
|
22016
|
+
const unit = await getById(inviter?.unit);
|
|
22024
22017
|
value.checkIn = null;
|
|
22025
22018
|
const dir = __dirname;
|
|
22026
22019
|
const filePath = getDirectory2(dir, "./public/handlebars/visitor-invite");
|
|
@@ -22029,9 +22022,11 @@ function useVisitorTransactionService() {
|
|
|
22029
22022
|
block: inviter?.block,
|
|
22030
22023
|
level: inviter?.level,
|
|
22031
22024
|
unit: inviter?.unit,
|
|
22025
|
+
unitName: unit?.name,
|
|
22032
22026
|
org: inviter?.org.toString(),
|
|
22033
22027
|
site: inviter?.site.toString(),
|
|
22034
|
-
status: "pending" /* PENDING
|
|
22028
|
+
status: "pending" /* PENDING */,
|
|
22029
|
+
invitedId: inviter?._id
|
|
22035
22030
|
};
|
|
22036
22031
|
const result = await _add(payload);
|
|
22037
22032
|
const emailContent = compileHandlebar2({
|
|
@@ -22254,7 +22249,7 @@ function useVisitorTransactionController() {
|
|
|
22254
22249
|
arrivalTime: Joi55.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
22255
22250
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
22256
22251
|
}),
|
|
22257
|
-
duration: Joi55.number().integer().optional().allow(null),
|
|
22252
|
+
duration: Joi55.number().integer().optional().allow(null, ""),
|
|
22258
22253
|
name: Joi55.string().required(),
|
|
22259
22254
|
contact: Joi55.string().required(),
|
|
22260
22255
|
email: Joi55.string().email().required(),
|
|
@@ -22277,8 +22272,8 @@ function useVisitorTransactionController() {
|
|
|
22277
22272
|
const { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose, inviterUserId } = value;
|
|
22278
22273
|
const rest = { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose };
|
|
22279
22274
|
try {
|
|
22280
|
-
await _inviteVisitor(rest, inviterUserId);
|
|
22281
|
-
res.status(200).json({
|
|
22275
|
+
const result = await _inviteVisitor(rest, inviterUserId);
|
|
22276
|
+
res.status(200).json({ insertedId: result });
|
|
22282
22277
|
return;
|
|
22283
22278
|
} catch (error2) {
|
|
22284
22279
|
logger78.log({ level: "error", message: error2.message });
|
|
@@ -22925,7 +22920,8 @@ function usePersonController() {
|
|
|
22925
22920
|
getPeopleByUnit: _getPeopleByUnit,
|
|
22926
22921
|
getCompany: _getCompany,
|
|
22927
22922
|
getPeopleByPlateNumber: _getPeopleByPlateNumber,
|
|
22928
|
-
getPeopleByNRIC: _getPeopleByNRIC
|
|
22923
|
+
getPeopleByNRIC: _getPeopleByNRIC,
|
|
22924
|
+
getByUserId: _getByUserId
|
|
22929
22925
|
} = usePersonRepo();
|
|
22930
22926
|
const { add: _add, updateById: _updateById } = usePersonService();
|
|
22931
22927
|
async function add(req, res, next) {
|
|
@@ -23224,6 +23220,25 @@ function usePersonController() {
|
|
|
23224
23220
|
return;
|
|
23225
23221
|
}
|
|
23226
23222
|
}
|
|
23223
|
+
async function getPersonByUserId(req, res, next) {
|
|
23224
|
+
const validation = Joi58.string().required();
|
|
23225
|
+
const userId = req.params.userId;
|
|
23226
|
+
const { error } = validation.validate(userId);
|
|
23227
|
+
if (error) {
|
|
23228
|
+
logger82.log({ level: "error", message: error.message });
|
|
23229
|
+
next(new BadRequestError101(error.message));
|
|
23230
|
+
return;
|
|
23231
|
+
}
|
|
23232
|
+
try {
|
|
23233
|
+
const data = await _getByUserId(userId);
|
|
23234
|
+
res.json(data);
|
|
23235
|
+
return;
|
|
23236
|
+
} catch (error2) {
|
|
23237
|
+
logger82.log({ level: "error", message: error2.message });
|
|
23238
|
+
next(error2);
|
|
23239
|
+
return;
|
|
23240
|
+
}
|
|
23241
|
+
}
|
|
23227
23242
|
return {
|
|
23228
23243
|
add,
|
|
23229
23244
|
getAll,
|
|
@@ -23234,7 +23249,8 @@ function usePersonController() {
|
|
|
23234
23249
|
getPeopleByUnit,
|
|
23235
23250
|
getCompany,
|
|
23236
23251
|
getPeopleByPlateNumber,
|
|
23237
|
-
getPeopleByNRIC
|
|
23252
|
+
getPeopleByNRIC,
|
|
23253
|
+
getPersonByUserId
|
|
23238
23254
|
};
|
|
23239
23255
|
}
|
|
23240
23256
|
|
|
@@ -30921,6 +30937,95 @@ function useSiteUnitBillingRepo() {
|
|
|
30921
30937
|
throw error;
|
|
30922
30938
|
}
|
|
30923
30939
|
}
|
|
30940
|
+
async function getResidentUserBilling({
|
|
30941
|
+
search = "",
|
|
30942
|
+
page = 1,
|
|
30943
|
+
limit = 10,
|
|
30944
|
+
sort = {},
|
|
30945
|
+
status = "active",
|
|
30946
|
+
site = "",
|
|
30947
|
+
paymentStatus = "awaiting_payment",
|
|
30948
|
+
month,
|
|
30949
|
+
year,
|
|
30950
|
+
unitId
|
|
30951
|
+
}, session) {
|
|
30952
|
+
page = page > 0 ? page - 1 : 0;
|
|
30953
|
+
let dateExpr = {};
|
|
30954
|
+
if (month && year) {
|
|
30955
|
+
const monthNum = parseInt(month, 10);
|
|
30956
|
+
const yearNum = parseInt(year, 10);
|
|
30957
|
+
const startDate = new Date(yearNum, monthNum - 1, 1);
|
|
30958
|
+
const endDate = new Date(yearNum, monthNum, 1);
|
|
30959
|
+
dateExpr.createdAt = {
|
|
30960
|
+
$gte: startDate,
|
|
30961
|
+
$lt: endDate
|
|
30962
|
+
};
|
|
30963
|
+
}
|
|
30964
|
+
const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
|
|
30965
|
+
const query = {
|
|
30966
|
+
paymentStatus,
|
|
30967
|
+
status,
|
|
30968
|
+
...search && {
|
|
30969
|
+
$or: [
|
|
30970
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
30971
|
+
{ billName: { $regex: search, $options: "i" } },
|
|
30972
|
+
{ unit: { $regex: unitSearchRegex, $options: "i" } },
|
|
30973
|
+
{
|
|
30974
|
+
$expr: {
|
|
30975
|
+
$regexMatch: {
|
|
30976
|
+
input: { $toString: "$amountPaid" },
|
|
30977
|
+
regex: search,
|
|
30978
|
+
options: "i"
|
|
30979
|
+
}
|
|
30980
|
+
}
|
|
30981
|
+
}
|
|
30982
|
+
]
|
|
30983
|
+
},
|
|
30984
|
+
...ObjectId86.isValid(site) && { site: new ObjectId86(site) },
|
|
30985
|
+
...dateExpr,
|
|
30986
|
+
...ObjectId86.isValid(unitId) && { unitId: new ObjectId86(unitId) }
|
|
30987
|
+
};
|
|
30988
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
30989
|
+
try {
|
|
30990
|
+
const basePipeline = [
|
|
30991
|
+
{ $match: query },
|
|
30992
|
+
{ $sort: sort },
|
|
30993
|
+
{ $skip: page * limit },
|
|
30994
|
+
{ $limit: limit },
|
|
30995
|
+
{
|
|
30996
|
+
$lookup: {
|
|
30997
|
+
from: "site.billing.items",
|
|
30998
|
+
localField: "billItem",
|
|
30999
|
+
foreignField: "_id",
|
|
31000
|
+
pipeline: [
|
|
31001
|
+
{
|
|
31002
|
+
$project: {
|
|
31003
|
+
_id: 1,
|
|
31004
|
+
totalAmount: 1
|
|
31005
|
+
}
|
|
31006
|
+
}
|
|
31007
|
+
],
|
|
31008
|
+
as: "billDetails"
|
|
31009
|
+
}
|
|
31010
|
+
},
|
|
31011
|
+
{
|
|
31012
|
+
$unwind: {
|
|
31013
|
+
path: "$billDetails",
|
|
31014
|
+
preserveNullAndEmptyArrays: true
|
|
31015
|
+
}
|
|
31016
|
+
}
|
|
31017
|
+
];
|
|
31018
|
+
const [items, countResult] = await Promise.all([
|
|
31019
|
+
collection.aggregate(basePipeline, { session }).toArray(),
|
|
31020
|
+
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
31021
|
+
]);
|
|
31022
|
+
const totalCount = countResult[0]?.total || 0;
|
|
31023
|
+
const data = paginate37(items, page, limit, totalCount);
|
|
31024
|
+
return data;
|
|
31025
|
+
} catch (error) {
|
|
31026
|
+
throw error;
|
|
31027
|
+
}
|
|
31028
|
+
}
|
|
30924
31029
|
function delCachedData() {
|
|
30925
31030
|
delNamespace().then(() => {
|
|
30926
31031
|
logger117.log({
|
|
@@ -30952,7 +31057,8 @@ function useSiteUnitBillingRepo() {
|
|
|
30952
31057
|
getById,
|
|
30953
31058
|
updateById,
|
|
30954
31059
|
deleteById,
|
|
30955
|
-
getUnitBillingBySite
|
|
31060
|
+
getUnitBillingBySite,
|
|
31061
|
+
getResidentUserBilling
|
|
30956
31062
|
};
|
|
30957
31063
|
}
|
|
30958
31064
|
|
|
@@ -31143,7 +31249,8 @@ function useSiteUnitBillingController() {
|
|
|
31143
31249
|
getAll: _getAll,
|
|
31144
31250
|
updateById: _updateById,
|
|
31145
31251
|
deleteById: _deleteById,
|
|
31146
|
-
getById: _getById
|
|
31252
|
+
getById: _getById,
|
|
31253
|
+
getResidentUserBilling: _getResidentUserBilling
|
|
31147
31254
|
} = useSiteUnitBillingRepo();
|
|
31148
31255
|
async function add(req, res, next) {
|
|
31149
31256
|
const data = { ...req.body };
|
|
@@ -31284,12 +31391,64 @@ function useSiteUnitBillingController() {
|
|
|
31284
31391
|
return;
|
|
31285
31392
|
}
|
|
31286
31393
|
}
|
|
31394
|
+
async function getResidentUserBilling(req, res, next) {
|
|
31395
|
+
const validation = Joi84.object({
|
|
31396
|
+
page: Joi84.number().integer().min(1).allow("", null).default(1),
|
|
31397
|
+
limit: Joi84.number().integer().min(1).max(100).allow("", null).default(10),
|
|
31398
|
+
status: Joi84.string().optional().allow(null, ""),
|
|
31399
|
+
search: Joi84.string().optional().allow(null, ""),
|
|
31400
|
+
site: Joi84.string().required(),
|
|
31401
|
+
paymentStatus: Joi84.string().optional().allow(null, ""),
|
|
31402
|
+
month: Joi84.string().optional().allow(null, ""),
|
|
31403
|
+
year: Joi84.string().optional().allow(null, ""),
|
|
31404
|
+
unitId: Joi84.string().optional().allow(null, "")
|
|
31405
|
+
});
|
|
31406
|
+
const query = { ...req.query };
|
|
31407
|
+
const { error } = validation.validate(query, {
|
|
31408
|
+
abortEarly: false
|
|
31409
|
+
});
|
|
31410
|
+
if (error) {
|
|
31411
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
31412
|
+
logger119.log({ level: "error", message: messages });
|
|
31413
|
+
next(new BadRequestError140(messages));
|
|
31414
|
+
return;
|
|
31415
|
+
}
|
|
31416
|
+
const search = req.query.search ?? "";
|
|
31417
|
+
const page = parseInt(req.query.page ?? "1");
|
|
31418
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
31419
|
+
const status = req.query.status ?? "active";
|
|
31420
|
+
const site = req.query.site;
|
|
31421
|
+
const paymentStatus = req.query.paymentStatus ?? "awaiting_payment";
|
|
31422
|
+
const month = req.query.month ?? "";
|
|
31423
|
+
const year = req.query.year ?? "";
|
|
31424
|
+
const unitId = req.query.unitId ?? "";
|
|
31425
|
+
try {
|
|
31426
|
+
const data = await _getResidentUserBilling({
|
|
31427
|
+
search,
|
|
31428
|
+
page,
|
|
31429
|
+
limit,
|
|
31430
|
+
status,
|
|
31431
|
+
site,
|
|
31432
|
+
paymentStatus,
|
|
31433
|
+
month,
|
|
31434
|
+
year,
|
|
31435
|
+
unitId
|
|
31436
|
+
});
|
|
31437
|
+
res.status(200).json(data);
|
|
31438
|
+
return;
|
|
31439
|
+
} catch (error2) {
|
|
31440
|
+
logger119.log({ level: "error", message: error2.message });
|
|
31441
|
+
next(error2);
|
|
31442
|
+
return;
|
|
31443
|
+
}
|
|
31444
|
+
}
|
|
31287
31445
|
return {
|
|
31288
31446
|
add,
|
|
31289
31447
|
getAll,
|
|
31290
31448
|
getById,
|
|
31291
31449
|
updateById,
|
|
31292
|
-
deleteById
|
|
31450
|
+
deleteById,
|
|
31451
|
+
getResidentUserBilling
|
|
31293
31452
|
};
|
|
31294
31453
|
}
|
|
31295
31454
|
|
|
@@ -39856,6 +40015,7 @@ function useNfcPatrolSettingsController() {
|
|
|
39856
40015
|
|
|
39857
40016
|
// src/services/occurrence-entry.service.ts
|
|
39858
40017
|
import { useAtlas as useAtlas93 } from "@7365admin1/node-server-utils";
|
|
40018
|
+
import { ObjectId as ObjectId108 } from "mongodb";
|
|
39859
40019
|
|
|
39860
40020
|
// src/repositories/occurrence-subject.repo.ts
|
|
39861
40021
|
import {
|
|
@@ -40073,22 +40233,11 @@ function useOccurrenceSubjectRepo() {
|
|
|
40073
40233
|
} catch (error) {
|
|
40074
40234
|
throw new BadRequestError169("Invalid occurrence subject ID format.");
|
|
40075
40235
|
}
|
|
40076
|
-
const cacheKey = makeCacheKey54(namespace_collection, { _id });
|
|
40077
|
-
const cachedData = await getCache(cacheKey);
|
|
40078
|
-
if (cachedData) {
|
|
40079
|
-
logger146.info(`Cache hit for key: ${cacheKey}`);
|
|
40080
|
-
return cachedData;
|
|
40081
|
-
}
|
|
40082
40236
|
try {
|
|
40083
40237
|
const data = await collection.findOne({ _id }, { session });
|
|
40084
40238
|
if (!data) {
|
|
40085
40239
|
throw new NotFoundError46("Occurrence subject not found.");
|
|
40086
40240
|
}
|
|
40087
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
40088
|
-
logger146.info(`Cache set for key: ${cacheKey}`);
|
|
40089
|
-
}).catch((err) => {
|
|
40090
|
-
logger146.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
40091
|
-
});
|
|
40092
40241
|
return data;
|
|
40093
40242
|
} catch (error) {
|
|
40094
40243
|
throw error;
|
|
@@ -40229,11 +40378,22 @@ function useOccurrenceEntryService() {
|
|
|
40229
40378
|
const updatedSerialNumber = (entrySerialNumber + 0.1).toFixed(1);
|
|
40230
40379
|
const dobId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40231
40380
|
const book = await _getOccurrenceBookById(dobId);
|
|
40232
|
-
const subject = await _getOccurrenceSubjectById(
|
|
40381
|
+
const subject = await _getOccurrenceSubjectById(
|
|
40382
|
+
occurrenceEntry.subject._id
|
|
40383
|
+
);
|
|
40384
|
+
value.subject = value.subject ? value.subject : occurrenceEntry.subject._id;
|
|
40385
|
+
value.subjectName = subject.subject;
|
|
40233
40386
|
value.serialNumber = updatedSerialNumber;
|
|
40234
40387
|
value.site = occurrenceEntry.site;
|
|
40235
40388
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40236
|
-
value.
|
|
40389
|
+
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
40390
|
+
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
40391
|
+
value.signature = value.signature ? new ObjectId108(value.signature) : occurrenceEntry.signature._id;
|
|
40392
|
+
value.eSignature = value.eSignature ? new ObjectId108(value.eSignature) : occurrenceEntry.eSignature;
|
|
40393
|
+
value.createdAt = /* @__PURE__ */ new Date();
|
|
40394
|
+
value.date = /* @__PURE__ */ new Date();
|
|
40395
|
+
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
40396
|
+
value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
|
|
40237
40397
|
await _updateOccurrenceBookById(dobId, {
|
|
40238
40398
|
totalInput: book.totalInput + 1
|
|
40239
40399
|
});
|
|
@@ -40429,7 +40589,7 @@ function useOccurrenceEntryController() {
|
|
|
40429
40589
|
|
|
40430
40590
|
// src/models/online-form.model.ts
|
|
40431
40591
|
import Joi105 from "joi";
|
|
40432
|
-
import { ObjectId as
|
|
40592
|
+
import { ObjectId as ObjectId109 } from "mongodb";
|
|
40433
40593
|
var schemaOnlineForm = Joi105.object({
|
|
40434
40594
|
_id: Joi105.string().hex().optional().allow("", null),
|
|
40435
40595
|
name: Joi105.string().required(),
|
|
@@ -40477,21 +40637,21 @@ function MOnlineForm(value) {
|
|
|
40477
40637
|
}
|
|
40478
40638
|
if (value._id && typeof value._id === "string") {
|
|
40479
40639
|
try {
|
|
40480
|
-
value._id = new
|
|
40640
|
+
value._id = new ObjectId109(value._id);
|
|
40481
40641
|
} catch (error2) {
|
|
40482
40642
|
throw new Error("Invalid ID.");
|
|
40483
40643
|
}
|
|
40484
40644
|
}
|
|
40485
40645
|
if (value.org && typeof value.org === "string") {
|
|
40486
40646
|
try {
|
|
40487
|
-
value.org = new
|
|
40647
|
+
value.org = new ObjectId109(value.org);
|
|
40488
40648
|
} catch (error2) {
|
|
40489
40649
|
throw new Error("Invalid org ID.");
|
|
40490
40650
|
}
|
|
40491
40651
|
}
|
|
40492
40652
|
if (value.site && typeof value.site === "string") {
|
|
40493
40653
|
try {
|
|
40494
|
-
value.site = new
|
|
40654
|
+
value.site = new ObjectId109(value.site);
|
|
40495
40655
|
} catch (error2) {
|
|
40496
40656
|
throw new Error("Invalid site ID.");
|
|
40497
40657
|
}
|
|
@@ -40523,7 +40683,7 @@ import {
|
|
|
40523
40683
|
useAtlas as useAtlas94,
|
|
40524
40684
|
useCache as useCache57
|
|
40525
40685
|
} from "@7365admin1/node-server-utils";
|
|
40526
|
-
import { ObjectId as
|
|
40686
|
+
import { ObjectId as ObjectId110 } from "mongodb";
|
|
40527
40687
|
function useOnlineFormRepo() {
|
|
40528
40688
|
const db = useAtlas94.getDb();
|
|
40529
40689
|
if (!db) {
|
|
@@ -40575,7 +40735,7 @@ function useOnlineFormRepo() {
|
|
|
40575
40735
|
}) {
|
|
40576
40736
|
page = page > 0 ? page - 1 : 0;
|
|
40577
40737
|
try {
|
|
40578
|
-
site = new
|
|
40738
|
+
site = new ObjectId110(site);
|
|
40579
40739
|
} catch (error) {
|
|
40580
40740
|
throw new BadRequestError171("Invalid site ID format.");
|
|
40581
40741
|
}
|
|
@@ -40635,7 +40795,7 @@ function useOnlineFormRepo() {
|
|
|
40635
40795
|
}
|
|
40636
40796
|
async function getOnlineFormById(_id) {
|
|
40637
40797
|
try {
|
|
40638
|
-
_id = new
|
|
40798
|
+
_id = new ObjectId110(_id);
|
|
40639
40799
|
} catch (error) {
|
|
40640
40800
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40641
40801
|
}
|
|
@@ -40678,7 +40838,7 @@ function useOnlineFormRepo() {
|
|
|
40678
40838
|
}
|
|
40679
40839
|
async function updateOnlineFormById(_id, value) {
|
|
40680
40840
|
try {
|
|
40681
|
-
_id = new
|
|
40841
|
+
_id = new ObjectId110(_id);
|
|
40682
40842
|
} catch (error) {
|
|
40683
40843
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40684
40844
|
}
|
|
@@ -40706,7 +40866,7 @@ function useOnlineFormRepo() {
|
|
|
40706
40866
|
}
|
|
40707
40867
|
async function deleteOnlineFormById(_id, session) {
|
|
40708
40868
|
try {
|
|
40709
|
-
_id = new
|
|
40869
|
+
_id = new ObjectId110(_id);
|
|
40710
40870
|
} catch (error) {
|
|
40711
40871
|
throw new BadRequestError171("Invalid online form ID format.");
|
|
40712
40872
|
}
|
|
@@ -40739,7 +40899,7 @@ function useOnlineFormRepo() {
|
|
|
40739
40899
|
}
|
|
40740
40900
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
40741
40901
|
try {
|
|
40742
|
-
site = new
|
|
40902
|
+
site = new ObjectId110(site);
|
|
40743
40903
|
} catch (error) {
|
|
40744
40904
|
throw new BadRequestError171(
|
|
40745
40905
|
"Invalid online form configuration site ID format."
|
|
@@ -41180,7 +41340,7 @@ function useOccurrenceSubjectController() {
|
|
|
41180
41340
|
}
|
|
41181
41341
|
|
|
41182
41342
|
// src/models/nfc-patrol-log.model.ts
|
|
41183
|
-
import { ObjectId as
|
|
41343
|
+
import { ObjectId as ObjectId111 } from "mongodb";
|
|
41184
41344
|
import Joi108 from "joi";
|
|
41185
41345
|
import { BadRequestError as BadRequestError174, logger as logger151 } from "@7365admin1/node-server-utils";
|
|
41186
41346
|
var schemaNfcPatrolLog = Joi108.object({
|
|
@@ -41232,32 +41392,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41232
41392
|
}
|
|
41233
41393
|
if (value._id && typeof value._id === "string") {
|
|
41234
41394
|
try {
|
|
41235
|
-
value._id = new
|
|
41395
|
+
value._id = new ObjectId111(value._id);
|
|
41236
41396
|
} catch (error2) {
|
|
41237
41397
|
throw new BadRequestError174("Invalid _id format");
|
|
41238
41398
|
}
|
|
41239
41399
|
}
|
|
41240
41400
|
try {
|
|
41241
|
-
value.site = new
|
|
41401
|
+
value.site = new ObjectId111(value.site);
|
|
41242
41402
|
} catch (error2) {
|
|
41243
41403
|
throw new BadRequestError174("Invalid site format");
|
|
41244
41404
|
}
|
|
41245
41405
|
if (value?.createdBy) {
|
|
41246
41406
|
try {
|
|
41247
|
-
value.createdBy = new
|
|
41407
|
+
value.createdBy = new ObjectId111(value.createdBy);
|
|
41248
41408
|
} catch (error2) {
|
|
41249
41409
|
throw new BadRequestError174("Invalid createdBy format");
|
|
41250
41410
|
}
|
|
41251
41411
|
}
|
|
41252
41412
|
if (value?.route?._id) {
|
|
41253
41413
|
try {
|
|
41254
|
-
value.route._id = new
|
|
41414
|
+
value.route._id = new ObjectId111(value.route._id);
|
|
41255
41415
|
} catch (error2) {
|
|
41256
41416
|
throw new BadRequestError174("Invalid route _id format");
|
|
41257
41417
|
}
|
|
41258
41418
|
}
|
|
41259
41419
|
return {
|
|
41260
|
-
_id: value._id ?? new
|
|
41420
|
+
_id: value._id ?? new ObjectId111(),
|
|
41261
41421
|
site: value.site,
|
|
41262
41422
|
route: value.route,
|
|
41263
41423
|
date: value.date,
|
|
@@ -41279,7 +41439,7 @@ import {
|
|
|
41279
41439
|
useAtlas as useAtlas96,
|
|
41280
41440
|
useCache as useCache58
|
|
41281
41441
|
} from "@7365admin1/node-server-utils";
|
|
41282
|
-
import { ObjectId as
|
|
41442
|
+
import { ObjectId as ObjectId112 } from "mongodb";
|
|
41283
41443
|
function useNfcPatrolLogRepo() {
|
|
41284
41444
|
const db = useAtlas96.getDb();
|
|
41285
41445
|
if (!db) {
|
|
@@ -41332,7 +41492,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41332
41492
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
41333
41493
|
let siteId;
|
|
41334
41494
|
try {
|
|
41335
|
-
siteId = typeof site === "string" ? new
|
|
41495
|
+
siteId = typeof site === "string" ? new ObjectId112(site) : site;
|
|
41336
41496
|
} catch {
|
|
41337
41497
|
throw new BadRequestError175("Invalid site ID format.");
|
|
41338
41498
|
}
|
|
@@ -41343,7 +41503,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41343
41503
|
query.date = date;
|
|
41344
41504
|
}
|
|
41345
41505
|
if (route?._id) {
|
|
41346
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
41506
|
+
query["route._id"] = typeof route._id === "string" ? new ObjectId112(route._id) : route._id;
|
|
41347
41507
|
}
|
|
41348
41508
|
if (route?.startTime) {
|
|
41349
41509
|
query["route.startTime"] = route.startTime;
|
|
@@ -42215,7 +42375,7 @@ function useNewDashboardController() {
|
|
|
42215
42375
|
|
|
42216
42376
|
// src/models/manpower-monitoring.model.ts
|
|
42217
42377
|
import Joi111 from "joi";
|
|
42218
|
-
import { ObjectId as
|
|
42378
|
+
import { ObjectId as ObjectId113 } from "mongodb";
|
|
42219
42379
|
var shiftSchema = Joi111.object({
|
|
42220
42380
|
name: Joi111.string().required(),
|
|
42221
42381
|
checkIn: Joi111.string().optional().allow("", null),
|
|
@@ -42240,7 +42400,7 @@ var manpowerMonitoringSchema = Joi111.object({
|
|
|
42240
42400
|
});
|
|
42241
42401
|
var MManpowerMonitoring = class {
|
|
42242
42402
|
constructor(data) {
|
|
42243
|
-
this._id = new
|
|
42403
|
+
this._id = new ObjectId113();
|
|
42244
42404
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42245
42405
|
this.siteId = data.siteId || "";
|
|
42246
42406
|
this.siteName = data.siteName;
|
|
@@ -42710,7 +42870,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
42710
42870
|
};
|
|
42711
42871
|
|
|
42712
42872
|
// src/repositories/manpower-monitoring.repo.ts
|
|
42713
|
-
import { ObjectId as
|
|
42873
|
+
import { ObjectId as ObjectId114 } from "mongodb";
|
|
42714
42874
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
42715
42875
|
function useManpowerMonitoringRepo() {
|
|
42716
42876
|
const db = useAtlas99.getDb();
|
|
@@ -42724,11 +42884,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42724
42884
|
try {
|
|
42725
42885
|
value = new MManpowerMonitoring(value);
|
|
42726
42886
|
if (value.createdBy)
|
|
42727
|
-
value.createdBy = new
|
|
42887
|
+
value.createdBy = new ObjectId114(value.createdBy);
|
|
42728
42888
|
if (value.siteId)
|
|
42729
|
-
value.siteId = new
|
|
42889
|
+
value.siteId = new ObjectId114(value.siteId);
|
|
42730
42890
|
if (value.serviceProviderId)
|
|
42731
|
-
value.serviceProviderId = new
|
|
42891
|
+
value.serviceProviderId = new ObjectId114(value.serviceProviderId);
|
|
42732
42892
|
const result = await collection.insertOne(value, { session });
|
|
42733
42893
|
return result;
|
|
42734
42894
|
} catch (error) {
|
|
@@ -42769,8 +42929,8 @@ function useManpowerMonitoringRepo() {
|
|
|
42769
42929
|
}
|
|
42770
42930
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
42771
42931
|
try {
|
|
42772
|
-
_id = new
|
|
42773
|
-
serviceProviderId = new
|
|
42932
|
+
_id = new ObjectId114(_id);
|
|
42933
|
+
serviceProviderId = new ObjectId114(serviceProviderId);
|
|
42774
42934
|
} catch (error) {
|
|
42775
42935
|
throw new Error("Invalid Site ID format.");
|
|
42776
42936
|
}
|
|
@@ -42786,7 +42946,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42786
42946
|
}
|
|
42787
42947
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
42788
42948
|
try {
|
|
42789
|
-
_id = new
|
|
42949
|
+
_id = new ObjectId114(_id);
|
|
42790
42950
|
} catch (error) {
|
|
42791
42951
|
throw new BadRequestError180("Invalid ID format.");
|
|
42792
42952
|
}
|
|
@@ -42813,7 +42973,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42813
42973
|
for (let item of value) {
|
|
42814
42974
|
item = new MManpowerMonitoring(item);
|
|
42815
42975
|
const data = await collection.findOne({
|
|
42816
|
-
siteId: new
|
|
42976
|
+
siteId: new ObjectId114(item.siteId)
|
|
42817
42977
|
});
|
|
42818
42978
|
if (data) {
|
|
42819
42979
|
let updateValue;
|
|
@@ -42838,11 +42998,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42838
42998
|
}
|
|
42839
42999
|
} else {
|
|
42840
43000
|
if (item.createdBy)
|
|
42841
|
-
item.createdBy = new
|
|
43001
|
+
item.createdBy = new ObjectId114(item.createdBy);
|
|
42842
43002
|
if (item.siteId)
|
|
42843
|
-
item.siteId = new
|
|
43003
|
+
item.siteId = new ObjectId114(item.siteId);
|
|
42844
43004
|
if (item.serviceProviderId)
|
|
42845
|
-
item.serviceProviderId = new
|
|
43005
|
+
item.serviceProviderId = new ObjectId114(item.serviceProviderId);
|
|
42846
43006
|
const result = await collection.insertOne(item);
|
|
42847
43007
|
if (result.insertedId) {
|
|
42848
43008
|
results.inserted++;
|
|
@@ -42866,7 +43026,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42866
43026
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
42867
43027
|
try {
|
|
42868
43028
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
42869
|
-
_id: new
|
|
43029
|
+
_id: new ObjectId114(serviceProviderId)
|
|
42870
43030
|
});
|
|
42871
43031
|
if (!serviceProvider) {
|
|
42872
43032
|
throw new Error("Service Provider not found.");
|
|
@@ -42916,7 +43076,7 @@ import {
|
|
|
42916
43076
|
|
|
42917
43077
|
// src/models/manpower-remarks.model.ts
|
|
42918
43078
|
import Joi112 from "joi";
|
|
42919
|
-
import { ObjectId as
|
|
43079
|
+
import { ObjectId as ObjectId115 } from "mongodb";
|
|
42920
43080
|
var remarksSchema = Joi112.object({
|
|
42921
43081
|
name: Joi112.string().required(),
|
|
42922
43082
|
remark: Joi112.object({
|
|
@@ -42940,7 +43100,7 @@ var manpowerRemarksSchema = Joi112.object({
|
|
|
42940
43100
|
});
|
|
42941
43101
|
var MManpowerRemarks = class {
|
|
42942
43102
|
constructor(data) {
|
|
42943
|
-
this._id = new
|
|
43103
|
+
this._id = new ObjectId115();
|
|
42944
43104
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42945
43105
|
this.siteId = data.siteId || "";
|
|
42946
43106
|
this.siteName = data.siteName || "";
|
|
@@ -42958,7 +43118,7 @@ var MManpowerRemarks = class {
|
|
|
42958
43118
|
};
|
|
42959
43119
|
|
|
42960
43120
|
// src/repositories/manpower-remarks.repo.ts
|
|
42961
|
-
import { ObjectId as
|
|
43121
|
+
import { ObjectId as ObjectId116 } from "mongodb";
|
|
42962
43122
|
import moment2 from "moment-timezone";
|
|
42963
43123
|
function useManpowerRemarksRepo() {
|
|
42964
43124
|
const db = useAtlas100.getDb();
|
|
@@ -42971,9 +43131,9 @@ function useManpowerRemarksRepo() {
|
|
|
42971
43131
|
try {
|
|
42972
43132
|
value = new MManpowerRemarks(value);
|
|
42973
43133
|
if (value.siteId)
|
|
42974
|
-
value.siteId = new
|
|
43134
|
+
value.siteId = new ObjectId116(value.siteId);
|
|
42975
43135
|
if (value.serviceProviderId)
|
|
42976
|
-
value.serviceProviderId = new
|
|
43136
|
+
value.serviceProviderId = new ObjectId116(value.serviceProviderId);
|
|
42977
43137
|
const result = await collection.insertOne(value, { session });
|
|
42978
43138
|
return result;
|
|
42979
43139
|
} catch (error) {
|
|
@@ -42993,7 +43153,7 @@ function useManpowerRemarksRepo() {
|
|
|
42993
43153
|
limit = limit || 10;
|
|
42994
43154
|
const searchQuery = {};
|
|
42995
43155
|
const nowSGT = moment2().tz("Asia/Singapore");
|
|
42996
|
-
searchQuery.serviceProviderId = new
|
|
43156
|
+
searchQuery.serviceProviderId = new ObjectId116(serviceProviderId);
|
|
42997
43157
|
if (search != "") {
|
|
42998
43158
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
42999
43159
|
}
|
|
@@ -43025,8 +43185,8 @@ function useManpowerRemarksRepo() {
|
|
|
43025
43185
|
}
|
|
43026
43186
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
43027
43187
|
try {
|
|
43028
|
-
_id = new
|
|
43029
|
-
serviceProviderId = new
|
|
43188
|
+
_id = new ObjectId116(_id);
|
|
43189
|
+
serviceProviderId = new ObjectId116(serviceProviderId);
|
|
43030
43190
|
} catch (error) {
|
|
43031
43191
|
throw new Error("Invalid Site ID format.");
|
|
43032
43192
|
}
|
|
@@ -43043,13 +43203,13 @@ function useManpowerRemarksRepo() {
|
|
|
43043
43203
|
}
|
|
43044
43204
|
async function updateManpowerRemarks(_id, value) {
|
|
43045
43205
|
try {
|
|
43046
|
-
_id = new
|
|
43206
|
+
_id = new ObjectId116(_id);
|
|
43047
43207
|
} catch (error) {
|
|
43048
43208
|
throw new BadRequestError181("Invalid ID format.");
|
|
43049
43209
|
}
|
|
43050
43210
|
try {
|
|
43051
43211
|
if (value.createdBy) {
|
|
43052
|
-
value.createdBy = new
|
|
43212
|
+
value.createdBy = new ObjectId116(value.createdBy);
|
|
43053
43213
|
}
|
|
43054
43214
|
const updateValue = {
|
|
43055
43215
|
...value,
|
|
@@ -43066,7 +43226,7 @@ function useManpowerRemarksRepo() {
|
|
|
43066
43226
|
}
|
|
43067
43227
|
async function updateRemarksStatus(_id, value) {
|
|
43068
43228
|
try {
|
|
43069
|
-
_id = new
|
|
43229
|
+
_id = new ObjectId116(_id);
|
|
43070
43230
|
} catch (error) {
|
|
43071
43231
|
throw new BadRequestError181("Invalid ID format.");
|
|
43072
43232
|
}
|
|
@@ -43338,7 +43498,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
43338
43498
|
|
|
43339
43499
|
// src/models/manpower-designations.model.ts
|
|
43340
43500
|
import Joi114 from "joi";
|
|
43341
|
-
import { ObjectId as
|
|
43501
|
+
import { ObjectId as ObjectId117 } from "mongodb";
|
|
43342
43502
|
var designationsSchema = Joi114.object({
|
|
43343
43503
|
title: Joi114.string().required(),
|
|
43344
43504
|
shifts: Joi114.object({
|
|
@@ -43357,7 +43517,7 @@ var manpowerDesignationsSchema = Joi114.object({
|
|
|
43357
43517
|
});
|
|
43358
43518
|
var MManpowerDesignations = class {
|
|
43359
43519
|
constructor(data) {
|
|
43360
|
-
this._id = new
|
|
43520
|
+
this._id = new ObjectId117();
|
|
43361
43521
|
this.siteId = data.siteId || "";
|
|
43362
43522
|
this.siteName = data.siteName || "";
|
|
43363
43523
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -43373,7 +43533,7 @@ var MManpowerDesignations = class {
|
|
|
43373
43533
|
import {
|
|
43374
43534
|
useAtlas as useAtlas102
|
|
43375
43535
|
} from "@7365admin1/node-server-utils";
|
|
43376
|
-
import { ObjectId as
|
|
43536
|
+
import { ObjectId as ObjectId118 } from "mongodb";
|
|
43377
43537
|
function useManpowerDesignationRepo() {
|
|
43378
43538
|
const db = useAtlas102.getDb();
|
|
43379
43539
|
if (!db) {
|
|
@@ -43385,11 +43545,11 @@ function useManpowerDesignationRepo() {
|
|
|
43385
43545
|
try {
|
|
43386
43546
|
value = new MManpowerDesignations(value);
|
|
43387
43547
|
if (value.createdBy)
|
|
43388
|
-
value.createdBy = new
|
|
43548
|
+
value.createdBy = new ObjectId118(value.createdBy);
|
|
43389
43549
|
if (value.siteId)
|
|
43390
|
-
value.siteId = new
|
|
43550
|
+
value.siteId = new ObjectId118(value.siteId);
|
|
43391
43551
|
if (value.serviceProviderId)
|
|
43392
|
-
value.serviceProviderId = new
|
|
43552
|
+
value.serviceProviderId = new ObjectId118(value.serviceProviderId);
|
|
43393
43553
|
const result = await collection.insertOne(value);
|
|
43394
43554
|
return result;
|
|
43395
43555
|
} catch (error) {
|
|
@@ -43398,8 +43558,8 @@ function useManpowerDesignationRepo() {
|
|
|
43398
43558
|
}
|
|
43399
43559
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
43400
43560
|
try {
|
|
43401
|
-
_id = new
|
|
43402
|
-
serviceProviderId = new
|
|
43561
|
+
_id = new ObjectId118(_id);
|
|
43562
|
+
serviceProviderId = new ObjectId118(serviceProviderId);
|
|
43403
43563
|
} catch (error) {
|
|
43404
43564
|
throw new Error("Invalid Site ID format.");
|
|
43405
43565
|
}
|
|
@@ -43415,7 +43575,7 @@ function useManpowerDesignationRepo() {
|
|
|
43415
43575
|
}
|
|
43416
43576
|
async function updateManpowerDesignations(_id, value) {
|
|
43417
43577
|
try {
|
|
43418
|
-
_id = new
|
|
43578
|
+
_id = new ObjectId118(_id);
|
|
43419
43579
|
} catch (error) {
|
|
43420
43580
|
throw new Error("Invalid ID format.");
|
|
43421
43581
|
}
|
|
@@ -43518,7 +43678,7 @@ function useManpowerDesignationCtrl() {
|
|
|
43518
43678
|
|
|
43519
43679
|
// src/models/overnight-parking.model.ts
|
|
43520
43680
|
import Joi116 from "joi";
|
|
43521
|
-
import { ObjectId as
|
|
43681
|
+
import { ObjectId as ObjectId119 } from "mongodb";
|
|
43522
43682
|
var dayScheduleSchema = Joi116.object({
|
|
43523
43683
|
isEnabled: Joi116.boolean().required(),
|
|
43524
43684
|
startTime: Joi116.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -43560,7 +43720,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
43560
43720
|
}
|
|
43561
43721
|
if (value.site && typeof value.site === "string") {
|
|
43562
43722
|
try {
|
|
43563
|
-
value.site = new
|
|
43723
|
+
value.site = new ObjectId119(value.site);
|
|
43564
43724
|
} catch {
|
|
43565
43725
|
throw new Error("Invalid site ID.");
|
|
43566
43726
|
}
|
|
@@ -45184,7 +45344,7 @@ function useManpowerRemarkCtrl() {
|
|
|
45184
45344
|
|
|
45185
45345
|
// src/models/manpower-sites.model.ts
|
|
45186
45346
|
import Joi122 from "joi";
|
|
45187
|
-
import { ObjectId as
|
|
45347
|
+
import { ObjectId as ObjectId120 } from "mongodb";
|
|
45188
45348
|
var manpowerSitesSchema = Joi122.object({
|
|
45189
45349
|
id: Joi122.string().hex().required(),
|
|
45190
45350
|
text: Joi122.string().hex().optional().allow("", null),
|
|
@@ -45195,7 +45355,7 @@ var manpowerSitesSchema = Joi122.object({
|
|
|
45195
45355
|
});
|
|
45196
45356
|
var MManpowerSites = class {
|
|
45197
45357
|
constructor(data) {
|
|
45198
|
-
this._id = new
|
|
45358
|
+
this._id = new ObjectId120();
|
|
45199
45359
|
this.id = data.id || "";
|
|
45200
45360
|
this.text = data.text || "";
|
|
45201
45361
|
this.contractID = data.contractID || "";
|
|
@@ -45417,7 +45577,7 @@ import {
|
|
|
45417
45577
|
getDirectory as getDirectory3,
|
|
45418
45578
|
logger as logger174
|
|
45419
45579
|
} from "@7365admin1/node-server-utils";
|
|
45420
|
-
import { ObjectId as
|
|
45580
|
+
import { ObjectId as ObjectId121 } from "mongodb";
|
|
45421
45581
|
import moment4 from "moment-timezone";
|
|
45422
45582
|
var createManpowerRemarksDaily = async () => {
|
|
45423
45583
|
const db = useAtlas108.getDb();
|
|
@@ -45577,7 +45737,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
45577
45737
|
for (const id of updatedIds) {
|
|
45578
45738
|
const doc = await remarks.findOne({ _id: id });
|
|
45579
45739
|
const setting = await settings.findOne(
|
|
45580
|
-
{ siteId: new
|
|
45740
|
+
{ siteId: new ObjectId121(doc?.siteId) },
|
|
45581
45741
|
{ projection: { emails: 1 } }
|
|
45582
45742
|
);
|
|
45583
45743
|
const payload = {
|
|
@@ -45663,7 +45823,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
45663
45823
|
for (const doc of docs) {
|
|
45664
45824
|
let shiftsToCheck = [];
|
|
45665
45825
|
const endShiftTime = await settings.findOne(
|
|
45666
|
-
{ siteId: new
|
|
45826
|
+
{ siteId: new ObjectId121(doc.siteId) },
|
|
45667
45827
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45668
45828
|
);
|
|
45669
45829
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -45769,7 +45929,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
45769
45929
|
|
|
45770
45930
|
// src/events/manpower.event.ts
|
|
45771
45931
|
import { useAtlas as useAtlas109 } from "@7365admin1/node-server-utils";
|
|
45772
|
-
import { ObjectId as
|
|
45932
|
+
import { ObjectId as ObjectId122 } from "mongodb";
|
|
45773
45933
|
import moment5 from "moment-timezone";
|
|
45774
45934
|
async function manpowerEvents(io) {
|
|
45775
45935
|
let intervalId = null;
|
|
@@ -45795,7 +45955,7 @@ async function manpowerEvents(io) {
|
|
|
45795
45955
|
}).toArray();
|
|
45796
45956
|
for (const doc of docs) {
|
|
45797
45957
|
const siteSettings = await settings.findOne(
|
|
45798
|
-
{ siteId: new
|
|
45958
|
+
{ siteId: new ObjectId122(doc.siteId), enabled: true },
|
|
45799
45959
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45800
45960
|
);
|
|
45801
45961
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -45914,7 +46074,7 @@ function genericSignature(params, secretKey) {
|
|
|
45914
46074
|
}
|
|
45915
46075
|
|
|
45916
46076
|
// src/repositories/reddot-payment.repository.ts
|
|
45917
|
-
import { ObjectId as
|
|
46077
|
+
import { ObjectId as ObjectId126 } from "mongodb";
|
|
45918
46078
|
|
|
45919
46079
|
// src/utils/date-format.util.ts
|
|
45920
46080
|
import moment6 from "moment-timezone";
|
|
@@ -45939,11 +46099,11 @@ function formatDateString(today, format, dateRange) {
|
|
|
45939
46099
|
}
|
|
45940
46100
|
|
|
45941
46101
|
// src/models/credit-card.model.ts
|
|
45942
|
-
import { ObjectId as
|
|
46102
|
+
import { ObjectId as ObjectId123 } from "mongodb";
|
|
45943
46103
|
var MCardInfo = class {
|
|
45944
46104
|
// this is coming from RDP transaction
|
|
45945
46105
|
constructor({
|
|
45946
|
-
_id = new
|
|
46106
|
+
_id = new ObjectId123(),
|
|
45947
46107
|
userId,
|
|
45948
46108
|
cardType,
|
|
45949
46109
|
cardNumber,
|
|
@@ -45978,11 +46138,11 @@ var MCardInfo = class {
|
|
|
45978
46138
|
};
|
|
45979
46139
|
|
|
45980
46140
|
// src/models/cart.model.ts
|
|
45981
|
-
import { ObjectId as
|
|
46141
|
+
import { ObjectId as ObjectId124 } from "mongodb";
|
|
45982
46142
|
var MUnitBillings = class {
|
|
45983
46143
|
// transaction response messages
|
|
45984
46144
|
constructor({
|
|
45985
|
-
_id = new
|
|
46145
|
+
_id = new ObjectId124(),
|
|
45986
46146
|
unit,
|
|
45987
46147
|
unitId,
|
|
45988
46148
|
unitBill,
|
|
@@ -46023,7 +46183,7 @@ var MUnitBillings = class {
|
|
|
46023
46183
|
};
|
|
46024
46184
|
|
|
46025
46185
|
// src/repositories/payment.repository.ts
|
|
46026
|
-
import { ObjectId as
|
|
46186
|
+
import { ObjectId as ObjectId125 } from "mongodb";
|
|
46027
46187
|
import {
|
|
46028
46188
|
InternalServerError as InternalServerError66,
|
|
46029
46189
|
useAtlas as useAtlas110
|
|
@@ -46060,7 +46220,7 @@ var PaymentBillRepo = () => {
|
|
|
46060
46220
|
if (unitBillInfo?.status === "Inactive" /* inactive */) {
|
|
46061
46221
|
throw new Error("This Bill is Inactive!");
|
|
46062
46222
|
}
|
|
46063
|
-
const billId = new
|
|
46223
|
+
const billId = new ObjectId125(unitBillInfo?.billId);
|
|
46064
46224
|
const billInfo = await billCollection().findOne({ _id: billId });
|
|
46065
46225
|
if (!billInfo) {
|
|
46066
46226
|
throw new Error("Bill info not found");
|
|
@@ -46099,13 +46259,13 @@ var PaymentBillRepo = () => {
|
|
|
46099
46259
|
const saveCreditCardInfo = async (payload) => {
|
|
46100
46260
|
try {
|
|
46101
46261
|
if (payload.userId)
|
|
46102
|
-
payload.userId = new
|
|
46262
|
+
payload.userId = new ObjectId125(payload.userId);
|
|
46103
46263
|
if (payload.site)
|
|
46104
|
-
payload.site = new
|
|
46264
|
+
payload.site = new ObjectId125(payload.site);
|
|
46105
46265
|
if (payload.organization)
|
|
46106
|
-
payload.organization = new
|
|
46266
|
+
payload.organization = new ObjectId125(payload.organization);
|
|
46107
46267
|
if (payload.createdBy)
|
|
46108
|
-
payload.createdBy = new
|
|
46268
|
+
payload.createdBy = new ObjectId125(payload.createdBy);
|
|
46109
46269
|
const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46110
46270
|
payload.createdAt = createdAt;
|
|
46111
46271
|
const result = await creditCollection().insertOne(new MCardInfo(payload));
|
|
@@ -46117,19 +46277,19 @@ var PaymentBillRepo = () => {
|
|
|
46117
46277
|
const checkOutUnitBills = async (payload) => {
|
|
46118
46278
|
try {
|
|
46119
46279
|
if (payload.unitId)
|
|
46120
|
-
payload.unitId = new
|
|
46280
|
+
payload.unitId = new ObjectId125(payload.unitId);
|
|
46121
46281
|
if (payload.site)
|
|
46122
|
-
payload.site = new
|
|
46282
|
+
payload.site = new ObjectId125(payload.site);
|
|
46123
46283
|
if (payload.organization)
|
|
46124
|
-
payload.organization = new
|
|
46284
|
+
payload.organization = new ObjectId125(payload.organization);
|
|
46125
46285
|
payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46126
46286
|
const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
|
|
46127
46287
|
const unitId = payload.unitId;
|
|
46128
46288
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
|
|
46129
46289
|
const unit = unitId?.toString().slice(-4);
|
|
46130
|
-
const newId = new
|
|
46290
|
+
const newId = new ObjectId125(addToCart?.insertedId).toString().slice(-4);
|
|
46131
46291
|
const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
|
|
46132
|
-
const result = await cartCollection().findOneAndUpdate({ _id: new
|
|
46292
|
+
const result = await cartCollection().findOneAndUpdate({ _id: new ObjectId125(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
|
|
46133
46293
|
return result;
|
|
46134
46294
|
} catch (error) {
|
|
46135
46295
|
throw new Error(error.message || error || "Server Internal Error");
|
|
@@ -46160,7 +46320,7 @@ var PaymentBillRepo = () => {
|
|
|
46160
46320
|
for (const ref of refNumber) {
|
|
46161
46321
|
const unitBillInfo = await collection().findOne({ referenceNumber: ref });
|
|
46162
46322
|
const billId = unitBillInfo?.billId;
|
|
46163
|
-
const billInfo = await billCollection().findOne({ _id: new
|
|
46323
|
+
const billInfo = await billCollection().findOne({ _id: new ObjectId125(billId) });
|
|
46164
46324
|
const billAmount = billInfo?.price;
|
|
46165
46325
|
payload.updatedAt = updatedAt;
|
|
46166
46326
|
payload.amountPaid = billAmount;
|
|
@@ -46314,7 +46474,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46314
46474
|
throw new Error("Failed to Add Merchant Details");
|
|
46315
46475
|
}
|
|
46316
46476
|
const merchantId = merchant?.insertedId;
|
|
46317
|
-
const orgId = new
|
|
46477
|
+
const orgId = new ObjectId126(_id);
|
|
46318
46478
|
const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
|
|
46319
46479
|
returnDocument: "after"
|
|
46320
46480
|
});
|
|
@@ -46343,7 +46503,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46343
46503
|
const getMerchantDetailsById = async (_id) => {
|
|
46344
46504
|
try {
|
|
46345
46505
|
if (_id)
|
|
46346
|
-
_id = new
|
|
46506
|
+
_id = new ObjectId126(_id);
|
|
46347
46507
|
const result = await redDotMerchantCollection().aggregate([
|
|
46348
46508
|
{
|
|
46349
46509
|
$match: {
|
|
@@ -46606,7 +46766,7 @@ import {
|
|
|
46606
46766
|
useAtlas as useAtlas112,
|
|
46607
46767
|
useCache as useCache66
|
|
46608
46768
|
} from "@7365admin1/node-server-utils";
|
|
46609
|
-
import { ObjectId as
|
|
46769
|
+
import { ObjectId as ObjectId127 } from "mongodb";
|
|
46610
46770
|
function useVerificationRepoV2() {
|
|
46611
46771
|
const db = useAtlas112.getDb();
|
|
46612
46772
|
if (!db) {
|
|
@@ -46659,7 +46819,7 @@ function useVerificationRepoV2() {
|
|
|
46659
46819
|
}
|
|
46660
46820
|
async function updateVerificationStatusById(_id, status, session) {
|
|
46661
46821
|
try {
|
|
46662
|
-
_id = new
|
|
46822
|
+
_id = new ObjectId127(_id);
|
|
46663
46823
|
} catch (error) {
|
|
46664
46824
|
throw new BadRequestError195("Invalid verification ID format.");
|
|
46665
46825
|
}
|
|
@@ -47227,7 +47387,7 @@ import {
|
|
|
47227
47387
|
import { v4 as uuidv42 } from "uuid";
|
|
47228
47388
|
|
|
47229
47389
|
// src/repositories/user-v2.repo.ts
|
|
47230
|
-
import { ObjectId as
|
|
47390
|
+
import { ObjectId as ObjectId128 } from "mongodb";
|
|
47231
47391
|
import {
|
|
47232
47392
|
useAtlas as useAtlas114,
|
|
47233
47393
|
InternalServerError as InternalServerError70,
|
|
@@ -47439,7 +47599,7 @@ function useUserRepoV2() {
|
|
|
47439
47599
|
}
|
|
47440
47600
|
if (organization) {
|
|
47441
47601
|
try {
|
|
47442
|
-
query.defaultOrg = new
|
|
47602
|
+
query.defaultOrg = new ObjectId128(organization);
|
|
47443
47603
|
cacheOptions.organization = organization.toString();
|
|
47444
47604
|
} catch (error) {
|
|
47445
47605
|
throw new BadRequestError198("Invalid organization ID format.");
|
|
@@ -47578,13 +47738,13 @@ function useUserRepoV2() {
|
|
|
47578
47738
|
);
|
|
47579
47739
|
}
|
|
47580
47740
|
try {
|
|
47581
|
-
_id = new
|
|
47741
|
+
_id = new ObjectId128(_id);
|
|
47582
47742
|
} catch (error) {
|
|
47583
47743
|
throw new BadRequestError198("Invalid ID.");
|
|
47584
47744
|
}
|
|
47585
47745
|
if (field === "defaultOrg") {
|
|
47586
47746
|
try {
|
|
47587
|
-
value = new
|
|
47747
|
+
value = new ObjectId128(value);
|
|
47588
47748
|
} catch (error) {
|
|
47589
47749
|
throw new BadRequestError198("Invalid organization ID.");
|
|
47590
47750
|
}
|
|
@@ -47625,7 +47785,7 @@ function useUserRepoV2() {
|
|
|
47625
47785
|
year
|
|
47626
47786
|
}, session) {
|
|
47627
47787
|
try {
|
|
47628
|
-
_id = new
|
|
47788
|
+
_id = new ObjectId128(_id);
|
|
47629
47789
|
} catch (error) {
|
|
47630
47790
|
throw new BadRequestError198("Invalid user ID format.");
|
|
47631
47791
|
}
|
|
@@ -47655,7 +47815,7 @@ function useUserRepoV2() {
|
|
|
47655
47815
|
}
|
|
47656
47816
|
async function updatePassword({ _id, password }, session) {
|
|
47657
47817
|
try {
|
|
47658
|
-
_id = new
|
|
47818
|
+
_id = new ObjectId128(_id);
|
|
47659
47819
|
} catch (error) {
|
|
47660
47820
|
throw new BadRequestError198("Invalid user ID format.");
|
|
47661
47821
|
}
|