@7365admin1/core 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +261 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +261 -130
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2742,6 +2742,7 @@ declare function MPerson(value: TPerson): {
|
|
|
2742
2742
|
declare enum KeyStatus {
|
|
2743
2743
|
AVAILABLE = "Available",
|
|
2744
2744
|
RETURNED = "Returned",
|
|
2745
|
+
REMOVED = "Removed",
|
|
2745
2746
|
NOT_RETURNED = "Not Returned",
|
|
2746
2747
|
LOST = "Lost",
|
|
2747
2748
|
DAMAGED = "Damaged",
|
|
@@ -2765,6 +2766,7 @@ type TKeyRef = {
|
|
|
2765
2766
|
remarks?: string;
|
|
2766
2767
|
receivedDate?: Date;
|
|
2767
2768
|
lastUpdate?: Date | null;
|
|
2769
|
+
add?: boolean;
|
|
2768
2770
|
};
|
|
2769
2771
|
type TVisitorTransaction = {
|
|
2770
2772
|
_id?: ObjectId;
|
package/dist/index.js
CHANGED
|
@@ -21126,14 +21126,20 @@ var schemaUpdateVisTrans = import_joi37.default.object({
|
|
|
21126
21126
|
import_joi37.default.object({
|
|
21127
21127
|
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21128
21128
|
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21129
|
-
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21129
|
+
remarks: import_joi37.default.string().optional().allow(null, ""),
|
|
21130
|
+
receivedDate: import_joi37.default.string().optional().allow(null, ""),
|
|
21131
|
+
lastUpdate: import_joi37.default.string().optional().allow(null, ""),
|
|
21132
|
+
add: import_joi37.default.boolean().optional().allow(null, "")
|
|
21130
21133
|
})
|
|
21131
21134
|
).optional().allow(null),
|
|
21132
21135
|
passKeys: import_joi37.default.array().items(
|
|
21133
21136
|
import_joi37.default.object({
|
|
21134
21137
|
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21135
21138
|
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21136
|
-
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21139
|
+
remarks: import_joi37.default.string().optional().allow(null, ""),
|
|
21140
|
+
receivedDate: import_joi37.default.string().optional().allow(null, ""),
|
|
21141
|
+
lastUpdate: import_joi37.default.string().optional().allow(null, ""),
|
|
21142
|
+
add: import_joi37.default.boolean().optional().allow(null, "")
|
|
21137
21143
|
})
|
|
21138
21144
|
).optional().allow(null),
|
|
21139
21145
|
checkInRemarks: import_joi37.default.string().optional().allow("", null),
|
|
@@ -21315,6 +21321,15 @@ async function convertObjectIdUtil2(id, fieldName) {
|
|
|
21315
21321
|
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21316
21322
|
}
|
|
21317
21323
|
}
|
|
21324
|
+
function convertObjectIdUtilNonAsync(id, fieldName) {
|
|
21325
|
+
try {
|
|
21326
|
+
if (!id)
|
|
21327
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21328
|
+
return new import_mongodb40.ObjectId(id);
|
|
21329
|
+
} catch (_) {
|
|
21330
|
+
throw new Error(`Invalid ID conversion to ObjectId of ${fieldName}.`);
|
|
21331
|
+
}
|
|
21332
|
+
}
|
|
21318
21333
|
|
|
21319
21334
|
// src/repositories/visitor-transaction.repo.ts
|
|
21320
21335
|
var import_moment_timezone = __toESM(require("moment-timezone"));
|
|
@@ -21508,6 +21523,7 @@ function useVisitorTransactionRepo() {
|
|
|
21508
21523
|
preserveNullAndEmptyArrays: true
|
|
21509
21524
|
}
|
|
21510
21525
|
},
|
|
21526
|
+
// 1. Lookup visitorPass into a temporary field
|
|
21511
21527
|
{
|
|
21512
21528
|
$lookup: {
|
|
21513
21529
|
from: "keys",
|
|
@@ -21519,48 +21535,66 @@ function useVisitorTransactionRepo() {
|
|
|
21519
21535
|
from: "qr-code-templates",
|
|
21520
21536
|
localField: "template",
|
|
21521
21537
|
foreignField: "_id",
|
|
21522
|
-
pipeline: [
|
|
21523
|
-
{
|
|
21524
|
-
$project: {
|
|
21525
|
-
_id: 1,
|
|
21526
|
-
prefixPass: 1,
|
|
21527
|
-
name: 1,
|
|
21528
|
-
remarks: 1
|
|
21529
|
-
}
|
|
21530
|
-
}
|
|
21531
|
-
],
|
|
21538
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21532
21539
|
as: "template"
|
|
21533
21540
|
}
|
|
21534
21541
|
},
|
|
21535
21542
|
{
|
|
21536
21543
|
$project: {
|
|
21537
|
-
_id:
|
|
21538
|
-
|
|
21539
|
-
status: 1,
|
|
21540
|
-
description: 1,
|
|
21541
|
-
remarks: {
|
|
21542
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21543
|
-
},
|
|
21544
|
-
templatePrefixPass: {
|
|
21545
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21546
|
-
},
|
|
21544
|
+
_id: 1,
|
|
21545
|
+
// Kept only for matching purposes
|
|
21547
21546
|
prefixAndName: {
|
|
21548
21547
|
$concat: [
|
|
21549
|
-
{
|
|
21550
|
-
$ifNull: [
|
|
21551
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21552
|
-
""
|
|
21553
|
-
]
|
|
21554
|
-
},
|
|
21548
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21555
21549
|
{ $ifNull: ["$name", ""] }
|
|
21556
21550
|
]
|
|
21557
21551
|
}
|
|
21558
21552
|
}
|
|
21559
21553
|
}
|
|
21560
21554
|
],
|
|
21561
|
-
as: "
|
|
21555
|
+
as: "visitorPass_lookup"
|
|
21556
|
+
}
|
|
21557
|
+
},
|
|
21558
|
+
// 2. Map through original array, keep all fields, and inject prefixAndName
|
|
21559
|
+
{
|
|
21560
|
+
$addFields: {
|
|
21561
|
+
visitorPass: {
|
|
21562
|
+
$map: {
|
|
21563
|
+
input: "$visitorPass",
|
|
21564
|
+
as: "original",
|
|
21565
|
+
in: {
|
|
21566
|
+
// Explicitly retain all original fields from your document
|
|
21567
|
+
keyId: "$$original.keyId",
|
|
21568
|
+
receivedDate: "$$original.receivedDate",
|
|
21569
|
+
status: "$$original.status",
|
|
21570
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21571
|
+
remarks: "$$original.remarks",
|
|
21572
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21573
|
+
prefixAndName: {
|
|
21574
|
+
$let: {
|
|
21575
|
+
vars: {
|
|
21576
|
+
matched: {
|
|
21577
|
+
$arrayElemAt: [
|
|
21578
|
+
{
|
|
21579
|
+
$filter: {
|
|
21580
|
+
input: "$visitorPass_lookup",
|
|
21581
|
+
as: "lookup",
|
|
21582
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21583
|
+
}
|
|
21584
|
+
},
|
|
21585
|
+
0
|
|
21586
|
+
]
|
|
21587
|
+
}
|
|
21588
|
+
},
|
|
21589
|
+
in: "$$matched.prefixAndName"
|
|
21590
|
+
}
|
|
21591
|
+
}
|
|
21592
|
+
}
|
|
21593
|
+
}
|
|
21594
|
+
}
|
|
21562
21595
|
}
|
|
21563
21596
|
},
|
|
21597
|
+
// 3. Lookup passKeys into a temporary field
|
|
21564
21598
|
{
|
|
21565
21599
|
$lookup: {
|
|
21566
21600
|
from: "keys",
|
|
@@ -21572,46 +21606,69 @@ function useVisitorTransactionRepo() {
|
|
|
21572
21606
|
from: "qr-code-templates",
|
|
21573
21607
|
localField: "template",
|
|
21574
21608
|
foreignField: "_id",
|
|
21575
|
-
pipeline: [
|
|
21576
|
-
{
|
|
21577
|
-
$project: {
|
|
21578
|
-
_id: 1,
|
|
21579
|
-
prefixPass: 1,
|
|
21580
|
-
name: 1,
|
|
21581
|
-
remarks: 1
|
|
21582
|
-
}
|
|
21583
|
-
}
|
|
21584
|
-
],
|
|
21609
|
+
pipeline: [{ $project: { prefixPass: 1, name: 1 } }],
|
|
21585
21610
|
as: "template"
|
|
21586
21611
|
}
|
|
21587
21612
|
},
|
|
21588
21613
|
{
|
|
21589
21614
|
$project: {
|
|
21590
|
-
_id:
|
|
21591
|
-
keyId: "$_id",
|
|
21592
|
-
status: 1,
|
|
21593
|
-
description: 1,
|
|
21594
|
-
remarks: {
|
|
21595
|
-
$arrayElemAt: ["$template.remarks", 0]
|
|
21596
|
-
},
|
|
21597
|
-
templatePrefixPass: {
|
|
21598
|
-
$arrayElemAt: ["$template.prefixPass", 0]
|
|
21599
|
-
},
|
|
21615
|
+
_id: 1,
|
|
21600
21616
|
prefixAndName: {
|
|
21601
21617
|
$concat: [
|
|
21602
|
-
{
|
|
21603
|
-
$ifNull: [
|
|
21604
|
-
{ $arrayElemAt: ["$template.prefixPass", 0] },
|
|
21605
|
-
""
|
|
21606
|
-
]
|
|
21607
|
-
},
|
|
21618
|
+
{ $ifNull: [{ $arrayElemAt: ["$template.prefixPass", 0] }, ""] },
|
|
21608
21619
|
{ $ifNull: ["$name", ""] }
|
|
21609
21620
|
]
|
|
21610
21621
|
}
|
|
21611
21622
|
}
|
|
21612
21623
|
}
|
|
21613
21624
|
],
|
|
21614
|
-
as: "
|
|
21625
|
+
as: "passKeys_lookup"
|
|
21626
|
+
}
|
|
21627
|
+
},
|
|
21628
|
+
// 4. Map through original passKeys array, keep all fields, inject prefixAndName
|
|
21629
|
+
{
|
|
21630
|
+
$addFields: {
|
|
21631
|
+
passKeys: {
|
|
21632
|
+
$map: {
|
|
21633
|
+
input: "$passKeys",
|
|
21634
|
+
as: "original",
|
|
21635
|
+
in: {
|
|
21636
|
+
// Explicitly retain all original fields from your document
|
|
21637
|
+
keyId: "$$original.keyId",
|
|
21638
|
+
receivedDate: "$$original.receivedDate",
|
|
21639
|
+
status: "$$original.status",
|
|
21640
|
+
lastUpdate: "$$original.lastUpdate",
|
|
21641
|
+
remarks: "$$original.remarks",
|
|
21642
|
+
// Find and extract ONLY the prefixAndName string from lookup
|
|
21643
|
+
prefixAndName: {
|
|
21644
|
+
$let: {
|
|
21645
|
+
vars: {
|
|
21646
|
+
matched: {
|
|
21647
|
+
$arrayElemAt: [
|
|
21648
|
+
{
|
|
21649
|
+
$filter: {
|
|
21650
|
+
input: "$passKeys_lookup",
|
|
21651
|
+
as: "lookup",
|
|
21652
|
+
cond: { $eq: ["$$lookup._id", "$$original.keyId"] }
|
|
21653
|
+
}
|
|
21654
|
+
},
|
|
21655
|
+
0
|
|
21656
|
+
]
|
|
21657
|
+
}
|
|
21658
|
+
},
|
|
21659
|
+
in: "$$matched.prefixAndName"
|
|
21660
|
+
}
|
|
21661
|
+
}
|
|
21662
|
+
}
|
|
21663
|
+
}
|
|
21664
|
+
}
|
|
21665
|
+
}
|
|
21666
|
+
},
|
|
21667
|
+
// 5. Cleanup temporary arrays
|
|
21668
|
+
{
|
|
21669
|
+
$project: {
|
|
21670
|
+
visitorPass_lookup: 0,
|
|
21671
|
+
passKeys_lookup: 0
|
|
21615
21672
|
}
|
|
21616
21673
|
},
|
|
21617
21674
|
{
|
|
@@ -21808,6 +21865,7 @@ function useVisitorTransactionRepo() {
|
|
|
21808
21865
|
}
|
|
21809
21866
|
try {
|
|
21810
21867
|
const updateFields = {};
|
|
21868
|
+
const pushFields = {};
|
|
21811
21869
|
const arrayFilters = [];
|
|
21812
21870
|
Object.keys(value).forEach((key) => {
|
|
21813
21871
|
if (key !== "visitorPass" && key !== "passKeys") {
|
|
@@ -21817,34 +21875,63 @@ function useVisitorTransactionRepo() {
|
|
|
21817
21875
|
});
|
|
21818
21876
|
if (Array.isArray(value.visitorPass)) {
|
|
21819
21877
|
value.visitorPass.forEach((item, index) => {
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21878
|
+
if (item.add === true) {
|
|
21879
|
+
const { add: add2, ...cleanItem } = item;
|
|
21880
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Pass Id");
|
|
21881
|
+
if (!pushFields["visitorPass"]) {
|
|
21882
|
+
pushFields["visitorPass"] = { $each: [] };
|
|
21826
21883
|
}
|
|
21827
|
-
|
|
21828
|
-
|
|
21884
|
+
pushFields["visitorPass"].$each.push(cleanItem);
|
|
21885
|
+
} else {
|
|
21886
|
+
const elementKey = `vElem${index}`;
|
|
21887
|
+
Object.keys(item).forEach((itemKey) => {
|
|
21888
|
+
if (itemKey !== "keyId") {
|
|
21889
|
+
const typedItemKey = itemKey;
|
|
21890
|
+
let itemValue = item[typedItemKey];
|
|
21891
|
+
updateFields[`visitorPass.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21892
|
+
}
|
|
21893
|
+
});
|
|
21894
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
21895
|
+
}
|
|
21829
21896
|
});
|
|
21830
21897
|
}
|
|
21831
21898
|
if (Array.isArray(value.passKeys)) {
|
|
21832
21899
|
value.passKeys.forEach((item, index) => {
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21900
|
+
if (item.add === true) {
|
|
21901
|
+
const { add: add2, ...cleanItem } = item;
|
|
21902
|
+
cleanItem.keyId = convertObjectIdUtilNonAsync(cleanItem.keyId, "Key Id");
|
|
21903
|
+
if (!pushFields["passKeys"]) {
|
|
21904
|
+
pushFields["passKeys"] = { $each: [] };
|
|
21839
21905
|
}
|
|
21840
|
-
|
|
21841
|
-
|
|
21906
|
+
pushFields["passKeys"].$each.push(cleanItem);
|
|
21907
|
+
} else {
|
|
21908
|
+
const elementKey = `pElem${index}`;
|
|
21909
|
+
Object.keys(item).forEach((itemKey) => {
|
|
21910
|
+
if (itemKey !== "keyId") {
|
|
21911
|
+
const typedItemKey = itemKey;
|
|
21912
|
+
let itemValue = item[typedItemKey];
|
|
21913
|
+
updateFields[`passKeys.$[${elementKey}].${itemKey}`] = itemValue;
|
|
21914
|
+
}
|
|
21915
|
+
});
|
|
21916
|
+
arrayFilters.push({ [`${elementKey}.keyId`]: new import_mongodb41.ObjectId(item.keyId) });
|
|
21917
|
+
}
|
|
21842
21918
|
});
|
|
21843
21919
|
}
|
|
21920
|
+
const updatePayload = {};
|
|
21921
|
+
if (Object.keys(updateFields).length > 0) {
|
|
21922
|
+
updatePayload.$set = updateFields;
|
|
21923
|
+
}
|
|
21924
|
+
if (Object.keys(pushFields).length > 0) {
|
|
21925
|
+
updatePayload.$push = pushFields;
|
|
21926
|
+
}
|
|
21844
21927
|
const result = await collection.updateOne(
|
|
21845
21928
|
{ _id: new import_mongodb41.ObjectId(_id) },
|
|
21846
|
-
|
|
21847
|
-
{
|
|
21929
|
+
updatePayload,
|
|
21930
|
+
{
|
|
21931
|
+
...arrayFilters.length > 0 && { arrayFilters },
|
|
21932
|
+
// Only pass if not empty
|
|
21933
|
+
session
|
|
21934
|
+
}
|
|
21848
21935
|
);
|
|
21849
21936
|
return result;
|
|
21850
21937
|
} catch (error) {
|
|
@@ -34155,43 +34242,45 @@ function useVisitorTransactionService() {
|
|
|
34155
34242
|
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
34156
34243
|
}
|
|
34157
34244
|
await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
|
|
34245
|
+
if (Array.isArray(value.visitorPass)) {
|
|
34246
|
+
for (const item of value.visitorPass) {
|
|
34247
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34248
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34249
|
+
item.lastUpdate = null;
|
|
34250
|
+
item.remarks = "";
|
|
34251
|
+
}
|
|
34252
|
+
}
|
|
34253
|
+
if (Array.isArray(value.passKeys)) {
|
|
34254
|
+
for (const item of value.passKeys) {
|
|
34255
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34256
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34257
|
+
item.lastUpdate = null;
|
|
34258
|
+
item.remarks = "";
|
|
34259
|
+
}
|
|
34260
|
+
}
|
|
34158
34261
|
const result = await _add(value, session);
|
|
34159
34262
|
if (Array.isArray(value.visitorPass)) {
|
|
34160
34263
|
for (const item of value.visitorPass) {
|
|
34161
34264
|
await KeyRepo.updateKeyById(
|
|
34162
34265
|
item.keyId,
|
|
34163
|
-
{
|
|
34164
|
-
status: "In Use" /* IN_USE */,
|
|
34165
|
-
updatedBy: value.createdBy
|
|
34166
|
-
},
|
|
34266
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34167
34267
|
value.site,
|
|
34168
34268
|
session,
|
|
34169
34269
|
void 0,
|
|
34170
34270
|
result
|
|
34171
34271
|
);
|
|
34172
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34173
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34174
|
-
item.lastUpdate = null;
|
|
34175
|
-
item.remarks = "";
|
|
34176
34272
|
}
|
|
34177
34273
|
}
|
|
34178
34274
|
if (Array.isArray(value.passKeys)) {
|
|
34179
34275
|
for (const item of value.passKeys) {
|
|
34180
34276
|
await KeyRepo.updateKeyById(
|
|
34181
34277
|
item.keyId,
|
|
34182
|
-
{
|
|
34183
|
-
status: "In Use" /* IN_USE */,
|
|
34184
|
-
updatedBy: value.createdBy
|
|
34185
|
-
},
|
|
34278
|
+
{ status: "In Use" /* IN_USE */, updatedBy: value.createdBy },
|
|
34186
34279
|
value.site,
|
|
34187
34280
|
session,
|
|
34188
34281
|
void 0,
|
|
34189
34282
|
result
|
|
34190
34283
|
);
|
|
34191
|
-
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34192
|
-
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34193
|
-
item.lastUpdate = null;
|
|
34194
|
-
item.remarks = "";
|
|
34195
34284
|
}
|
|
34196
34285
|
}
|
|
34197
34286
|
await session?.commitTransaction();
|
|
@@ -34288,54 +34377,96 @@ function useVisitorTransactionService() {
|
|
|
34288
34377
|
}
|
|
34289
34378
|
if (Array.isArray(value.visitorPass)) {
|
|
34290
34379
|
for (const item of value.visitorPass) {
|
|
34291
|
-
|
|
34292
|
-
|
|
34293
|
-
|
|
34294
|
-
|
|
34295
|
-
|
|
34296
|
-
|
|
34297
|
-
|
|
34380
|
+
if (item.add) {
|
|
34381
|
+
await KeyRepo.updateKeyById(
|
|
34382
|
+
item.keyId,
|
|
34383
|
+
{
|
|
34384
|
+
status: "In Use" /* IN_USE */,
|
|
34385
|
+
updatedBy: value.updatedBy
|
|
34386
|
+
},
|
|
34387
|
+
value.site,
|
|
34388
|
+
session,
|
|
34389
|
+
void 0,
|
|
34390
|
+
id
|
|
34391
|
+
);
|
|
34392
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34393
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34394
|
+
item.lastUpdate = null;
|
|
34395
|
+
item.remarks = "";
|
|
34298
34396
|
} else {
|
|
34299
|
-
|
|
34397
|
+
let status = "Invalid";
|
|
34398
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34399
|
+
status = "Available" /* AVAILABLE */;
|
|
34400
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34401
|
+
status = "Available" /* AVAILABLE */;
|
|
34402
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34403
|
+
status = "In Use" /* IN_USE */;
|
|
34404
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34405
|
+
status = item.status;
|
|
34406
|
+
} else {
|
|
34407
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34408
|
+
}
|
|
34409
|
+
await KeyRepo.updateKeyById(
|
|
34410
|
+
item.keyId,
|
|
34411
|
+
{
|
|
34412
|
+
status,
|
|
34413
|
+
updatedBy: value.updatedBy
|
|
34414
|
+
},
|
|
34415
|
+
value.site,
|
|
34416
|
+
session,
|
|
34417
|
+
void 0,
|
|
34418
|
+
id
|
|
34419
|
+
);
|
|
34420
|
+
delete item.receivedDate;
|
|
34421
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34300
34422
|
}
|
|
34301
|
-
await KeyRepo.updateKeyById(
|
|
34302
|
-
item.keyId,
|
|
34303
|
-
{
|
|
34304
|
-
status,
|
|
34305
|
-
updatedBy: value.updatedBy
|
|
34306
|
-
},
|
|
34307
|
-
value.site,
|
|
34308
|
-
session,
|
|
34309
|
-
void 0,
|
|
34310
|
-
id
|
|
34311
|
-
);
|
|
34312
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34313
34423
|
}
|
|
34314
34424
|
}
|
|
34315
34425
|
if (Array.isArray(value.passKeys)) {
|
|
34316
34426
|
for (const item of value.passKeys) {
|
|
34317
|
-
|
|
34318
|
-
|
|
34319
|
-
|
|
34320
|
-
|
|
34321
|
-
|
|
34322
|
-
|
|
34323
|
-
|
|
34427
|
+
if (item.add) {
|
|
34428
|
+
await KeyRepo.updateKeyById(
|
|
34429
|
+
item.keyId,
|
|
34430
|
+
{
|
|
34431
|
+
status: "In Use" /* IN_USE */,
|
|
34432
|
+
updatedBy: value.updatedBy
|
|
34433
|
+
},
|
|
34434
|
+
value.site,
|
|
34435
|
+
session,
|
|
34436
|
+
void 0,
|
|
34437
|
+
id
|
|
34438
|
+
);
|
|
34439
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34440
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34441
|
+
item.lastUpdate = null;
|
|
34442
|
+
item.remarks = "";
|
|
34324
34443
|
} else {
|
|
34325
|
-
|
|
34444
|
+
let status = "Invalid";
|
|
34445
|
+
if (item?.status == "Returned" /* RETURNED */) {
|
|
34446
|
+
status = "Available" /* AVAILABLE */;
|
|
34447
|
+
} else if (item?.status == "Removed" /* REMOVED */) {
|
|
34448
|
+
status = "Available" /* AVAILABLE */;
|
|
34449
|
+
} else if (item?.status == "Not Returned" /* NOT_RETURNED */) {
|
|
34450
|
+
status = "In Use" /* IN_USE */;
|
|
34451
|
+
} else if (item?.status && VALID_STATUSES.has(item.status)) {
|
|
34452
|
+
status = item.status;
|
|
34453
|
+
} else {
|
|
34454
|
+
throw new Error("Invalid Visitor Pass Status");
|
|
34455
|
+
}
|
|
34456
|
+
await KeyRepo.updateKeyById(
|
|
34457
|
+
item.keyId,
|
|
34458
|
+
{
|
|
34459
|
+
status,
|
|
34460
|
+
updatedBy: value.updatedBy
|
|
34461
|
+
},
|
|
34462
|
+
value.site,
|
|
34463
|
+
session,
|
|
34464
|
+
void 0,
|
|
34465
|
+
id
|
|
34466
|
+
);
|
|
34467
|
+
delete item.receivedDate;
|
|
34468
|
+
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34326
34469
|
}
|
|
34327
|
-
await KeyRepo.updateKeyById(
|
|
34328
|
-
item.keyId,
|
|
34329
|
-
{
|
|
34330
|
-
status,
|
|
34331
|
-
updatedBy: value.updatedBy
|
|
34332
|
-
},
|
|
34333
|
-
value.site,
|
|
34334
|
-
session,
|
|
34335
|
-
void 0,
|
|
34336
|
-
id
|
|
34337
|
-
);
|
|
34338
|
-
item.lastUpdate = /* @__PURE__ */ new Date();
|
|
34339
34470
|
}
|
|
34340
34471
|
}
|
|
34341
34472
|
await _updateVisitorTansactionById(id, value, session);
|