onroute-policy-engine 1.6.2 → 1.6.4

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.
@@ -4,5 +4,6 @@ export declare enum ValidationResultCode {
4
4
  ConfigurationInvalid = "configuration-invalid",
5
5
  GeneralResult = "general-result",
6
6
  CostValue = "cost-value",
7
- IsLcvCarrier = "lcv-carrier"
7
+ IsLcvCarrier = "lcv-carrier",
8
+ NoFeeClient = "no-fee-client"
8
9
  }
@@ -9,4 +9,5 @@ var ValidationResultCode;
9
9
  ValidationResultCode["GeneralResult"] = "general-result";
10
10
  ValidationResultCode["CostValue"] = "cost-value";
11
11
  ValidationResultCode["IsLcvCarrier"] = "lcv-carrier";
12
+ ValidationResultCode["NoFeeClient"] = "no-fee-client";
12
13
  })(ValidationResultCode || (exports.ValidationResultCode = ValidationResultCode = {}));
@@ -55,7 +55,7 @@ class Policy {
55
55
  * @returns Results of the validation of the permit application
56
56
  */
57
57
  async validate(permit) {
58
- var _a;
58
+ var _a, _b;
59
59
  const engine = this.rulesEngines.get(permit.permitType);
60
60
  if (!engine) {
61
61
  // If the permit type being validated has no configuration in the
@@ -75,7 +75,19 @@ class Policy {
75
75
  const validationResults = new validation_results_1.ValidationResults(engineResult);
76
76
  // Include an informational message if the client is an LCV carrier
77
77
  if ((_a = this.specialAuthorizations) === null || _a === void 0 ? void 0 : _a.isLcvAllowed) {
78
- validationResults.information.push(new validation_result_1.ValidationResult(enum_1.ValidationResultType.Information, enum_1.ValidationResultCode.IsLcvCarrier, `Policy validation allowing long combination vahicle permitting for client '${this.specialAuthorizations.companyId}'`));
78
+ validationResults.information.push(new validation_result_1.ValidationResult(enum_1.ValidationResultType.Information, enum_1.ValidationResultCode.IsLcvCarrier, `Policy validation allowing long combination vehicle permitting for client '${this.specialAuthorizations.companyId}'`));
79
+ }
80
+ // Include an informational message and adjust the cost if the client
81
+ // has a no fee flag set.
82
+ if ((_b = this.specialAuthorizations) === null || _b === void 0 ? void 0 : _b.noFeeType) {
83
+ const originalPermitCost = validationResults === null || validationResults === void 0 ? void 0 : validationResults.cost.reduce((accumulator, { cost }) => accumulator + (cost !== null && cost !== void 0 ? cost : 0), 0);
84
+ // Clear the cost array and replace with zero cost
85
+ validationResults.cost.length = 0;
86
+ const newPermitCostResult = new validation_result_1.ValidationResult(enum_1.ValidationResultType.Cost, enum_1.ValidationResultCode.CostValue, 'Calculated permit cost');
87
+ newPermitCostResult.cost = 0;
88
+ validationResults.cost.push(newPermitCostResult);
89
+ // Add an informational message to the results
90
+ validationResults.information.push(new validation_result_1.ValidationResult(enum_1.ValidationResultType.Information, enum_1.ValidationResultCode.NoFeeClient, `Client '${this.specialAuthorizations.companyId}' has no fee flag, original permit cost would otherwise be '${originalPermitCost}'`));
79
91
  }
80
92
  return validationResults;
81
93
  }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v1.6.2";
1
+ export declare const version = "v1.6.4";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = 'v1.6.2';
5
+ exports.version = 'v1.6.4';
package/package.json CHANGED
@@ -89,5 +89,5 @@
89
89
  ],
90
90
  "testEnvironment": "node"
91
91
  },
92
- "version": "v1.6.2"
92
+ "version": "v1.6.4"
93
93
  }