@optimiser/common 1.0.446 → 1.0.447

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.
Files changed (2) hide show
  1. package/dist/lib/utility.js +15 -11
  2. package/package.json +1 -1
@@ -4661,11 +4661,11 @@ exports.GetDayIndex = GetDayIndex;
4661
4661
  function GetUserProfile(msp_d, db, mdb, next) {
4662
4662
  var _a;
4663
4663
  return __awaiter(this, void 0, void 0, function () {
4664
- var userData, userProfile_1, error_5, objectIDs_1, modules_1, licenceDetail_1, companyLevelLicenceDetail, moduleList, _loop_17, i, error_6;
4664
+ var userData, userProfile_1, error_5, objectIDs_1, modules_1, licenceDetail_1, companyLevelLicenceAll, companylicenceDetail_1, companyLevelLicenceDetail, moduleList, _loop_17, i, error_6;
4665
4665
  return __generator(this, function (_b) {
4666
4666
  switch (_b.label) {
4667
4667
  case 0:
4668
- _b.trys.push([0, 11, , 12]);
4668
+ _b.trys.push([0, 12, , 13]);
4669
4669
  return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1, 'CompanyID': 1 } })];
4670
4670
  case 1:
4671
4671
  userData = _b.sent();
@@ -4705,7 +4705,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4705
4705
  if (!(!userProfile_1 || userProfile_1.length <= 0)) return [3 /*break*/, 6];
4706
4706
  return [2 /*return*/, { statusCode: 500, message: "User's profile data not found.", data: {} }];
4707
4707
  case 6:
4708
- if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 9];
4708
+ if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 10];
4709
4709
  objectIDs_1 = [];
4710
4710
  userData.LicenceDetail.forEach(function (licenceDetail) {
4711
4711
  if (licenceDetail.Status == "active")
@@ -4715,9 +4715,13 @@ function GetUserProfile(msp_d, db, mdb, next) {
4715
4715
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
4716
4716
  case 7:
4717
4717
  licenceDetail_1 = _b.sent();
4718
- return [4 /*yield*/, mdb.collection("Licences").find({ "IsCompanyLevelLicence": true, "Status": "active", "IsActive": true }, { projection: { Modules: 1 } }).toArray()];
4718
+ return [4 /*yield*/, mdb.collection("Licences").find({ "IsCompanyLevelLicence": true, "Status": "active", "IsActive": true }, { projection: { Modules: 1, LicenceName: 1, LicenceType: 1 } }).toArray()];
4719
4719
  case 8:
4720
- companyLevelLicenceDetail = _b.sent();
4720
+ companyLevelLicenceAll = _b.sent();
4721
+ return [4 /*yield*/, mdb.collection("CompanyLicence").find({ 'CompanyID': userData.CompanyID, 'Status': 'active', 'IsActive': true }).toArray()];
4722
+ case 9:
4723
+ companylicenceDetail_1 = _b.sent();
4724
+ companyLevelLicenceDetail = companyLevelLicenceAll.filter(function (x) { return companylicenceDetail_1.some(function (y) { return x.LicenceName === y.LicenceName && x.LicenceType === y.LicenceType; }); });
4721
4725
  if (companyLevelLicenceDetail && companyLevelLicenceDetail.length > 0) {
4722
4726
  companyLevelLicenceDetail.map(function (x) {
4723
4727
  var _a;
@@ -4754,15 +4758,15 @@ function GetUserProfile(msp_d, db, mdb, next) {
4754
4758
  else {
4755
4759
  return [2 /*return*/, { statusCode: 200, message: "Licence data is not found in Master database.", data: {} }];
4756
4760
  }
4757
- return [3 /*break*/, 10];
4758
- case 9: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4759
- case 10: return [3 /*break*/, 12];
4760
- case 11:
4761
+ return [3 /*break*/, 11];
4762
+ case 10: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4763
+ case 11: return [3 /*break*/, 13];
4764
+ case 12:
4761
4765
  error_6 = _b.sent();
4762
4766
  console.error("Internal Error in GetUserProfile Utility function : ".concat(error_6));
4763
4767
  next(error_6);
4764
- return [3 /*break*/, 12];
4765
- case 12: return [2 /*return*/];
4768
+ return [3 /*break*/, 13];
4769
+ case 13: return [2 /*return*/];
4766
4770
  }
4767
4771
  });
4768
4772
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.446",
3
+ "version": "1.0.447",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {