onroute-policy-engine 2.20.2 → 2.22.0
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.
- package/dist/constants/stgvwi.d.ts +6 -0
- package/dist/constants/stgvwi.js +9 -0
- package/dist/enum/facts.d.ts +1 -0
- package/dist/enum/facts.js +1 -0
- package/dist/helper/facts.helper.js +69 -4
- package/dist/types/permit-application.d.ts +11 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const AXLE_CALC_RESULTS_FACT = "axleCalcResults";
|
|
2
|
+
export declare const BASE_OVERLOAD_LIMIT = 28000;
|
|
3
|
+
export declare const EXTRA_WEIGHT_INTERVAL = 900;
|
|
4
|
+
export declare const EXTRA_RATE_INCREMENT = 1.85;
|
|
5
|
+
export declare const DEFAULT_MAX_RATE = 21.4;
|
|
6
|
+
export declare const MINIMUM_OVERLOAD_FEE = 25;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MINIMUM_OVERLOAD_FEE = exports.DEFAULT_MAX_RATE = exports.EXTRA_RATE_INCREMENT = exports.EXTRA_WEIGHT_INTERVAL = exports.BASE_OVERLOAD_LIMIT = exports.AXLE_CALC_RESULTS_FACT = void 0;
|
|
4
|
+
exports.AXLE_CALC_RESULTS_FACT = 'axleCalcResults';
|
|
5
|
+
exports.BASE_OVERLOAD_LIMIT = 28000;
|
|
6
|
+
exports.EXTRA_WEIGHT_INTERVAL = 900;
|
|
7
|
+
exports.EXTRA_RATE_INCREMENT = 1.85;
|
|
8
|
+
exports.DEFAULT_MAX_RATE = 21.4;
|
|
9
|
+
exports.MINIMUM_OVERLOAD_FEE = 25;
|
package/dist/enum/facts.d.ts
CHANGED
package/dist/enum/facts.js
CHANGED
|
@@ -22,5 +22,6 @@ var CostFacts;
|
|
|
22
22
|
CostFacts["CostPerKilometre"] = "costPerKilometre";
|
|
23
23
|
CostFacts["CostPerMonth"] = "costPerMonth";
|
|
24
24
|
CostFacts["FixedCost"] = "fixedCost";
|
|
25
|
+
CostFacts["OverloadCost"] = "overloadCost";
|
|
25
26
|
CostFacts["RangeMatrixCostLookup"] = "rangeMatrixCostLookup";
|
|
26
27
|
})(CostFacts || (exports.CostFacts = CostFacts = {}));
|
|
@@ -8,8 +8,8 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
8
8
|
const quarterOfYear_1 = __importDefault(require("dayjs/plugin/quarterOfYear"));
|
|
9
9
|
const enum_1 = require("onroute-policy-engine/enum");
|
|
10
10
|
const policy_check_helper_1 = require("./policy-check.helper");
|
|
11
|
+
const stgvwi_1 = require("../constants/stgvwi");
|
|
11
12
|
dayjs_1.default.extend(quarterOfYear_1.default);
|
|
12
|
-
const AXLE_CALC_RESULTS_FACT = 'axleCalcResults';
|
|
13
13
|
const getAxleCalculationInputs = async (policy, almanac) => {
|
|
14
14
|
var _a, _b;
|
|
15
15
|
const vehicleDetails = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.VehicleDetails);
|
|
@@ -66,7 +66,9 @@ function addRuntimeFacts(engine, policy) {
|
|
|
66
66
|
engine.addFact(enum_1.PolicyFacts.EndOfPermitYear, async function (params, almanac) {
|
|
67
67
|
const startDate = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.PermitStartDate);
|
|
68
68
|
const dateFrom = (0, dayjs_1.default)(startDate, enum_1.PermitAppInfo.PermitDateFormat);
|
|
69
|
-
const endOfYear = dateFrom
|
|
69
|
+
const endOfYear = dateFrom
|
|
70
|
+
.endOf('year')
|
|
71
|
+
.format(enum_1.PermitAppInfo.PermitDateFormat);
|
|
70
72
|
return endOfYear;
|
|
71
73
|
});
|
|
72
74
|
/**
|
|
@@ -162,7 +164,7 @@ function addRuntimeFacts(engine, policy) {
|
|
|
162
164
|
* Add runtime fact to return the complete runAxleCalculation result. This
|
|
163
165
|
* is the structured ASW validation detail exposed by validate().
|
|
164
166
|
*/
|
|
165
|
-
engine.addFact(AXLE_CALC_RESULTS_FACT, async function (params, almanac) {
|
|
167
|
+
engine.addFact(stgvwi_1.AXLE_CALC_RESULTS_FACT, async function (params, almanac) {
|
|
166
168
|
const { vehicleConfiguration, axleConfiguration, licensedGVW } = await getAxleCalculationInputs(policy, almanac);
|
|
167
169
|
return policy.runAxleCalculation(vehicleConfiguration, axleConfiguration, licensedGVW);
|
|
168
170
|
});
|
|
@@ -172,7 +174,7 @@ function addRuntimeFacts(engine, policy) {
|
|
|
172
174
|
* axleCalcResults carries the structured ASW detail.
|
|
173
175
|
*/
|
|
174
176
|
engine.addFact(enum_1.PolicyFacts.AxleCalcViolations, async function (params, almanac) {
|
|
175
|
-
const results = await almanac.factValue(AXLE_CALC_RESULTS_FACT);
|
|
177
|
+
const results = await almanac.factValue(stgvwi_1.AXLE_CALC_RESULTS_FACT);
|
|
176
178
|
const violations = results.results.filter((r) => r.result === enum_1.PolicyCheckResultType.Fail);
|
|
177
179
|
return violations.map((v) => v.message);
|
|
178
180
|
});
|
|
@@ -302,4 +304,67 @@ function addRuntimeFacts(engine, policy) {
|
|
|
302
304
|
}
|
|
303
305
|
return cost;
|
|
304
306
|
});
|
|
307
|
+
/**
|
|
308
|
+
* Add runtime fact to calculate the overload fee for STGVWI permits
|
|
309
|
+
* based on the Licensed GVW Increase and Total Distance.
|
|
310
|
+
*/
|
|
311
|
+
engine.addFact(enum_1.CostFacts.OverloadCost.toString(), async function (params, almanac) {
|
|
312
|
+
const actualGVW = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, 'vehicleConfiguration.actualGVW');
|
|
313
|
+
const licensedGVW = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, 'vehicleDetails.licensedGVW');
|
|
314
|
+
const distance = await almanac.factValue(enum_1.PermitAppInfo.PermitData, {}, enum_1.PermitAppInfo.TotalDistance);
|
|
315
|
+
const overloadKg = actualGVW - licensedGVW;
|
|
316
|
+
if (overloadKg <= 0 || !distance) {
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
let ratePer10km = 0;
|
|
320
|
+
if (overloadKg <= stgvwi_1.BASE_OVERLOAD_LIMIT) {
|
|
321
|
+
// Overload permit fee rate table mapping up to 28,000 kg
|
|
322
|
+
const rates = [
|
|
323
|
+
{ max: 2000, rate: 0.95 },
|
|
324
|
+
{ max: 3000, rate: 1.15 },
|
|
325
|
+
{ max: 4000, rate: 1.4 },
|
|
326
|
+
{ max: 5000, rate: 1.6 },
|
|
327
|
+
{ max: 6000, rate: 1.85 },
|
|
328
|
+
{ max: 7000, rate: 2.15 },
|
|
329
|
+
{ max: 8000, rate: 2.45 },
|
|
330
|
+
{ max: 9000, rate: 2.95 },
|
|
331
|
+
{ max: 10000, rate: 3.35 },
|
|
332
|
+
{ max: 11000, rate: 3.75 },
|
|
333
|
+
{ max: 12000, rate: 4.25 },
|
|
334
|
+
{ max: 13000, rate: 4.95 },
|
|
335
|
+
{ max: 14000, rate: 5.6 },
|
|
336
|
+
{ max: 15000, rate: 6.25 },
|
|
337
|
+
{ max: 16000, rate: 7.25 },
|
|
338
|
+
{ max: 17000, rate: 8.25 },
|
|
339
|
+
{ max: 18000, rate: 9.15 },
|
|
340
|
+
{ max: 19000, rate: 10.1 },
|
|
341
|
+
{ max: 20000, rate: 10.9 },
|
|
342
|
+
{ max: 21000, rate: 11.85 },
|
|
343
|
+
{ max: 22000, rate: 12.7 },
|
|
344
|
+
{ max: 23000, rate: 13.95 },
|
|
345
|
+
{ max: 24000, rate: 14.95 },
|
|
346
|
+
{ max: 25000, rate: 16.1 },
|
|
347
|
+
{ max: 26000, rate: 17.85 },
|
|
348
|
+
{ max: 27000, rate: 19.85 },
|
|
349
|
+
{ max: 28000, rate: 21.4 },
|
|
350
|
+
];
|
|
351
|
+
const match = rates.find((r) => overloadKg <= r.max);
|
|
352
|
+
ratePer10km = match ? match.rate : stgvwi_1.DEFAULT_MAX_RATE;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
// For overload greater than BASE_OVERLOAD_LIMIT kg
|
|
356
|
+
const extraWeight = overloadKg - stgvwi_1.BASE_OVERLOAD_LIMIT;
|
|
357
|
+
const intervals = Math.ceil(extraWeight / stgvwi_1.EXTRA_WEIGHT_INTERVAL);
|
|
358
|
+
ratePer10km = stgvwi_1.DEFAULT_MAX_RATE + intervals * stgvwi_1.EXTRA_RATE_INCREMENT;
|
|
359
|
+
}
|
|
360
|
+
// Fee calculation: rate * (distance / 10)
|
|
361
|
+
const distanceUnits = Math.ceil(distance / 10);
|
|
362
|
+
let totalFee = ratePer10km * distanceUnits;
|
|
363
|
+
// Apply minimum fee rule
|
|
364
|
+
if (totalFee < stgvwi_1.MINIMUM_OVERLOAD_FEE) {
|
|
365
|
+
totalFee = stgvwi_1.MINIMUM_OVERLOAD_FEE;
|
|
366
|
+
}
|
|
367
|
+
// Round to the nearest dollar (0.50 rounds up)
|
|
368
|
+
return Math.round(totalFee);
|
|
369
|
+
});
|
|
305
370
|
}
|
|
@@ -100,6 +100,15 @@ export type ICBCInsuranceCertificate = {
|
|
|
100
100
|
/** Certificate number */
|
|
101
101
|
certificateNumber?: string | null;
|
|
102
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* Extraordinary Load Request information for STOW permit applications
|
|
105
|
+
*/
|
|
106
|
+
export type ExtraordinaryLoadRequest = {
|
|
107
|
+
/** Whether or not an extraordinary load request is to be applied to the permit */
|
|
108
|
+
isExtraordinaryLoadRequest: boolean;
|
|
109
|
+
/** Approval number */
|
|
110
|
+
approvalNumber?: string | null;
|
|
111
|
+
};
|
|
103
112
|
/**
|
|
104
113
|
* Complete permit data including all application details
|
|
105
114
|
*/
|
|
@@ -140,6 +149,8 @@ export type PermitData = {
|
|
|
140
149
|
conditionalLicensingFee?: string | null;
|
|
141
150
|
/** ICBC insurance certificate information (optional) */
|
|
142
151
|
icbcInsuranceCertificate?: ICBCInsuranceCertificate | null;
|
|
152
|
+
/** Extraordinary load request information for STOW permit (optional) */
|
|
153
|
+
extraordinaryLoadRequest?: ExtraordinaryLoadRequest | null;
|
|
143
154
|
};
|
|
144
155
|
/**
|
|
145
156
|
* Selected commodity for the permit with load description
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "v2.
|
|
1
|
+
export declare const version = "v2.22.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED