@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.js
CHANGED
|
@@ -13314,7 +13314,7 @@ var schemaVisitorTransaction = import_joi36.default.object({
|
|
|
13314
13314
|
arrivalTime: import_joi36.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
13315
13315
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
13316
13316
|
}),
|
|
13317
|
-
duration: import_joi36.default.number().integer().optional().allow(null),
|
|
13317
|
+
duration: import_joi36.default.number().integer().optional().allow(null, ""),
|
|
13318
13318
|
isOvernightParking: import_joi36.default.boolean().optional().default(false),
|
|
13319
13319
|
email: import_joi36.default.string().email().optional().allow(null, ""),
|
|
13320
13320
|
numberOfPassengers: import_joi36.default.number().integer().optional().allow(null, ""),
|
|
@@ -13331,7 +13331,8 @@ var schemaVisitorTransaction = import_joi36.default.object({
|
|
|
13331
13331
|
checkInRemarks: import_joi36.default.string().optional().allow("", null),
|
|
13332
13332
|
checkOutRemarks: import_joi36.default.string().optional().allow("", null),
|
|
13333
13333
|
expectedCheckIn: import_joi36.default.string().isoDate().optional(),
|
|
13334
|
-
purpose: import_joi36.default.string().optional().allow(null, "")
|
|
13334
|
+
purpose: import_joi36.default.string().optional().allow(null, ""),
|
|
13335
|
+
invitedId: import_joi36.default.any().optional().allow(null, "")
|
|
13335
13336
|
});
|
|
13336
13337
|
var schemaUpdateVisTrans = import_joi36.default.object({
|
|
13337
13338
|
_id: import_joi36.default.string().hex().length(24).required(),
|
|
@@ -13360,12 +13361,16 @@ var schemaUpdateVisTrans = import_joi36.default.object({
|
|
|
13360
13361
|
expiredAt: import_joi36.default.date().iso().optional().allow(null, ""),
|
|
13361
13362
|
visitorPass: import_joi36.default.array().items(
|
|
13362
13363
|
import_joi36.default.object({
|
|
13363
|
-
keyId: import_joi36.default.string().hex().length(24).required()
|
|
13364
|
+
keyId: import_joi36.default.string().hex().length(24).required(),
|
|
13365
|
+
status: import_joi36.default.string().optional().allow(null, ""),
|
|
13366
|
+
remarks: import_joi36.default.string().optional().allow(null, "")
|
|
13364
13367
|
})
|
|
13365
13368
|
).optional().allow(null),
|
|
13366
13369
|
passKeys: import_joi36.default.array().items(
|
|
13367
13370
|
import_joi36.default.object({
|
|
13368
|
-
keyId: import_joi36.default.string().hex().length(24).required()
|
|
13371
|
+
keyId: import_joi36.default.string().hex().length(24).required(),
|
|
13372
|
+
status: import_joi36.default.string().optional().allow(null, ""),
|
|
13373
|
+
remarks: import_joi36.default.string().optional().allow(null, "")
|
|
13369
13374
|
})
|
|
13370
13375
|
).optional().allow(null),
|
|
13371
13376
|
checkInRemarks: import_joi36.default.string().optional().allow("", null),
|
|
@@ -13471,7 +13476,17 @@ function MVisitorTransaction(value) {
|
|
|
13471
13476
|
expiredAt: value.expiredAt ?? null,
|
|
13472
13477
|
createdAt: value.createdAt ?? newDate,
|
|
13473
13478
|
updatedAt: value.updatedAt ?? "",
|
|
13474
|
-
deletedAt: value.deletedAt ?? ""
|
|
13479
|
+
deletedAt: value.deletedAt ?? "",
|
|
13480
|
+
purpose: value.purpose,
|
|
13481
|
+
numberOfPassengers: value.numberOfPassengers ?? null,
|
|
13482
|
+
email: value.email,
|
|
13483
|
+
isOvernightParking: value.isOvernightParking ?? false,
|
|
13484
|
+
invitedId: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null,
|
|
13485
|
+
overnightParking: value.isOvernightParking == true ? {
|
|
13486
|
+
status: "pending approval",
|
|
13487
|
+
remarks: "",
|
|
13488
|
+
updatedBy: new import_mongodb39.ObjectId(String(value.invitedId)) ?? null
|
|
13489
|
+
} : null
|
|
13475
13490
|
};
|
|
13476
13491
|
}
|
|
13477
13492
|
|
|
@@ -13603,16 +13618,40 @@ function useVisitorTransactionRepo() {
|
|
|
13603
13618
|
localField: "visitorPass.keyId",
|
|
13604
13619
|
foreignField: "_id",
|
|
13605
13620
|
pipeline: [
|
|
13621
|
+
{
|
|
13622
|
+
$lookup: {
|
|
13623
|
+
from: "qr-code-templates",
|
|
13624
|
+
localField: "template",
|
|
13625
|
+
foreignField: "_id",
|
|
13626
|
+
pipeline: [
|
|
13627
|
+
{
|
|
13628
|
+
$project: {
|
|
13629
|
+
_id: 1,
|
|
13630
|
+
prefixPass: 1,
|
|
13631
|
+
name: 1
|
|
13632
|
+
}
|
|
13633
|
+
}
|
|
13634
|
+
],
|
|
13635
|
+
as: "template"
|
|
13636
|
+
}
|
|
13637
|
+
},
|
|
13606
13638
|
{
|
|
13607
13639
|
$project: {
|
|
13608
13640
|
_id: 0,
|
|
13609
|
-
// remove original _id
|
|
13610
13641
|
keyId: "$_id",
|
|
13611
13642
|
status: 1,
|
|
13612
13643
|
description: 1,
|
|
13644
|
+
templatePrefixPass: {
|
|
13645
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13646
|
+
},
|
|
13613
13647
|
prefixAndName: {
|
|
13614
13648
|
$concat: [
|
|
13615
|
-
{
|
|
13649
|
+
{
|
|
13650
|
+
$ifNull: [
|
|
13651
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13652
|
+
""
|
|
13653
|
+
]
|
|
13654
|
+
},
|
|
13616
13655
|
{ $ifNull: ["$name", ""] }
|
|
13617
13656
|
]
|
|
13618
13657
|
}
|
|
@@ -13625,145 +13664,50 @@ function useVisitorTransactionRepo() {
|
|
|
13625
13664
|
{
|
|
13626
13665
|
$lookup: {
|
|
13627
13666
|
from: "keys",
|
|
13628
|
-
localField: "
|
|
13667
|
+
localField: "passKeys.keyId",
|
|
13629
13668
|
foreignField: "_id",
|
|
13630
13669
|
pipeline: [
|
|
13631
13670
|
{
|
|
13632
|
-
$
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
as: "visitorPassDetails"
|
|
13643
|
-
}
|
|
13644
|
-
},
|
|
13645
|
-
{
|
|
13646
|
-
$addFields: {
|
|
13647
|
-
visitorPass: {
|
|
13648
|
-
$map: {
|
|
13649
|
-
input: "$visitorPass",
|
|
13650
|
-
as: "vp",
|
|
13651
|
-
in: {
|
|
13652
|
-
$let: {
|
|
13653
|
-
vars: {
|
|
13654
|
-
matchedKey: {
|
|
13655
|
-
$arrayElemAt: [
|
|
13656
|
-
{
|
|
13657
|
-
$filter: {
|
|
13658
|
-
input: "$visitorPassDetails",
|
|
13659
|
-
as: "kd",
|
|
13660
|
-
cond: { $eq: ["$$kd._id", "$$vp.keyId"] }
|
|
13661
|
-
}
|
|
13662
|
-
},
|
|
13663
|
-
0
|
|
13664
|
-
]
|
|
13665
|
-
}
|
|
13666
|
-
},
|
|
13667
|
-
in: {
|
|
13668
|
-
keyId: "$$vp.keyId",
|
|
13669
|
-
receivedDate: "$$vp.receivedDate",
|
|
13670
|
-
status: "$$vp.status",
|
|
13671
|
-
lastUpdate: {
|
|
13672
|
-
$max: [
|
|
13673
|
-
"$$matchedKey.createdAt",
|
|
13674
|
-
"$$matchedKey.updatedAt"
|
|
13675
|
-
]
|
|
13676
|
-
},
|
|
13677
|
-
remarks: "$$vp.remarks",
|
|
13678
|
-
description: "$$matchedKey.description",
|
|
13679
|
-
prefixAndName: {
|
|
13680
|
-
$concat: [
|
|
13681
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13682
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13683
|
-
]
|
|
13671
|
+
$lookup: {
|
|
13672
|
+
from: "qr-code-templates",
|
|
13673
|
+
localField: "template",
|
|
13674
|
+
foreignField: "_id",
|
|
13675
|
+
pipeline: [
|
|
13676
|
+
{
|
|
13677
|
+
$project: {
|
|
13678
|
+
_id: 1,
|
|
13679
|
+
prefixPass: 1,
|
|
13680
|
+
name: 1
|
|
13684
13681
|
}
|
|
13685
13682
|
}
|
|
13686
|
-
|
|
13683
|
+
],
|
|
13684
|
+
as: "template"
|
|
13687
13685
|
}
|
|
13688
|
-
}
|
|
13689
|
-
}
|
|
13690
|
-
}
|
|
13691
|
-
},
|
|
13692
|
-
{
|
|
13693
|
-
$project: {
|
|
13694
|
-
visitorPassDetails: 0
|
|
13695
|
-
}
|
|
13696
|
-
},
|
|
13697
|
-
{
|
|
13698
|
-
$lookup: {
|
|
13699
|
-
from: "keys",
|
|
13700
|
-
localField: "passKeys.keyId",
|
|
13701
|
-
foreignField: "_id",
|
|
13702
|
-
pipeline: [
|
|
13686
|
+
},
|
|
13703
13687
|
{
|
|
13704
13688
|
$project: {
|
|
13705
|
-
_id:
|
|
13706
|
-
|
|
13707
|
-
|
|
13689
|
+
_id: 0,
|
|
13690
|
+
keyId: "$_id",
|
|
13691
|
+
status: 1,
|
|
13708
13692
|
description: 1,
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
$addFields: {
|
|
13719
|
-
passKeys: {
|
|
13720
|
-
$map: {
|
|
13721
|
-
input: "$passKeys",
|
|
13722
|
-
as: "pk",
|
|
13723
|
-
in: {
|
|
13724
|
-
$let: {
|
|
13725
|
-
vars: {
|
|
13726
|
-
matchedKey: {
|
|
13727
|
-
$arrayElemAt: [
|
|
13728
|
-
{
|
|
13729
|
-
$filter: {
|
|
13730
|
-
input: "$passKeysDetails",
|
|
13731
|
-
as: "kd",
|
|
13732
|
-
cond: { $eq: ["$$kd._id", "$$pk.keyId"] }
|
|
13733
|
-
}
|
|
13734
|
-
},
|
|
13735
|
-
0
|
|
13736
|
-
]
|
|
13737
|
-
}
|
|
13738
|
-
},
|
|
13739
|
-
in: {
|
|
13740
|
-
keyId: "$$pk.keyId",
|
|
13741
|
-
receivedDate: "$$pk.receivedDate",
|
|
13742
|
-
status: "$$pk.status",
|
|
13743
|
-
lastUpdate: {
|
|
13744
|
-
$max: [
|
|
13745
|
-
"$$matchedKey.createdAt",
|
|
13746
|
-
"$$matchedKey.updatedAt"
|
|
13693
|
+
templatePrefixPass: {
|
|
13694
|
+
$arrayElemAt: ["$template.prefixPass", 0]
|
|
13695
|
+
},
|
|
13696
|
+
prefixAndName: {
|
|
13697
|
+
$concat: [
|
|
13698
|
+
{
|
|
13699
|
+
$ifNull: [
|
|
13700
|
+
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
13701
|
+
""
|
|
13747
13702
|
]
|
|
13748
13703
|
},
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
prefixAndName: {
|
|
13752
|
-
$concat: [
|
|
13753
|
-
{ $ifNull: ["$$matchedKey.prefix", ""] },
|
|
13754
|
-
{ $ifNull: ["$$matchedKey.name", ""] }
|
|
13755
|
-
]
|
|
13756
|
-
}
|
|
13757
|
-
}
|
|
13704
|
+
{ $ifNull: ["$name", ""] }
|
|
13705
|
+
]
|
|
13758
13706
|
}
|
|
13759
13707
|
}
|
|
13760
13708
|
}
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
},
|
|
13764
|
-
{
|
|
13765
|
-
$project: {
|
|
13766
|
-
passKeysDetails: 0
|
|
13709
|
+
],
|
|
13710
|
+
as: "passKeys"
|
|
13767
13711
|
}
|
|
13768
13712
|
},
|
|
13769
13713
|
{ $sort: sort },
|
|
@@ -21700,8 +21644,8 @@ var KeyRepo = class {
|
|
|
21700
21644
|
static async updateKeyById(keyId, key, site, session, isChild) {
|
|
21701
21645
|
try {
|
|
21702
21646
|
keyId = new import_mongodb57.ObjectId(keyId);
|
|
21703
|
-
|
|
21704
|
-
|
|
21647
|
+
if (site)
|
|
21648
|
+
site = new import_mongodb57.ObjectId(site);
|
|
21705
21649
|
if (key.updatedBy)
|
|
21706
21650
|
key.updatedBy = await convertObjectIdUtil(key.updatedBy);
|
|
21707
21651
|
if (!key.status)
|
|
@@ -21711,7 +21655,8 @@ var KeyRepo = class {
|
|
|
21711
21655
|
}
|
|
21712
21656
|
try {
|
|
21713
21657
|
key.updatedAt = /* @__PURE__ */ new Date();
|
|
21714
|
-
|
|
21658
|
+
const query = { _id: keyId, ...site && { site } };
|
|
21659
|
+
let find = query;
|
|
21715
21660
|
if (isChild)
|
|
21716
21661
|
find = { parentId: keyId, site };
|
|
21717
21662
|
const result = await this.collection().updateMany(
|
|
@@ -21771,6 +21716,7 @@ function useVisitorTransactionService() {
|
|
|
21771
21716
|
getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
|
|
21772
21717
|
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
|
|
21773
21718
|
} = useVisitorTransactionRepo();
|
|
21719
|
+
const { getById } = useBuildingUnitRepo();
|
|
21774
21720
|
const {
|
|
21775
21721
|
add: _addPerson,
|
|
21776
21722
|
getByNRIC,
|
|
@@ -21863,7 +21809,7 @@ function useVisitorTransactionService() {
|
|
|
21863
21809
|
if (member.visitorPass && Array.isArray(member.visitorPass) && member.visitorPass.length > 0) {
|
|
21864
21810
|
for (const vp of member.visitorPass) {
|
|
21865
21811
|
try {
|
|
21866
|
-
const updatePayload = { status: "
|
|
21812
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21867
21813
|
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
|
|
21868
21814
|
await KeyRepo.updateKeyById(
|
|
21869
21815
|
visitorPassId,
|
|
@@ -21878,7 +21824,7 @@ function useVisitorTransactionService() {
|
|
|
21878
21824
|
if (member.passKeys && Array.isArray(member.passKeys) && member.passKeys.length > 0) {
|
|
21879
21825
|
for (const pk of member.passKeys) {
|
|
21880
21826
|
try {
|
|
21881
|
-
const updatePayload = { status: "
|
|
21827
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21882
21828
|
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
|
|
21883
21829
|
await KeyRepo.updateKeyById(
|
|
21884
21830
|
passKeyId,
|
|
@@ -21994,7 +21940,7 @@ function useVisitorTransactionService() {
|
|
|
21994
21940
|
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
21995
21941
|
for (const vp of value.visitorPass) {
|
|
21996
21942
|
try {
|
|
21997
|
-
const updatePayload = { status: "
|
|
21943
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21998
21944
|
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
|
|
21999
21945
|
await KeyRepo.updateKeyById(
|
|
22000
21946
|
visitorPassId,
|
|
@@ -22009,7 +21955,7 @@ function useVisitorTransactionService() {
|
|
|
22009
21955
|
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
22010
21956
|
for (const pk of value.passKeys) {
|
|
22011
21957
|
try {
|
|
22012
|
-
const updatePayload = { status: "
|
|
21958
|
+
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
22013
21959
|
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
|
|
22014
21960
|
await KeyRepo.updateKeyById(
|
|
22015
21961
|
passKeyId,
|
|
@@ -22035,6 +21981,52 @@ function useVisitorTransactionService() {
|
|
|
22035
21981
|
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
22036
21982
|
session?.startTransaction();
|
|
22037
21983
|
try {
|
|
21984
|
+
if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
21985
|
+
const keptVisitorPass = [];
|
|
21986
|
+
for (const vp of value.visitorPass) {
|
|
21987
|
+
const updatePayload = {
|
|
21988
|
+
...vp.status && { status: vp.status },
|
|
21989
|
+
...vp.remarks && { remarks: vp.remarks }
|
|
21990
|
+
};
|
|
21991
|
+
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
|
|
21992
|
+
await KeyRepo.updateKeyById(
|
|
21993
|
+
visitorPassId,
|
|
21994
|
+
updatePayload,
|
|
21995
|
+
value.site
|
|
21996
|
+
);
|
|
21997
|
+
if (typeof vp !== "string" && !(vp instanceof import_mongodb58.ObjectId)) {
|
|
21998
|
+
keptVisitorPass.push({
|
|
21999
|
+
keyId: new import_mongodb58.ObjectId(visitorPassId)
|
|
22000
|
+
});
|
|
22001
|
+
}
|
|
22002
|
+
}
|
|
22003
|
+
value.visitorPass = keptVisitorPass;
|
|
22004
|
+
}
|
|
22005
|
+
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
22006
|
+
const keptPassKeys = [];
|
|
22007
|
+
for (const pk of value.passKeys) {
|
|
22008
|
+
try {
|
|
22009
|
+
const updatePayload = {
|
|
22010
|
+
...pk.status && { status: pk.status },
|
|
22011
|
+
...pk.remarks && { remarks: pk.remarks }
|
|
22012
|
+
};
|
|
22013
|
+
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
|
|
22014
|
+
await KeyRepo.updateKeyById(
|
|
22015
|
+
passKeyId,
|
|
22016
|
+
updatePayload,
|
|
22017
|
+
value.site
|
|
22018
|
+
);
|
|
22019
|
+
if (typeof pk !== "string" && !(pk instanceof import_mongodb58.ObjectId)) {
|
|
22020
|
+
keptPassKeys.push({
|
|
22021
|
+
keyId: new import_mongodb58.ObjectId(passKeyId)
|
|
22022
|
+
});
|
|
22023
|
+
}
|
|
22024
|
+
} catch (error) {
|
|
22025
|
+
throw error;
|
|
22026
|
+
}
|
|
22027
|
+
}
|
|
22028
|
+
value.passKeys = keptPassKeys;
|
|
22029
|
+
}
|
|
22038
22030
|
await _updateVisitorTansactionById(id, value, session);
|
|
22039
22031
|
await session?.commitTransaction();
|
|
22040
22032
|
return "Successfully updated visitor transaction.";
|
|
@@ -22123,6 +22115,7 @@ function useVisitorTransactionService() {
|
|
|
22123
22115
|
try {
|
|
22124
22116
|
session.startTransaction();
|
|
22125
22117
|
const inviter = await _getByUserId(userId);
|
|
22118
|
+
const unit = await getById(inviter?.unit);
|
|
22126
22119
|
value.checkIn = null;
|
|
22127
22120
|
const dir = __dirname;
|
|
22128
22121
|
const filePath = (0, import_node_server_utils101.getDirectory)(dir, "./public/handlebars/visitor-invite");
|
|
@@ -22131,9 +22124,11 @@ function useVisitorTransactionService() {
|
|
|
22131
22124
|
block: inviter?.block,
|
|
22132
22125
|
level: inviter?.level,
|
|
22133
22126
|
unit: inviter?.unit,
|
|
22127
|
+
unitName: unit?.name,
|
|
22134
22128
|
org: inviter?.org.toString(),
|
|
22135
22129
|
site: inviter?.site.toString(),
|
|
22136
|
-
status: "pending" /* PENDING
|
|
22130
|
+
status: "pending" /* PENDING */,
|
|
22131
|
+
invitedId: inviter?._id
|
|
22137
22132
|
};
|
|
22138
22133
|
const result = await _add(payload);
|
|
22139
22134
|
const emailContent = (0, import_node_server_utils101.compileHandlebar)({
|
|
@@ -22356,7 +22351,7 @@ function useVisitorTransactionController() {
|
|
|
22356
22351
|
arrivalTime: import_joi55.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
22357
22352
|
"string.pattern.base": "arrivalTime must be in HH:mm format (e.g. 09:30, 18:45)"
|
|
22358
22353
|
}),
|
|
22359
|
-
duration: import_joi55.default.number().integer().optional().allow(null),
|
|
22354
|
+
duration: import_joi55.default.number().integer().optional().allow(null, ""),
|
|
22360
22355
|
name: import_joi55.default.string().required(),
|
|
22361
22356
|
contact: import_joi55.default.string().required(),
|
|
22362
22357
|
email: import_joi55.default.string().email().required(),
|
|
@@ -22379,8 +22374,8 @@ function useVisitorTransactionController() {
|
|
|
22379
22374
|
const { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose, inviterUserId } = value;
|
|
22380
22375
|
const rest = { expectedCheckIn, arrivalTime, duration, name, contact, email, plateNumber, isOvernightParking, numberOfPassengers, purpose };
|
|
22381
22376
|
try {
|
|
22382
|
-
await _inviteVisitor(rest, inviterUserId);
|
|
22383
|
-
res.status(200).json({
|
|
22377
|
+
const result = await _inviteVisitor(rest, inviterUserId);
|
|
22378
|
+
res.status(200).json({ insertedId: result });
|
|
22384
22379
|
return;
|
|
22385
22380
|
} catch (error2) {
|
|
22386
22381
|
import_node_server_utils102.logger.log({ level: "error", message: error2.message });
|
|
@@ -23013,7 +23008,8 @@ function usePersonController() {
|
|
|
23013
23008
|
getPeopleByUnit: _getPeopleByUnit,
|
|
23014
23009
|
getCompany: _getCompany,
|
|
23015
23010
|
getPeopleByPlateNumber: _getPeopleByPlateNumber,
|
|
23016
|
-
getPeopleByNRIC: _getPeopleByNRIC
|
|
23011
|
+
getPeopleByNRIC: _getPeopleByNRIC,
|
|
23012
|
+
getByUserId: _getByUserId
|
|
23017
23013
|
} = usePersonRepo();
|
|
23018
23014
|
const { add: _add, updateById: _updateById } = usePersonService();
|
|
23019
23015
|
async function add(req, res, next) {
|
|
@@ -23312,6 +23308,25 @@ function usePersonController() {
|
|
|
23312
23308
|
return;
|
|
23313
23309
|
}
|
|
23314
23310
|
}
|
|
23311
|
+
async function getPersonByUserId(req, res, next) {
|
|
23312
|
+
const validation = import_joi58.default.string().required();
|
|
23313
|
+
const userId = req.params.userId;
|
|
23314
|
+
const { error } = validation.validate(userId);
|
|
23315
|
+
if (error) {
|
|
23316
|
+
import_node_server_utils107.logger.log({ level: "error", message: error.message });
|
|
23317
|
+
next(new import_node_server_utils107.BadRequestError(error.message));
|
|
23318
|
+
return;
|
|
23319
|
+
}
|
|
23320
|
+
try {
|
|
23321
|
+
const data = await _getByUserId(userId);
|
|
23322
|
+
res.json(data);
|
|
23323
|
+
return;
|
|
23324
|
+
} catch (error2) {
|
|
23325
|
+
import_node_server_utils107.logger.log({ level: "error", message: error2.message });
|
|
23326
|
+
next(error2);
|
|
23327
|
+
return;
|
|
23328
|
+
}
|
|
23329
|
+
}
|
|
23315
23330
|
return {
|
|
23316
23331
|
add,
|
|
23317
23332
|
getAll,
|
|
@@ -23322,7 +23337,8 @@ function usePersonController() {
|
|
|
23322
23337
|
getPeopleByUnit,
|
|
23323
23338
|
getCompany,
|
|
23324
23339
|
getPeopleByPlateNumber,
|
|
23325
|
-
getPeopleByNRIC
|
|
23340
|
+
getPeopleByNRIC,
|
|
23341
|
+
getPersonByUserId
|
|
23326
23342
|
};
|
|
23327
23343
|
}
|
|
23328
23344
|
|
|
@@ -30875,6 +30891,95 @@ function useSiteUnitBillingRepo() {
|
|
|
30875
30891
|
throw error;
|
|
30876
30892
|
}
|
|
30877
30893
|
}
|
|
30894
|
+
async function getResidentUserBilling({
|
|
30895
|
+
search = "",
|
|
30896
|
+
page = 1,
|
|
30897
|
+
limit = 10,
|
|
30898
|
+
sort = {},
|
|
30899
|
+
status = "active",
|
|
30900
|
+
site = "",
|
|
30901
|
+
paymentStatus = "awaiting_payment",
|
|
30902
|
+
month,
|
|
30903
|
+
year,
|
|
30904
|
+
unitId
|
|
30905
|
+
}, session) {
|
|
30906
|
+
page = page > 0 ? page - 1 : 0;
|
|
30907
|
+
let dateExpr = {};
|
|
30908
|
+
if (month && year) {
|
|
30909
|
+
const monthNum = parseInt(month, 10);
|
|
30910
|
+
const yearNum = parseInt(year, 10);
|
|
30911
|
+
const startDate = new Date(yearNum, monthNum - 1, 1);
|
|
30912
|
+
const endDate = new Date(yearNum, monthNum, 1);
|
|
30913
|
+
dateExpr.createdAt = {
|
|
30914
|
+
$gte: startDate,
|
|
30915
|
+
$lt: endDate
|
|
30916
|
+
};
|
|
30917
|
+
}
|
|
30918
|
+
const unitSearchRegex = search ? search.trim().replace(/\s+/g, "").replace(/\//g, "\\s*/\\s*") : null;
|
|
30919
|
+
const query = {
|
|
30920
|
+
paymentStatus,
|
|
30921
|
+
status,
|
|
30922
|
+
...search && {
|
|
30923
|
+
$or: [
|
|
30924
|
+
{ unitOwner: { $regex: search, $options: "i" } },
|
|
30925
|
+
{ billName: { $regex: search, $options: "i" } },
|
|
30926
|
+
{ unit: { $regex: unitSearchRegex, $options: "i" } },
|
|
30927
|
+
{
|
|
30928
|
+
$expr: {
|
|
30929
|
+
$regexMatch: {
|
|
30930
|
+
input: { $toString: "$amountPaid" },
|
|
30931
|
+
regex: search,
|
|
30932
|
+
options: "i"
|
|
30933
|
+
}
|
|
30934
|
+
}
|
|
30935
|
+
}
|
|
30936
|
+
]
|
|
30937
|
+
},
|
|
30938
|
+
...import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) },
|
|
30939
|
+
...dateExpr,
|
|
30940
|
+
...import_mongodb86.ObjectId.isValid(unitId) && { unitId: new import_mongodb86.ObjectId(unitId) }
|
|
30941
|
+
};
|
|
30942
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
30943
|
+
try {
|
|
30944
|
+
const basePipeline = [
|
|
30945
|
+
{ $match: query },
|
|
30946
|
+
{ $sort: sort },
|
|
30947
|
+
{ $skip: page * limit },
|
|
30948
|
+
{ $limit: limit },
|
|
30949
|
+
{
|
|
30950
|
+
$lookup: {
|
|
30951
|
+
from: "site.billing.items",
|
|
30952
|
+
localField: "billItem",
|
|
30953
|
+
foreignField: "_id",
|
|
30954
|
+
pipeline: [
|
|
30955
|
+
{
|
|
30956
|
+
$project: {
|
|
30957
|
+
_id: 1,
|
|
30958
|
+
totalAmount: 1
|
|
30959
|
+
}
|
|
30960
|
+
}
|
|
30961
|
+
],
|
|
30962
|
+
as: "billDetails"
|
|
30963
|
+
}
|
|
30964
|
+
},
|
|
30965
|
+
{
|
|
30966
|
+
$unwind: {
|
|
30967
|
+
path: "$billDetails",
|
|
30968
|
+
preserveNullAndEmptyArrays: true
|
|
30969
|
+
}
|
|
30970
|
+
}
|
|
30971
|
+
];
|
|
30972
|
+
const [items, countResult] = await Promise.all([
|
|
30973
|
+
collection.aggregate(basePipeline, { session }).toArray(),
|
|
30974
|
+
collection.aggregate([{ $match: query }, { $count: "total" }], { session }).toArray()
|
|
30975
|
+
]);
|
|
30976
|
+
const totalCount = countResult[0]?.total || 0;
|
|
30977
|
+
const data = (0, import_node_server_utils149.paginate)(items, page, limit, totalCount);
|
|
30978
|
+
return data;
|
|
30979
|
+
} catch (error) {
|
|
30980
|
+
throw error;
|
|
30981
|
+
}
|
|
30982
|
+
}
|
|
30878
30983
|
function delCachedData() {
|
|
30879
30984
|
delNamespace().then(() => {
|
|
30880
30985
|
import_node_server_utils149.logger.log({
|
|
@@ -30906,7 +31011,8 @@ function useSiteUnitBillingRepo() {
|
|
|
30906
31011
|
getById,
|
|
30907
31012
|
updateById,
|
|
30908
31013
|
deleteById,
|
|
30909
|
-
getUnitBillingBySite
|
|
31014
|
+
getUnitBillingBySite,
|
|
31015
|
+
getResidentUserBilling
|
|
30910
31016
|
};
|
|
30911
31017
|
}
|
|
30912
31018
|
|
|
@@ -31093,7 +31199,8 @@ function useSiteUnitBillingController() {
|
|
|
31093
31199
|
getAll: _getAll,
|
|
31094
31200
|
updateById: _updateById,
|
|
31095
31201
|
deleteById: _deleteById,
|
|
31096
|
-
getById: _getById
|
|
31202
|
+
getById: _getById,
|
|
31203
|
+
getResidentUserBilling: _getResidentUserBilling
|
|
31097
31204
|
} = useSiteUnitBillingRepo();
|
|
31098
31205
|
async function add(req, res, next) {
|
|
31099
31206
|
const data = { ...req.body };
|
|
@@ -31234,12 +31341,64 @@ function useSiteUnitBillingController() {
|
|
|
31234
31341
|
return;
|
|
31235
31342
|
}
|
|
31236
31343
|
}
|
|
31344
|
+
async function getResidentUserBilling(req, res, next) {
|
|
31345
|
+
const validation = import_joi84.default.object({
|
|
31346
|
+
page: import_joi84.default.number().integer().min(1).allow("", null).default(1),
|
|
31347
|
+
limit: import_joi84.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
31348
|
+
status: import_joi84.default.string().optional().allow(null, ""),
|
|
31349
|
+
search: import_joi84.default.string().optional().allow(null, ""),
|
|
31350
|
+
site: import_joi84.default.string().required(),
|
|
31351
|
+
paymentStatus: import_joi84.default.string().optional().allow(null, ""),
|
|
31352
|
+
month: import_joi84.default.string().optional().allow(null, ""),
|
|
31353
|
+
year: import_joi84.default.string().optional().allow(null, ""),
|
|
31354
|
+
unitId: import_joi84.default.string().optional().allow(null, "")
|
|
31355
|
+
});
|
|
31356
|
+
const query = { ...req.query };
|
|
31357
|
+
const { error } = validation.validate(query, {
|
|
31358
|
+
abortEarly: false
|
|
31359
|
+
});
|
|
31360
|
+
if (error) {
|
|
31361
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
31362
|
+
import_node_server_utils151.logger.log({ level: "error", message: messages });
|
|
31363
|
+
next(new import_node_server_utils151.BadRequestError(messages));
|
|
31364
|
+
return;
|
|
31365
|
+
}
|
|
31366
|
+
const search = req.query.search ?? "";
|
|
31367
|
+
const page = parseInt(req.query.page ?? "1");
|
|
31368
|
+
const limit = parseInt(req.query.limit ?? "10");
|
|
31369
|
+
const status = req.query.status ?? "active";
|
|
31370
|
+
const site = req.query.site;
|
|
31371
|
+
const paymentStatus = req.query.paymentStatus ?? "awaiting_payment";
|
|
31372
|
+
const month = req.query.month ?? "";
|
|
31373
|
+
const year = req.query.year ?? "";
|
|
31374
|
+
const unitId = req.query.unitId ?? "";
|
|
31375
|
+
try {
|
|
31376
|
+
const data = await _getResidentUserBilling({
|
|
31377
|
+
search,
|
|
31378
|
+
page,
|
|
31379
|
+
limit,
|
|
31380
|
+
status,
|
|
31381
|
+
site,
|
|
31382
|
+
paymentStatus,
|
|
31383
|
+
month,
|
|
31384
|
+
year,
|
|
31385
|
+
unitId
|
|
31386
|
+
});
|
|
31387
|
+
res.status(200).json(data);
|
|
31388
|
+
return;
|
|
31389
|
+
} catch (error2) {
|
|
31390
|
+
import_node_server_utils151.logger.log({ level: "error", message: error2.message });
|
|
31391
|
+
next(error2);
|
|
31392
|
+
return;
|
|
31393
|
+
}
|
|
31394
|
+
}
|
|
31237
31395
|
return {
|
|
31238
31396
|
add,
|
|
31239
31397
|
getAll,
|
|
31240
31398
|
getById,
|
|
31241
31399
|
updateById,
|
|
31242
|
-
deleteById
|
|
31400
|
+
deleteById,
|
|
31401
|
+
getResidentUserBilling
|
|
31243
31402
|
};
|
|
31244
31403
|
}
|
|
31245
31404
|
|
|
@@ -39705,6 +39864,7 @@ function useNfcPatrolSettingsController() {
|
|
|
39705
39864
|
|
|
39706
39865
|
// src/services/occurrence-entry.service.ts
|
|
39707
39866
|
var import_node_server_utils184 = require("@7365admin1/node-server-utils");
|
|
39867
|
+
var import_mongodb108 = require("mongodb");
|
|
39708
39868
|
|
|
39709
39869
|
// src/repositories/occurrence-subject.repo.ts
|
|
39710
39870
|
var import_node_server_utils183 = require("@7365admin1/node-server-utils");
|
|
@@ -39913,22 +40073,11 @@ function useOccurrenceSubjectRepo() {
|
|
|
39913
40073
|
} catch (error) {
|
|
39914
40074
|
throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
|
|
39915
40075
|
}
|
|
39916
|
-
const cacheKey = (0, import_node_server_utils183.makeCacheKey)(namespace_collection, { _id });
|
|
39917
|
-
const cachedData = await getCache(cacheKey);
|
|
39918
|
-
if (cachedData) {
|
|
39919
|
-
import_node_server_utils183.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
39920
|
-
return cachedData;
|
|
39921
|
-
}
|
|
39922
40076
|
try {
|
|
39923
40077
|
const data = await collection.findOne({ _id }, { session });
|
|
39924
40078
|
if (!data) {
|
|
39925
40079
|
throw new import_node_server_utils183.NotFoundError("Occurrence subject not found.");
|
|
39926
40080
|
}
|
|
39927
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
39928
|
-
import_node_server_utils183.logger.info(`Cache set for key: ${cacheKey}`);
|
|
39929
|
-
}).catch((err) => {
|
|
39930
|
-
import_node_server_utils183.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
39931
|
-
});
|
|
39932
40081
|
return data;
|
|
39933
40082
|
} catch (error) {
|
|
39934
40083
|
throw error;
|
|
@@ -40069,11 +40218,22 @@ function useOccurrenceEntryService() {
|
|
|
40069
40218
|
const updatedSerialNumber = (entrySerialNumber + 0.1).toFixed(1);
|
|
40070
40219
|
const dobId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40071
40220
|
const book = await _getOccurrenceBookById(dobId);
|
|
40072
|
-
const subject = await _getOccurrenceSubjectById(
|
|
40221
|
+
const subject = await _getOccurrenceSubjectById(
|
|
40222
|
+
occurrenceEntry.subject._id
|
|
40223
|
+
);
|
|
40224
|
+
value.subject = value.subject ? value.subject : occurrenceEntry.subject._id;
|
|
40225
|
+
value.subjectName = subject.subject;
|
|
40073
40226
|
value.serialNumber = updatedSerialNumber;
|
|
40074
40227
|
value.site = occurrenceEntry.site;
|
|
40075
40228
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40076
|
-
value.
|
|
40229
|
+
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
40230
|
+
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
40231
|
+
value.signature = value.signature ? new import_mongodb108.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
40232
|
+
value.eSignature = value.eSignature ? new import_mongodb108.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
40233
|
+
value.createdAt = /* @__PURE__ */ new Date();
|
|
40234
|
+
value.date = /* @__PURE__ */ new Date();
|
|
40235
|
+
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
40236
|
+
value.createdByName = value.createdByName ? value.createdByName : occurrenceEntry.createdByName;
|
|
40077
40237
|
await _updateOccurrenceBookById(dobId, {
|
|
40078
40238
|
totalInput: book.totalInput + 1
|
|
40079
40239
|
});
|
|
@@ -40269,7 +40429,7 @@ function useOccurrenceEntryController() {
|
|
|
40269
40429
|
|
|
40270
40430
|
// src/models/online-form.model.ts
|
|
40271
40431
|
var import_joi105 = __toESM(require("joi"));
|
|
40272
|
-
var
|
|
40432
|
+
var import_mongodb109 = require("mongodb");
|
|
40273
40433
|
var schemaOnlineForm = import_joi105.default.object({
|
|
40274
40434
|
_id: import_joi105.default.string().hex().optional().allow("", null),
|
|
40275
40435
|
name: import_joi105.default.string().required(),
|
|
@@ -40317,21 +40477,21 @@ function MOnlineForm(value) {
|
|
|
40317
40477
|
}
|
|
40318
40478
|
if (value._id && typeof value._id === "string") {
|
|
40319
40479
|
try {
|
|
40320
|
-
value._id = new
|
|
40480
|
+
value._id = new import_mongodb109.ObjectId(value._id);
|
|
40321
40481
|
} catch (error2) {
|
|
40322
40482
|
throw new Error("Invalid ID.");
|
|
40323
40483
|
}
|
|
40324
40484
|
}
|
|
40325
40485
|
if (value.org && typeof value.org === "string") {
|
|
40326
40486
|
try {
|
|
40327
|
-
value.org = new
|
|
40487
|
+
value.org = new import_mongodb109.ObjectId(value.org);
|
|
40328
40488
|
} catch (error2) {
|
|
40329
40489
|
throw new Error("Invalid org ID.");
|
|
40330
40490
|
}
|
|
40331
40491
|
}
|
|
40332
40492
|
if (value.site && typeof value.site === "string") {
|
|
40333
40493
|
try {
|
|
40334
|
-
value.site = new
|
|
40494
|
+
value.site = new import_mongodb109.ObjectId(value.site);
|
|
40335
40495
|
} catch (error2) {
|
|
40336
40496
|
throw new Error("Invalid site ID.");
|
|
40337
40497
|
}
|
|
@@ -40354,7 +40514,7 @@ function MOnlineForm(value) {
|
|
|
40354
40514
|
|
|
40355
40515
|
// src/repositories/online-form.repo.ts
|
|
40356
40516
|
var import_node_server_utils186 = require("@7365admin1/node-server-utils");
|
|
40357
|
-
var
|
|
40517
|
+
var import_mongodb110 = require("mongodb");
|
|
40358
40518
|
function useOnlineFormRepo() {
|
|
40359
40519
|
const db = import_node_server_utils186.useAtlas.getDb();
|
|
40360
40520
|
if (!db) {
|
|
@@ -40406,7 +40566,7 @@ function useOnlineFormRepo() {
|
|
|
40406
40566
|
}) {
|
|
40407
40567
|
page = page > 0 ? page - 1 : 0;
|
|
40408
40568
|
try {
|
|
40409
|
-
site = new
|
|
40569
|
+
site = new import_mongodb110.ObjectId(site);
|
|
40410
40570
|
} catch (error) {
|
|
40411
40571
|
throw new import_node_server_utils186.BadRequestError("Invalid site ID format.");
|
|
40412
40572
|
}
|
|
@@ -40466,7 +40626,7 @@ function useOnlineFormRepo() {
|
|
|
40466
40626
|
}
|
|
40467
40627
|
async function getOnlineFormById(_id) {
|
|
40468
40628
|
try {
|
|
40469
|
-
_id = new
|
|
40629
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
40470
40630
|
} catch (error) {
|
|
40471
40631
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40472
40632
|
}
|
|
@@ -40509,7 +40669,7 @@ function useOnlineFormRepo() {
|
|
|
40509
40669
|
}
|
|
40510
40670
|
async function updateOnlineFormById(_id, value) {
|
|
40511
40671
|
try {
|
|
40512
|
-
_id = new
|
|
40672
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
40513
40673
|
} catch (error) {
|
|
40514
40674
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40515
40675
|
}
|
|
@@ -40537,7 +40697,7 @@ function useOnlineFormRepo() {
|
|
|
40537
40697
|
}
|
|
40538
40698
|
async function deleteOnlineFormById(_id, session) {
|
|
40539
40699
|
try {
|
|
40540
|
-
_id = new
|
|
40700
|
+
_id = new import_mongodb110.ObjectId(_id);
|
|
40541
40701
|
} catch (error) {
|
|
40542
40702
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40543
40703
|
}
|
|
@@ -40570,7 +40730,7 @@ function useOnlineFormRepo() {
|
|
|
40570
40730
|
}
|
|
40571
40731
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
40572
40732
|
try {
|
|
40573
|
-
site = new
|
|
40733
|
+
site = new import_mongodb110.ObjectId(site);
|
|
40574
40734
|
} catch (error) {
|
|
40575
40735
|
throw new import_node_server_utils186.BadRequestError(
|
|
40576
40736
|
"Invalid online form configuration site ID format."
|
|
@@ -41011,7 +41171,7 @@ function useOccurrenceSubjectController() {
|
|
|
41011
41171
|
}
|
|
41012
41172
|
|
|
41013
41173
|
// src/models/nfc-patrol-log.model.ts
|
|
41014
|
-
var
|
|
41174
|
+
var import_mongodb111 = require("mongodb");
|
|
41015
41175
|
var import_joi108 = __toESM(require("joi"));
|
|
41016
41176
|
var import_node_server_utils190 = require("@7365admin1/node-server-utils");
|
|
41017
41177
|
var schemaNfcPatrolLog = import_joi108.default.object({
|
|
@@ -41063,32 +41223,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41063
41223
|
}
|
|
41064
41224
|
if (value._id && typeof value._id === "string") {
|
|
41065
41225
|
try {
|
|
41066
|
-
value._id = new
|
|
41226
|
+
value._id = new import_mongodb111.ObjectId(value._id);
|
|
41067
41227
|
} catch (error2) {
|
|
41068
41228
|
throw new import_node_server_utils190.BadRequestError("Invalid _id format");
|
|
41069
41229
|
}
|
|
41070
41230
|
}
|
|
41071
41231
|
try {
|
|
41072
|
-
value.site = new
|
|
41232
|
+
value.site = new import_mongodb111.ObjectId(value.site);
|
|
41073
41233
|
} catch (error2) {
|
|
41074
41234
|
throw new import_node_server_utils190.BadRequestError("Invalid site format");
|
|
41075
41235
|
}
|
|
41076
41236
|
if (value?.createdBy) {
|
|
41077
41237
|
try {
|
|
41078
|
-
value.createdBy = new
|
|
41238
|
+
value.createdBy = new import_mongodb111.ObjectId(value.createdBy);
|
|
41079
41239
|
} catch (error2) {
|
|
41080
41240
|
throw new import_node_server_utils190.BadRequestError("Invalid createdBy format");
|
|
41081
41241
|
}
|
|
41082
41242
|
}
|
|
41083
41243
|
if (value?.route?._id) {
|
|
41084
41244
|
try {
|
|
41085
|
-
value.route._id = new
|
|
41245
|
+
value.route._id = new import_mongodb111.ObjectId(value.route._id);
|
|
41086
41246
|
} catch (error2) {
|
|
41087
41247
|
throw new import_node_server_utils190.BadRequestError("Invalid route _id format");
|
|
41088
41248
|
}
|
|
41089
41249
|
}
|
|
41090
41250
|
return {
|
|
41091
|
-
_id: value._id ?? new
|
|
41251
|
+
_id: value._id ?? new import_mongodb111.ObjectId(),
|
|
41092
41252
|
site: value.site,
|
|
41093
41253
|
route: value.route,
|
|
41094
41254
|
date: value.date,
|
|
@@ -41102,7 +41262,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41102
41262
|
|
|
41103
41263
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
41104
41264
|
var import_node_server_utils191 = require("@7365admin1/node-server-utils");
|
|
41105
|
-
var
|
|
41265
|
+
var import_mongodb112 = require("mongodb");
|
|
41106
41266
|
function useNfcPatrolLogRepo() {
|
|
41107
41267
|
const db = import_node_server_utils191.useAtlas.getDb();
|
|
41108
41268
|
if (!db) {
|
|
@@ -41155,7 +41315,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41155
41315
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
41156
41316
|
let siteId;
|
|
41157
41317
|
try {
|
|
41158
|
-
siteId = typeof site === "string" ? new
|
|
41318
|
+
siteId = typeof site === "string" ? new import_mongodb112.ObjectId(site) : site;
|
|
41159
41319
|
} catch {
|
|
41160
41320
|
throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
|
|
41161
41321
|
}
|
|
@@ -41166,7 +41326,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41166
41326
|
query.date = date;
|
|
41167
41327
|
}
|
|
41168
41328
|
if (route?._id) {
|
|
41169
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
41329
|
+
query["route._id"] = typeof route._id === "string" ? new import_mongodb112.ObjectId(route._id) : route._id;
|
|
41170
41330
|
}
|
|
41171
41331
|
if (route?.startTime) {
|
|
41172
41332
|
query["route.startTime"] = route.startTime;
|
|
@@ -42025,7 +42185,7 @@ function useNewDashboardController() {
|
|
|
42025
42185
|
|
|
42026
42186
|
// src/models/manpower-monitoring.model.ts
|
|
42027
42187
|
var import_joi111 = __toESM(require("joi"));
|
|
42028
|
-
var
|
|
42188
|
+
var import_mongodb113 = require("mongodb");
|
|
42029
42189
|
var shiftSchema = import_joi111.default.object({
|
|
42030
42190
|
name: import_joi111.default.string().required(),
|
|
42031
42191
|
checkIn: import_joi111.default.string().optional().allow("", null),
|
|
@@ -42050,7 +42210,7 @@ var manpowerMonitoringSchema = import_joi111.default.object({
|
|
|
42050
42210
|
});
|
|
42051
42211
|
var MManpowerMonitoring = class {
|
|
42052
42212
|
constructor(data) {
|
|
42053
|
-
this._id = new
|
|
42213
|
+
this._id = new import_mongodb113.ObjectId();
|
|
42054
42214
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42055
42215
|
this.siteId = data.siteId || "";
|
|
42056
42216
|
this.siteName = data.siteName;
|
|
@@ -42516,7 +42676,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
42516
42676
|
};
|
|
42517
42677
|
|
|
42518
42678
|
// src/repositories/manpower-monitoring.repo.ts
|
|
42519
|
-
var
|
|
42679
|
+
var import_mongodb114 = require("mongodb");
|
|
42520
42680
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
42521
42681
|
function useManpowerMonitoringRepo() {
|
|
42522
42682
|
const db = import_node_server_utils196.useAtlas.getDb();
|
|
@@ -42530,11 +42690,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42530
42690
|
try {
|
|
42531
42691
|
value = new MManpowerMonitoring(value);
|
|
42532
42692
|
if (value.createdBy)
|
|
42533
|
-
value.createdBy = new
|
|
42693
|
+
value.createdBy = new import_mongodb114.ObjectId(value.createdBy);
|
|
42534
42694
|
if (value.siteId)
|
|
42535
|
-
value.siteId = new
|
|
42695
|
+
value.siteId = new import_mongodb114.ObjectId(value.siteId);
|
|
42536
42696
|
if (value.serviceProviderId)
|
|
42537
|
-
value.serviceProviderId = new
|
|
42697
|
+
value.serviceProviderId = new import_mongodb114.ObjectId(value.serviceProviderId);
|
|
42538
42698
|
const result = await collection.insertOne(value, { session });
|
|
42539
42699
|
return result;
|
|
42540
42700
|
} catch (error) {
|
|
@@ -42575,8 +42735,8 @@ function useManpowerMonitoringRepo() {
|
|
|
42575
42735
|
}
|
|
42576
42736
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
42577
42737
|
try {
|
|
42578
|
-
_id = new
|
|
42579
|
-
serviceProviderId = new
|
|
42738
|
+
_id = new import_mongodb114.ObjectId(_id);
|
|
42739
|
+
serviceProviderId = new import_mongodb114.ObjectId(serviceProviderId);
|
|
42580
42740
|
} catch (error) {
|
|
42581
42741
|
throw new Error("Invalid Site ID format.");
|
|
42582
42742
|
}
|
|
@@ -42592,7 +42752,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42592
42752
|
}
|
|
42593
42753
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
42594
42754
|
try {
|
|
42595
|
-
_id = new
|
|
42755
|
+
_id = new import_mongodb114.ObjectId(_id);
|
|
42596
42756
|
} catch (error) {
|
|
42597
42757
|
throw new import_node_server_utils196.BadRequestError("Invalid ID format.");
|
|
42598
42758
|
}
|
|
@@ -42619,7 +42779,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42619
42779
|
for (let item of value) {
|
|
42620
42780
|
item = new MManpowerMonitoring(item);
|
|
42621
42781
|
const data = await collection.findOne({
|
|
42622
|
-
siteId: new
|
|
42782
|
+
siteId: new import_mongodb114.ObjectId(item.siteId)
|
|
42623
42783
|
});
|
|
42624
42784
|
if (data) {
|
|
42625
42785
|
let updateValue;
|
|
@@ -42644,11 +42804,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42644
42804
|
}
|
|
42645
42805
|
} else {
|
|
42646
42806
|
if (item.createdBy)
|
|
42647
|
-
item.createdBy = new
|
|
42807
|
+
item.createdBy = new import_mongodb114.ObjectId(item.createdBy);
|
|
42648
42808
|
if (item.siteId)
|
|
42649
|
-
item.siteId = new
|
|
42809
|
+
item.siteId = new import_mongodb114.ObjectId(item.siteId);
|
|
42650
42810
|
if (item.serviceProviderId)
|
|
42651
|
-
item.serviceProviderId = new
|
|
42811
|
+
item.serviceProviderId = new import_mongodb114.ObjectId(item.serviceProviderId);
|
|
42652
42812
|
const result = await collection.insertOne(item);
|
|
42653
42813
|
if (result.insertedId) {
|
|
42654
42814
|
results.inserted++;
|
|
@@ -42672,7 +42832,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42672
42832
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
42673
42833
|
try {
|
|
42674
42834
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
42675
|
-
_id: new
|
|
42835
|
+
_id: new import_mongodb114.ObjectId(serviceProviderId)
|
|
42676
42836
|
});
|
|
42677
42837
|
if (!serviceProvider) {
|
|
42678
42838
|
throw new Error("Service Provider not found.");
|
|
@@ -42714,7 +42874,7 @@ var import_node_server_utils197 = require("@7365admin1/node-server-utils");
|
|
|
42714
42874
|
|
|
42715
42875
|
// src/models/manpower-remarks.model.ts
|
|
42716
42876
|
var import_joi112 = __toESM(require("joi"));
|
|
42717
|
-
var
|
|
42877
|
+
var import_mongodb115 = require("mongodb");
|
|
42718
42878
|
var remarksSchema = import_joi112.default.object({
|
|
42719
42879
|
name: import_joi112.default.string().required(),
|
|
42720
42880
|
remark: import_joi112.default.object({
|
|
@@ -42738,7 +42898,7 @@ var manpowerRemarksSchema = import_joi112.default.object({
|
|
|
42738
42898
|
});
|
|
42739
42899
|
var MManpowerRemarks = class {
|
|
42740
42900
|
constructor(data) {
|
|
42741
|
-
this._id = new
|
|
42901
|
+
this._id = new import_mongodb115.ObjectId();
|
|
42742
42902
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42743
42903
|
this.siteId = data.siteId || "";
|
|
42744
42904
|
this.siteName = data.siteName || "";
|
|
@@ -42756,7 +42916,7 @@ var MManpowerRemarks = class {
|
|
|
42756
42916
|
};
|
|
42757
42917
|
|
|
42758
42918
|
// src/repositories/manpower-remarks.repo.ts
|
|
42759
|
-
var
|
|
42919
|
+
var import_mongodb116 = require("mongodb");
|
|
42760
42920
|
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
42761
42921
|
function useManpowerRemarksRepo() {
|
|
42762
42922
|
const db = import_node_server_utils197.useAtlas.getDb();
|
|
@@ -42769,9 +42929,9 @@ function useManpowerRemarksRepo() {
|
|
|
42769
42929
|
try {
|
|
42770
42930
|
value = new MManpowerRemarks(value);
|
|
42771
42931
|
if (value.siteId)
|
|
42772
|
-
value.siteId = new
|
|
42932
|
+
value.siteId = new import_mongodb116.ObjectId(value.siteId);
|
|
42773
42933
|
if (value.serviceProviderId)
|
|
42774
|
-
value.serviceProviderId = new
|
|
42934
|
+
value.serviceProviderId = new import_mongodb116.ObjectId(value.serviceProviderId);
|
|
42775
42935
|
const result = await collection.insertOne(value, { session });
|
|
42776
42936
|
return result;
|
|
42777
42937
|
} catch (error) {
|
|
@@ -42791,7 +42951,7 @@ function useManpowerRemarksRepo() {
|
|
|
42791
42951
|
limit = limit || 10;
|
|
42792
42952
|
const searchQuery = {};
|
|
42793
42953
|
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
42794
|
-
searchQuery.serviceProviderId = new
|
|
42954
|
+
searchQuery.serviceProviderId = new import_mongodb116.ObjectId(serviceProviderId);
|
|
42795
42955
|
if (search != "") {
|
|
42796
42956
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
42797
42957
|
}
|
|
@@ -42823,8 +42983,8 @@ function useManpowerRemarksRepo() {
|
|
|
42823
42983
|
}
|
|
42824
42984
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
42825
42985
|
try {
|
|
42826
|
-
_id = new
|
|
42827
|
-
serviceProviderId = new
|
|
42986
|
+
_id = new import_mongodb116.ObjectId(_id);
|
|
42987
|
+
serviceProviderId = new import_mongodb116.ObjectId(serviceProviderId);
|
|
42828
42988
|
} catch (error) {
|
|
42829
42989
|
throw new Error("Invalid Site ID format.");
|
|
42830
42990
|
}
|
|
@@ -42841,13 +43001,13 @@ function useManpowerRemarksRepo() {
|
|
|
42841
43001
|
}
|
|
42842
43002
|
async function updateManpowerRemarks(_id, value) {
|
|
42843
43003
|
try {
|
|
42844
|
-
_id = new
|
|
43004
|
+
_id = new import_mongodb116.ObjectId(_id);
|
|
42845
43005
|
} catch (error) {
|
|
42846
43006
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
42847
43007
|
}
|
|
42848
43008
|
try {
|
|
42849
43009
|
if (value.createdBy) {
|
|
42850
|
-
value.createdBy = new
|
|
43010
|
+
value.createdBy = new import_mongodb116.ObjectId(value.createdBy);
|
|
42851
43011
|
}
|
|
42852
43012
|
const updateValue = {
|
|
42853
43013
|
...value,
|
|
@@ -42864,7 +43024,7 @@ function useManpowerRemarksRepo() {
|
|
|
42864
43024
|
}
|
|
42865
43025
|
async function updateRemarksStatus(_id, value) {
|
|
42866
43026
|
try {
|
|
42867
|
-
_id = new
|
|
43027
|
+
_id = new import_mongodb116.ObjectId(_id);
|
|
42868
43028
|
} catch (error) {
|
|
42869
43029
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
42870
43030
|
}
|
|
@@ -43136,7 +43296,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
43136
43296
|
|
|
43137
43297
|
// src/models/manpower-designations.model.ts
|
|
43138
43298
|
var import_joi114 = __toESM(require("joi"));
|
|
43139
|
-
var
|
|
43299
|
+
var import_mongodb117 = require("mongodb");
|
|
43140
43300
|
var designationsSchema = import_joi114.default.object({
|
|
43141
43301
|
title: import_joi114.default.string().required(),
|
|
43142
43302
|
shifts: import_joi114.default.object({
|
|
@@ -43155,7 +43315,7 @@ var manpowerDesignationsSchema = import_joi114.default.object({
|
|
|
43155
43315
|
});
|
|
43156
43316
|
var MManpowerDesignations = class {
|
|
43157
43317
|
constructor(data) {
|
|
43158
|
-
this._id = new
|
|
43318
|
+
this._id = new import_mongodb117.ObjectId();
|
|
43159
43319
|
this.siteId = data.siteId || "";
|
|
43160
43320
|
this.siteName = data.siteName || "";
|
|
43161
43321
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -43169,7 +43329,7 @@ var MManpowerDesignations = class {
|
|
|
43169
43329
|
|
|
43170
43330
|
// src/repositories/manpower-designations.repo.ts
|
|
43171
43331
|
var import_node_server_utils200 = require("@7365admin1/node-server-utils");
|
|
43172
|
-
var
|
|
43332
|
+
var import_mongodb118 = require("mongodb");
|
|
43173
43333
|
function useManpowerDesignationRepo() {
|
|
43174
43334
|
const db = import_node_server_utils200.useAtlas.getDb();
|
|
43175
43335
|
if (!db) {
|
|
@@ -43181,11 +43341,11 @@ function useManpowerDesignationRepo() {
|
|
|
43181
43341
|
try {
|
|
43182
43342
|
value = new MManpowerDesignations(value);
|
|
43183
43343
|
if (value.createdBy)
|
|
43184
|
-
value.createdBy = new
|
|
43344
|
+
value.createdBy = new import_mongodb118.ObjectId(value.createdBy);
|
|
43185
43345
|
if (value.siteId)
|
|
43186
|
-
value.siteId = new
|
|
43346
|
+
value.siteId = new import_mongodb118.ObjectId(value.siteId);
|
|
43187
43347
|
if (value.serviceProviderId)
|
|
43188
|
-
value.serviceProviderId = new
|
|
43348
|
+
value.serviceProviderId = new import_mongodb118.ObjectId(value.serviceProviderId);
|
|
43189
43349
|
const result = await collection.insertOne(value);
|
|
43190
43350
|
return result;
|
|
43191
43351
|
} catch (error) {
|
|
@@ -43194,8 +43354,8 @@ function useManpowerDesignationRepo() {
|
|
|
43194
43354
|
}
|
|
43195
43355
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
43196
43356
|
try {
|
|
43197
|
-
_id = new
|
|
43198
|
-
serviceProviderId = new
|
|
43357
|
+
_id = new import_mongodb118.ObjectId(_id);
|
|
43358
|
+
serviceProviderId = new import_mongodb118.ObjectId(serviceProviderId);
|
|
43199
43359
|
} catch (error) {
|
|
43200
43360
|
throw new Error("Invalid Site ID format.");
|
|
43201
43361
|
}
|
|
@@ -43211,7 +43371,7 @@ function useManpowerDesignationRepo() {
|
|
|
43211
43371
|
}
|
|
43212
43372
|
async function updateManpowerDesignations(_id, value) {
|
|
43213
43373
|
try {
|
|
43214
|
-
_id = new
|
|
43374
|
+
_id = new import_mongodb118.ObjectId(_id);
|
|
43215
43375
|
} catch (error) {
|
|
43216
43376
|
throw new Error("Invalid ID format.");
|
|
43217
43377
|
}
|
|
@@ -43314,7 +43474,7 @@ function useManpowerDesignationCtrl() {
|
|
|
43314
43474
|
|
|
43315
43475
|
// src/models/overnight-parking.model.ts
|
|
43316
43476
|
var import_joi116 = __toESM(require("joi"));
|
|
43317
|
-
var
|
|
43477
|
+
var import_mongodb119 = require("mongodb");
|
|
43318
43478
|
var dayScheduleSchema = import_joi116.default.object({
|
|
43319
43479
|
isEnabled: import_joi116.default.boolean().required(),
|
|
43320
43480
|
startTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -43356,7 +43516,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
43356
43516
|
}
|
|
43357
43517
|
if (value.site && typeof value.site === "string") {
|
|
43358
43518
|
try {
|
|
43359
|
-
value.site = new
|
|
43519
|
+
value.site = new import_mongodb119.ObjectId(value.site);
|
|
43360
43520
|
} catch {
|
|
43361
43521
|
throw new Error("Invalid site ID.");
|
|
43362
43522
|
}
|
|
@@ -44961,7 +45121,7 @@ function useManpowerRemarkCtrl() {
|
|
|
44961
45121
|
|
|
44962
45122
|
// src/models/manpower-sites.model.ts
|
|
44963
45123
|
var import_joi122 = __toESM(require("joi"));
|
|
44964
|
-
var
|
|
45124
|
+
var import_mongodb120 = require("mongodb");
|
|
44965
45125
|
var manpowerSitesSchema = import_joi122.default.object({
|
|
44966
45126
|
id: import_joi122.default.string().hex().required(),
|
|
44967
45127
|
text: import_joi122.default.string().hex().optional().allow("", null),
|
|
@@ -44972,7 +45132,7 @@ var manpowerSitesSchema = import_joi122.default.object({
|
|
|
44972
45132
|
});
|
|
44973
45133
|
var MManpowerSites = class {
|
|
44974
45134
|
constructor(data) {
|
|
44975
|
-
this._id = new
|
|
45135
|
+
this._id = new import_mongodb120.ObjectId();
|
|
44976
45136
|
this.id = data.id || "";
|
|
44977
45137
|
this.text = data.text || "";
|
|
44978
45138
|
this.contractID = data.contractID || "";
|
|
@@ -45182,7 +45342,7 @@ function useManpowerSitesCtrl() {
|
|
|
45182
45342
|
|
|
45183
45343
|
// src/utils/cron.util.ts
|
|
45184
45344
|
var import_node_server_utils214 = require("@7365admin1/node-server-utils");
|
|
45185
|
-
var
|
|
45345
|
+
var import_mongodb121 = require("mongodb");
|
|
45186
45346
|
var import_moment_timezone4 = __toESM(require("moment-timezone"));
|
|
45187
45347
|
var createManpowerRemarksDaily = async () => {
|
|
45188
45348
|
const db = import_node_server_utils214.useAtlas.getDb();
|
|
@@ -45342,7 +45502,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
45342
45502
|
for (const id of updatedIds) {
|
|
45343
45503
|
const doc = await remarks.findOne({ _id: id });
|
|
45344
45504
|
const setting = await settings.findOne(
|
|
45345
|
-
{ siteId: new
|
|
45505
|
+
{ siteId: new import_mongodb121.ObjectId(doc?.siteId) },
|
|
45346
45506
|
{ projection: { emails: 1 } }
|
|
45347
45507
|
);
|
|
45348
45508
|
const payload = {
|
|
@@ -45428,7 +45588,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
45428
45588
|
for (const doc of docs) {
|
|
45429
45589
|
let shiftsToCheck = [];
|
|
45430
45590
|
const endShiftTime = await settings.findOne(
|
|
45431
|
-
{ siteId: new
|
|
45591
|
+
{ siteId: new import_mongodb121.ObjectId(doc.siteId) },
|
|
45432
45592
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45433
45593
|
);
|
|
45434
45594
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -45534,7 +45694,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
45534
45694
|
|
|
45535
45695
|
// src/events/manpower.event.ts
|
|
45536
45696
|
var import_node_server_utils215 = require("@7365admin1/node-server-utils");
|
|
45537
|
-
var
|
|
45697
|
+
var import_mongodb122 = require("mongodb");
|
|
45538
45698
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
45539
45699
|
async function manpowerEvents(io) {
|
|
45540
45700
|
let intervalId = null;
|
|
@@ -45560,7 +45720,7 @@ async function manpowerEvents(io) {
|
|
|
45560
45720
|
}).toArray();
|
|
45561
45721
|
for (const doc of docs) {
|
|
45562
45722
|
const siteSettings = await settings.findOne(
|
|
45563
|
-
{ siteId: new
|
|
45723
|
+
{ siteId: new import_mongodb122.ObjectId(doc.siteId), enabled: true },
|
|
45564
45724
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45565
45725
|
);
|
|
45566
45726
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -45679,7 +45839,7 @@ function genericSignature(params, secretKey) {
|
|
|
45679
45839
|
}
|
|
45680
45840
|
|
|
45681
45841
|
// src/repositories/reddot-payment.repository.ts
|
|
45682
|
-
var
|
|
45842
|
+
var import_mongodb126 = require("mongodb");
|
|
45683
45843
|
|
|
45684
45844
|
// src/utils/date-format.util.ts
|
|
45685
45845
|
var import_moment_timezone6 = __toESM(require("moment-timezone"));
|
|
@@ -45704,11 +45864,11 @@ function formatDateString(today, format, dateRange) {
|
|
|
45704
45864
|
}
|
|
45705
45865
|
|
|
45706
45866
|
// src/models/credit-card.model.ts
|
|
45707
|
-
var
|
|
45867
|
+
var import_mongodb123 = require("mongodb");
|
|
45708
45868
|
var MCardInfo = class {
|
|
45709
45869
|
// this is coming from RDP transaction
|
|
45710
45870
|
constructor({
|
|
45711
|
-
_id = new
|
|
45871
|
+
_id = new import_mongodb123.ObjectId(),
|
|
45712
45872
|
userId,
|
|
45713
45873
|
cardType,
|
|
45714
45874
|
cardNumber,
|
|
@@ -45743,11 +45903,11 @@ var MCardInfo = class {
|
|
|
45743
45903
|
};
|
|
45744
45904
|
|
|
45745
45905
|
// src/models/cart.model.ts
|
|
45746
|
-
var
|
|
45906
|
+
var import_mongodb124 = require("mongodb");
|
|
45747
45907
|
var MUnitBillings = class {
|
|
45748
45908
|
// transaction response messages
|
|
45749
45909
|
constructor({
|
|
45750
|
-
_id = new
|
|
45910
|
+
_id = new import_mongodb124.ObjectId(),
|
|
45751
45911
|
unit,
|
|
45752
45912
|
unitId,
|
|
45753
45913
|
unitBill,
|
|
@@ -45788,7 +45948,7 @@ var MUnitBillings = class {
|
|
|
45788
45948
|
};
|
|
45789
45949
|
|
|
45790
45950
|
// src/repositories/payment.repository.ts
|
|
45791
|
-
var
|
|
45951
|
+
var import_mongodb125 = require("mongodb");
|
|
45792
45952
|
var import_node_server_utils216 = require("@7365admin1/node-server-utils");
|
|
45793
45953
|
var PaymentBillRepo = () => {
|
|
45794
45954
|
const getDB2 = () => {
|
|
@@ -45822,7 +45982,7 @@ var PaymentBillRepo = () => {
|
|
|
45822
45982
|
if (unitBillInfo?.status === "Inactive" /* inactive */) {
|
|
45823
45983
|
throw new Error("This Bill is Inactive!");
|
|
45824
45984
|
}
|
|
45825
|
-
const billId = new
|
|
45985
|
+
const billId = new import_mongodb125.ObjectId(unitBillInfo?.billId);
|
|
45826
45986
|
const billInfo = await billCollection().findOne({ _id: billId });
|
|
45827
45987
|
if (!billInfo) {
|
|
45828
45988
|
throw new Error("Bill info not found");
|
|
@@ -45861,13 +46021,13 @@ var PaymentBillRepo = () => {
|
|
|
45861
46021
|
const saveCreditCardInfo = async (payload) => {
|
|
45862
46022
|
try {
|
|
45863
46023
|
if (payload.userId)
|
|
45864
|
-
payload.userId = new
|
|
46024
|
+
payload.userId = new import_mongodb125.ObjectId(payload.userId);
|
|
45865
46025
|
if (payload.site)
|
|
45866
|
-
payload.site = new
|
|
46026
|
+
payload.site = new import_mongodb125.ObjectId(payload.site);
|
|
45867
46027
|
if (payload.organization)
|
|
45868
|
-
payload.organization = new
|
|
46028
|
+
payload.organization = new import_mongodb125.ObjectId(payload.organization);
|
|
45869
46029
|
if (payload.createdBy)
|
|
45870
|
-
payload.createdBy = new
|
|
46030
|
+
payload.createdBy = new import_mongodb125.ObjectId(payload.createdBy);
|
|
45871
46031
|
const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
45872
46032
|
payload.createdAt = createdAt;
|
|
45873
46033
|
const result = await creditCollection().insertOne(new MCardInfo(payload));
|
|
@@ -45879,19 +46039,19 @@ var PaymentBillRepo = () => {
|
|
|
45879
46039
|
const checkOutUnitBills = async (payload) => {
|
|
45880
46040
|
try {
|
|
45881
46041
|
if (payload.unitId)
|
|
45882
|
-
payload.unitId = new
|
|
46042
|
+
payload.unitId = new import_mongodb125.ObjectId(payload.unitId);
|
|
45883
46043
|
if (payload.site)
|
|
45884
|
-
payload.site = new
|
|
46044
|
+
payload.site = new import_mongodb125.ObjectId(payload.site);
|
|
45885
46045
|
if (payload.organization)
|
|
45886
|
-
payload.organization = new
|
|
46046
|
+
payload.organization = new import_mongodb125.ObjectId(payload.organization);
|
|
45887
46047
|
payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
45888
46048
|
const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
|
|
45889
46049
|
const unitId = payload.unitId;
|
|
45890
46050
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
|
|
45891
46051
|
const unit = unitId?.toString().slice(-4);
|
|
45892
|
-
const newId = new
|
|
46052
|
+
const newId = new import_mongodb125.ObjectId(addToCart?.insertedId).toString().slice(-4);
|
|
45893
46053
|
const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
|
|
45894
|
-
const result = await cartCollection().findOneAndUpdate({ _id: new
|
|
46054
|
+
const result = await cartCollection().findOneAndUpdate({ _id: new import_mongodb125.ObjectId(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
|
|
45895
46055
|
return result;
|
|
45896
46056
|
} catch (error) {
|
|
45897
46057
|
throw new Error(error.message || error || "Server Internal Error");
|
|
@@ -45922,7 +46082,7 @@ var PaymentBillRepo = () => {
|
|
|
45922
46082
|
for (const ref of refNumber) {
|
|
45923
46083
|
const unitBillInfo = await collection().findOne({ referenceNumber: ref });
|
|
45924
46084
|
const billId = unitBillInfo?.billId;
|
|
45925
|
-
const billInfo = await billCollection().findOne({ _id: new
|
|
46085
|
+
const billInfo = await billCollection().findOne({ _id: new import_mongodb125.ObjectId(billId) });
|
|
45926
46086
|
const billAmount = billInfo?.price;
|
|
45927
46087
|
payload.updatedAt = updatedAt;
|
|
45928
46088
|
payload.amountPaid = billAmount;
|
|
@@ -46073,7 +46233,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46073
46233
|
throw new Error("Failed to Add Merchant Details");
|
|
46074
46234
|
}
|
|
46075
46235
|
const merchantId = merchant?.insertedId;
|
|
46076
|
-
const orgId = new
|
|
46236
|
+
const orgId = new import_mongodb126.ObjectId(_id);
|
|
46077
46237
|
const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
|
|
46078
46238
|
returnDocument: "after"
|
|
46079
46239
|
});
|
|
@@ -46102,7 +46262,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46102
46262
|
const getMerchantDetailsById = async (_id) => {
|
|
46103
46263
|
try {
|
|
46104
46264
|
if (_id)
|
|
46105
|
-
_id = new
|
|
46265
|
+
_id = new import_mongodb126.ObjectId(_id);
|
|
46106
46266
|
const result = await redDotMerchantCollection().aggregate([
|
|
46107
46267
|
{
|
|
46108
46268
|
$match: {
|
|
@@ -46357,7 +46517,7 @@ function useRedDotPaymentController() {
|
|
|
46357
46517
|
|
|
46358
46518
|
// src/repositories/verification-v2.repo.ts
|
|
46359
46519
|
var import_node_server_utils218 = require("@7365admin1/node-server-utils");
|
|
46360
|
-
var
|
|
46520
|
+
var import_mongodb127 = require("mongodb");
|
|
46361
46521
|
function useVerificationRepoV2() {
|
|
46362
46522
|
const db = import_node_server_utils218.useAtlas.getDb();
|
|
46363
46523
|
if (!db) {
|
|
@@ -46410,7 +46570,7 @@ function useVerificationRepoV2() {
|
|
|
46410
46570
|
}
|
|
46411
46571
|
async function updateVerificationStatusById(_id, status, session) {
|
|
46412
46572
|
try {
|
|
46413
|
-
_id = new
|
|
46573
|
+
_id = new import_mongodb127.ObjectId(_id);
|
|
46414
46574
|
} catch (error) {
|
|
46415
46575
|
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46416
46576
|
}
|
|
@@ -46962,7 +47122,7 @@ var import_node_server_utils222 = require("@7365admin1/node-server-utils");
|
|
|
46962
47122
|
var import_uuid2 = require("uuid");
|
|
46963
47123
|
|
|
46964
47124
|
// src/repositories/user-v2.repo.ts
|
|
46965
|
-
var
|
|
47125
|
+
var import_mongodb128 = require("mongodb");
|
|
46966
47126
|
var import_node_server_utils221 = require("@7365admin1/node-server-utils");
|
|
46967
47127
|
function useUserRepoV2() {
|
|
46968
47128
|
const { updateFeedbackCreatedByName } = useFeedbackRepo();
|
|
@@ -47163,7 +47323,7 @@ function useUserRepoV2() {
|
|
|
47163
47323
|
}
|
|
47164
47324
|
if (organization) {
|
|
47165
47325
|
try {
|
|
47166
|
-
query.defaultOrg = new
|
|
47326
|
+
query.defaultOrg = new import_mongodb128.ObjectId(organization);
|
|
47167
47327
|
cacheOptions.organization = organization.toString();
|
|
47168
47328
|
} catch (error) {
|
|
47169
47329
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID format.");
|
|
@@ -47302,13 +47462,13 @@ function useUserRepoV2() {
|
|
|
47302
47462
|
);
|
|
47303
47463
|
}
|
|
47304
47464
|
try {
|
|
47305
|
-
_id = new
|
|
47465
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
47306
47466
|
} catch (error) {
|
|
47307
47467
|
throw new import_node_server_utils221.BadRequestError("Invalid ID.");
|
|
47308
47468
|
}
|
|
47309
47469
|
if (field === "defaultOrg") {
|
|
47310
47470
|
try {
|
|
47311
|
-
value = new
|
|
47471
|
+
value = new import_mongodb128.ObjectId(value);
|
|
47312
47472
|
} catch (error) {
|
|
47313
47473
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID.");
|
|
47314
47474
|
}
|
|
@@ -47349,7 +47509,7 @@ function useUserRepoV2() {
|
|
|
47349
47509
|
year
|
|
47350
47510
|
}, session) {
|
|
47351
47511
|
try {
|
|
47352
|
-
_id = new
|
|
47512
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
47353
47513
|
} catch (error) {
|
|
47354
47514
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47355
47515
|
}
|
|
@@ -47379,7 +47539,7 @@ function useUserRepoV2() {
|
|
|
47379
47539
|
}
|
|
47380
47540
|
async function updatePassword({ _id, password }, session) {
|
|
47381
47541
|
try {
|
|
47382
|
-
_id = new
|
|
47542
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
47383
47543
|
} catch (error) {
|
|
47384
47544
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47385
47545
|
}
|