@optimiser/common 1.0.280 → 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 +30 -17
  2. package/package.json +1 -1
@@ -1797,9 +1797,7 @@ function BuildGridFieldProjection(project, field, group) {
1797
1797
  project[fldName] = 1;
1798
1798
  project[alias] = 1;
1799
1799
  for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1800
- // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1801
- // added by Shahzaib, make int to string and concat
1802
- searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, [" "]] });
1800
+ searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1803
1801
  if (i < field.Schema.LookupFields.length - 1) {
1804
1802
  searchConcatArry.push([" "]);
1805
1803
  }
@@ -1810,7 +1808,8 @@ function BuildGridFieldProjection(project, field, group) {
1810
1808
  $reduce: {
1811
1809
  input: { $concatArrays: searchConcatArry },
1812
1810
  initialValue: "",
1813
- in: { $concat: ["$$value", "$$this"] }
1811
+ //in: { $concat: ["$$value", "$$this"] } // Commented by and below line was added by Shahzaib, make int to string
1812
+ in: { $concat: ["$$value", { $toString: "$$this" }] }
1814
1813
  }
1815
1814
  };
1816
1815
  break;
@@ -1840,9 +1839,7 @@ function BuildGridFieldProjection(project, field, group) {
1840
1839
  project[alias] = 1;
1841
1840
  if (field.Schema.LookupObject) {
1842
1841
  for (var i = 0; i < field.Schema.LookupFields.length; i++) {
1843
- // searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "] ] });
1844
- // added by Shahzaib, make int to string and concat
1845
- searchConcatArry.push({ "$ifNull": [{ $toString: '$' + alias + '.' + field.Schema.LookupFields[i] }, [" "]] });
1842
+ searchConcatArry.push({ "$ifNull": ['$' + alias + '.' + field.Schema.LookupFields[i], [" "]] });
1846
1843
  if (i < field.Schema.LookupFields.length - 1) {
1847
1844
  searchConcatArry.push([" "]);
1848
1845
  }
@@ -3994,12 +3991,12 @@ exports.GetDayIndex = GetDayIndex;
3994
3991
  function GetUserProfile(msp_d, db, mdb, next) {
3995
3992
  var _a;
3996
3993
  return __awaiter(this, void 0, void 0, function () {
3997
- 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;
3998
3995
  return __generator(this, function (_b) {
3999
3996
  switch (_b.label) {
4000
3997
  case 0:
4001
- _b.trys.push([0, 10, , 11]);
4002
- 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 } })];
4003
4000
  case 1:
4004
4001
  userData = _b.sent();
4005
4002
  if (!userData) {
@@ -4038,7 +4035,7 @@ function GetUserProfile(msp_d, db, mdb, next) {
4038
4035
  if (!(!userProfile_1 || userProfile_1.length <= 0)) return [3 /*break*/, 6];
4039
4036
  return [2 /*return*/, { statusCode: 500, message: "User's profile data not found.", data: {} }];
4040
4037
  case 6:
4041
- if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 8];
4038
+ if (!(userData.LicenceDetail && userData.LicenceDetail.length > 0)) return [3 /*break*/, 10];
4042
4039
  objectIDs_1 = [];
4043
4040
  userData.LicenceDetail.forEach(function (licenceDetail) {
4044
4041
  if (licenceDetail.Status == "active")
@@ -4048,6 +4045,22 @@ function GetUserProfile(msp_d, db, mdb, next) {
4048
4045
  return [4 /*yield*/, mdb.collection("Licences").find({ '_id': { $in: objectIDs_1 }, 'Status': 'active', 'IsActive': true }).toArray()];
4049
4046
  case 7:
4050
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:
4051
4064
  if (licenceDetail && licenceDetail.length > 0) {
4052
4065
  licenceDetail.forEach(function (licence) {
4053
4066
  modules_1 = modules_1.concat(licence.Modules);
@@ -4076,15 +4089,15 @@ function GetUserProfile(msp_d, db, mdb, next) {
4076
4089
  else {
4077
4090
  return [2 /*return*/, { statusCode: 200, message: "Licence data is not found in Master database.", data: {} }];
4078
4091
  }
4079
- return [3 /*break*/, 9];
4080
- case 8: return [2 /*return*/, { statusCode: 200, message: "There is no licence assigned to this user, please contact your administrator.", data: {} }];
4081
- case 9: return [3 /*break*/, 11];
4082
- 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:
4083
4096
  error_4 = _b.sent();
4084
4097
  console.error("Internal Error in GetUserProfile Utility function : " + error_4);
4085
4098
  next(error_4);
4086
- return [3 /*break*/, 11];
4087
- case 11: return [2 /*return*/];
4099
+ return [3 /*break*/, 13];
4100
+ case 13: return [2 /*return*/];
4088
4101
  }
4089
4102
  });
4090
4103
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.280",
3
+ "version": "1.0.283",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {