@optimiser/common 1.0.282 → 1.0.283

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 +26 -10
  2. package/package.json +1 -1
@@ -3991,12 +3991,12 @@ exports.GetDayIndex = GetDayIndex;
3991
3991
  function GetUserProfile(msp_d, db, mdb, next) {
3992
3992
  var _a;
3993
3993
  return __awaiter(this, void 0, void 0, function () {
3994
- var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, moduleList, _loop_17, i, error_4;
3994
+ var userData, userProfile_1, error_3, objectIDs_1, modules_1, licenceDetail, companylicenceDetail, receptionLicense, moduleList, _loop_17, i, error_4;
3995
3995
  return __generator(this, function (_b) {
3996
3996
  switch (_b.label) {
3997
3997
  case 0:
3998
- _b.trys.push([0, 10, , 11]);
3999
- return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1 } })];
3998
+ _b.trys.push([0, 12, , 13]);
3999
+ return [4 /*yield*/, db.collection("User").findOne({ '_id': new mongodb_1.ObjectId(msp_d.ui), IsActive: true }, { projection: { 'LicenceDetail': 1, 'CompanyID': 1 } })];
4000
4000
  case 1:
4001
4001
  userData = _b.sent();
4002
4002
  if (!userData) {
@@ -4035,7 +4035,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4035
4035
  if (!(!userProfile_1 || userProfile_1.length <= 0)) return [3 /*break*/, 6];
4036
4036
  return [2 /*return*/, { statusCode: 500, message: "User's profile data not found.", data: {} }];
4037
4037
  case 6:
4038
- if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 8];
4038
+ if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 10];
4039
4039
  objectIDs_1 = [];
4040
4040
  userData.LicenceDetail.forEach(function (licenceDetail) {
4041
4041
  if (licenceDetail.Status == "active")
@@ -4045,6 +4045,22 @@ function GetUserProfile(msp_d, db, mdb, next) {
4045
4045
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
4046
4046
  case 7:
4047
4047
  licenceDetail = _b.sent();
4048
+ if (!(userData && userData.CompanyID)) return [3 /*break*/, 9];
4049
+ return [4 /*yield*/, mdb.collection("CompanyLicence").find({ 'CompanyID': userData.CompanyID, 'Status': 'active', 'IsActive': true }).toArray()];
4050
+ case 8:
4051
+ companylicenceDetail = _b.sent();
4052
+ if (companylicenceDetail && companylicenceDetail.length > 0) {
4053
+ receptionLicense = companylicenceDetail.find(function (licence) { return licence.LicenceName === "Reception" && licence.LicenceType === "App"; });
4054
+ if (receptionLicense) {
4055
+ licenceDetail.push({
4056
+ "Modules": [
4057
+ "reception"
4058
+ ]
4059
+ });
4060
+ }
4061
+ }
4062
+ _b.label = 9;
4063
+ case 9:
4048
4064
  if (licenceDetail && licenceDetail.length > 0) {
4049
4065
  licenceDetail.forEach(function (licence) {
4050
4066
  modules_1 = modules_1.concat(licence.Modules);
@@ -4073,15 +4089,15 @@ function GetUserProfile(msp_d, db, mdb, next) {
4073
4089
  else {
4074
4090
  return [2 /*return*/, { statusCode: 200, message: "Licence data is not found in Master database.", data: {} }];
4075
4091
  }
4076
- return [3 /*break*/, 9];
4077
- case 8: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4078
- case 9: return [3 /*break*/, 11];
4079
- case 10:
4092
+ return [3 /*break*/, 11];
4093
+ case 10: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4094
+ case 11: return [3 /*break*/, 13];
4095
+ case 12:
4080
4096
  error_4 = _b.sent();
4081
4097
  console.error("Internal Error in GetUserProfile Utility function : " + error_4);
4082
4098
  next(error_4);
4083
- return [3 /*break*/, 11];
4084
- case 11: return [2 /*return*/];
4099
+ return [3 /*break*/, 13];
4100
+ case 13: return [2 /*return*/];
4085
4101
  }
4086
4102
  });
4087
4103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.282",
3
+ "version": "1.0.283",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {