@optimiser/common 1.0.327 → 1.0.329

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 +40 -33
  2. package/package.json +1 -1
@@ -2217,14 +2217,15 @@ function FilterConditions(condition, match, fields) {
2217
2217
  if (field.Schema.UIDataType === 'date' || field.Schema.UIDataType === 'datetime') {
2218
2218
  var operator = obj.Operator;
2219
2219
  var startCompareDate = void 0, endCompareDate = void 0;
2220
+ // below moment date was converted into utc by Shahzaib on 22/05/2023
2220
2221
  if (operator === "custom") {
2221
- startCompareDate = moment_1.default((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, obj.DateFormat).startOf('day');
2222
- endCompareDate = moment_1.default((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, obj.DateFormat).endOf('day');
2222
+ startCompareDate = moment_1.default.utc((_a = obj.Value) === null || _a === void 0 ? void 0 : _a.From, obj.DateFormat).startOf('day'); //moment(obj.Value.From).startOf('day');
2223
+ endCompareDate = moment_1.default.utc((_b = obj.Value) === null || _b === void 0 ? void 0 : _b.To, obj.DateFormat).endOf('day'); //moment(obj.Value.To).endOf('day');
2223
2224
  }
2224
2225
  else {
2225
2226
  var _d = helper_1.GetDateRangeFromOperatorValue(operator, obj.FiscalMonth, obj.FiscalFrom), startDate = _d.startDate, endDate = _d.endDate;
2226
- startCompareDate = moment_1.default(startDate, obj.DateFormat).startOf('day');
2227
- endCompareDate = moment_1.default(endDate, obj.DateFormat).endOf('day');
2227
+ startCompareDate = moment_1.default.utc(startDate, obj.DateFormat).startOf('day'); //moment(startDate).startOf('day');
2228
+ endCompareDate = moment_1.default.utc(endDate, obj.DateFormat).endOf('day'); //moment(endDate).endOf('day');
2228
2229
  }
2229
2230
  matchValue = { '$gte': new Date(moment_1.default(startCompareDate).toISOString()), '$lte': new Date(moment_1.default(endCompareDate).toISOString()) };
2230
2231
  }
@@ -5054,39 +5055,45 @@ exports.ValidateUserInput = ValidateUserInput;
5054
5055
  * @return message in string
5055
5056
  */
5056
5057
  function CheckConditionalField(field, record, action) {
5057
- var msg = '';
5058
- var fieldData = record[field.Name];
5059
- if (field.Schema.ConditionalAction == 'enabled' && field.IsRequired == true) {
5060
- if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
5061
- msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is required!';
5058
+ try {
5059
+ var msg = '';
5060
+ var fieldData = record[field.Name];
5061
+ if (field.Schema.ConditionalAction == 'enabled' && field.IsRequired == true) {
5062
+ if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
5063
+ msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is required!';
5064
+ }
5062
5065
  }
5063
- }
5064
- else if (record != undefined && eval(field.Schema.ConditionalExpression) == true) {
5065
- switch (field.Schema.ConditionalAction) {
5066
- case "mandatory":
5067
- case "enabled-mandatory":
5068
- case "show-enabled-mandatory":
5069
- case "show-disabled-mandatory":
5070
- if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
5071
- msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is conditionally required!';
5072
- }
5073
- break;
5066
+ else if (record != undefined && eval(field.Schema.ConditionalExpression) == true) {
5067
+ switch (field.Schema.ConditionalAction) {
5068
+ case "mandatory":
5069
+ case "enabled-mandatory":
5070
+ case "show-enabled-mandatory":
5071
+ case "show-disabled-mandatory":
5072
+ if (field.Schema.UIDataType != 'autoincrement' && (fieldData === '' || fieldData === null || (fieldData === undefined && action == "add"))) {
5073
+ msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is conditionally required!';
5074
+ }
5075
+ break;
5076
+ }
5074
5077
  }
5075
- }
5076
- else {
5077
- switch (field.Schema.ConditionalAction) {
5078
- case "show-disabled-mandatory":
5079
- case "show-disabled-nonmandatory":
5080
- break;
5081
- case "show-enabled-mandatory":
5082
- case "show-enabled-nonmandatory":
5083
- if (fieldData) {
5084
- msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is a hidden field and should not contain value.';
5085
- }
5086
- break;
5078
+ else {
5079
+ switch (field.Schema.ConditionalAction) {
5080
+ case "show-disabled-mandatory":
5081
+ case "show-disabled-nonmandatory":
5082
+ break;
5083
+ case "show-enabled-mandatory":
5084
+ case "show-enabled-nonmandatory":
5085
+ if (fieldData) {
5086
+ msg = ((field.DisplayName || field.Schema.DisplayName) || field.Name) + ' is a hidden field and should not contain value.';
5087
+ }
5088
+ break;
5089
+ }
5087
5090
  }
5091
+ return msg;
5092
+ }
5093
+ catch (error) {
5094
+ console.error("Internal Error in CheckConditionalField Function : ", error);
5095
+ return '';
5088
5096
  }
5089
- return msg;
5090
5097
  }
5091
5098
  /**
5092
5099
  * TODO: Create lookup of fields of list schema for Vat Setting data
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimiser/common",
3
- "version": "1.0.327",
3
+ "version": "1.0.329",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {