generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Policy engine cost calculations and vehicle configuration funct…
…ions (#1508)
- Loading branch information
1 parent
7951551
commit 6eb9153
Showing
33 changed files
with
4,412 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Policy } from 'onroute-policy-engine'; | ||
import { PermitAppInfo } from 'onroute-policy-engine/enum'; | ||
import { masterPolicyConfig } from '../_test/policy-config/master.sample'; | ||
import { validTros30Day } from '../_test/permit-app/valid-tros-30day'; | ||
import dayjs from 'dayjs'; | ||
|
||
async function start() { | ||
const policy: Policy = new Policy(masterPolicyConfig); | ||
const today = dayjs(); | ||
|
||
// Set startDate to today | ||
validTros30Day.permitData.startDate = today.format( | ||
PermitAppInfo.PermitDateFormat.toString(), | ||
); | ||
// Set duration to full year (365 or 366 depending on leap year) | ||
const oneYearDuration: number = today.add(1, 'year').diff(today, 'day'); | ||
console.log('Setting TROS permit duration to ' + oneYearDuration); | ||
validTros30Day.permitData.permitDuration = oneYearDuration; | ||
|
||
const validationResult2 = await policy.validate(validTros30Day); | ||
console.log(JSON.stringify(validationResult2, null, ' ')); | ||
} | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Policy } from 'onroute-policy-engine'; | ||
import { completePolicyConfig } from '../_test/policy-config/complete-in-progress.sample'; | ||
|
||
function start() { | ||
const policy: Policy = new Policy(completePolicyConfig); | ||
|
||
console.log('***ALL COMMODITIES***'); | ||
const allCommodities = policy.getCommodities(); | ||
console.log( | ||
JSON.stringify(Array.from(allCommodities.entries()), null, ' '), | ||
); | ||
|
||
console.log('***COMMODITIES FOR STOS***'); | ||
const stosCommodities = policy.getCommodities('STOS'); | ||
console.log( | ||
JSON.stringify(Array.from(stosCommodities.entries()), null, ' '), | ||
); | ||
|
||
console.log('***POWER UNITS PERMITTABLE FOR STOS AND EMPTY COMMODITY***'); | ||
const puTypesEmpty = policy.getPermittablePowerUnitTypes('STOS', 'EMPTYXX'); | ||
console.log(JSON.stringify(Array.from(puTypesEmpty.entries()), null, ' ')); | ||
|
||
console.log( | ||
'***POWER UNITS PERMITTABLE FOR STOS AND BRIDGE BEAMS COMMODITY***', | ||
); | ||
const puTypesBridgeBeams = policy.getPermittablePowerUnitTypes( | ||
'STOS', | ||
'BRGBEAM', | ||
); | ||
console.log( | ||
JSON.stringify(Array.from(puTypesBridgeBeams.entries()), null, ' '), | ||
); | ||
|
||
console.log( | ||
'***PERMITTABLE NEXT VEHICLES WITH EMPTY CONFIGURATION, STOS AND EMPTY***', | ||
); | ||
const vehicleTypes1 = policy.getNextPermittableVehicles( | ||
'STOS', | ||
'EMPTYXX', | ||
[], | ||
); | ||
console.log(JSON.stringify(Array.from(vehicleTypes1.entries()), null, ' ')); | ||
|
||
console.log( | ||
'***PERMITTABLE NEXT VEHICLES WITH TRUCK TRACTOR AND JEEP, STOS AND EMPTY***', | ||
); | ||
const vehicleTypes2 = policy.getNextPermittableVehicles('STOS', 'EMPTYXX', [ | ||
'TRKTRAC', | ||
'JEEPSRG', | ||
]); | ||
console.log(JSON.stringify(Array.from(vehicleTypes2.entries()), null, ' ')); | ||
|
||
console.log( | ||
'***MAX SIZE FOR TRUCK TRACTOR, JEEP, HIBOEXP, STOS AND EMPTYXX***', | ||
); | ||
const sizeDimension = policy.getSizeDimension('STOS', 'EMPTYXX', ['TRKTRAC', 'JEEPSRG', 'HIBOEXP']); | ||
console.log(JSON.stringify(sizeDimension, null, ' ')); | ||
|
||
console.log( | ||
'***MAX SIZE FOR TRUCK TRACTOR, JEEP, HIBOEXP, STOS AND EMPTYXX IN PEACE***', | ||
); | ||
const sizeDimensionPeace = policy.getSizeDimension('STOS', 'EMPTYXX', ['TRKTRAC', 'JEEPSRG', 'HIBOEXP'], ['PCE']); | ||
console.log(JSON.stringify(sizeDimensionPeace, null, ' ')); | ||
|
||
console.log( | ||
'***MAX SIZE FOR TRUCK TRACTOR, JEEP, HIBOEXP, STOS AND EMPTYXX IN PEACE,BC DEFAULT***', | ||
); | ||
const sizeDimensionPeaceBC = policy.getSizeDimension('STOS', 'EMPTYXX', ['TRKTRAC', 'JEEPSRG', 'HIBOEXP'], ['PCE','BCD']); | ||
console.log(JSON.stringify(sizeDimensionPeaceBC, null, ' ')); | ||
} | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Policy } from 'onroute-policy-engine'; | ||
import { PermitAppInfo } from 'onroute-policy-engine/enum'; | ||
import { completePolicyConfig } from '../_test/policy-config/complete-in-progress.sample'; | ||
import { testStos } from '../_test/permit-app/test-stos'; | ||
import dayjs from 'dayjs'; | ||
|
||
async function start() { | ||
const policy: Policy = new Policy(completePolicyConfig); | ||
|
||
// Set startDate to today | ||
testStos.permitData.startDate = dayjs().format( | ||
PermitAppInfo.PermitDateFormat.toString(), | ||
); | ||
|
||
const validationResult2 = await policy.validate(testStos); | ||
console.log(JSON.stringify(validationResult2, null, ' ')); | ||
} | ||
|
||
start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Policy } from 'onroute-policy-engine'; | ||
import { PermitAppInfo } from 'onroute-policy-engine/enum'; | ||
import { masterPolicyConfig } from '../_test/policy-config/master.sample'; | ||
import { validTros30Day } from '../_test/permit-app/valid-tros-30day'; | ||
import dayjs from 'dayjs'; | ||
|
||
async function start() { | ||
const policy: Policy = new Policy(masterPolicyConfig); | ||
|
||
// Set startDate to today | ||
validTros30Day.permitData.startDate = dayjs().format( | ||
PermitAppInfo.PermitDateFormat.toString(), | ||
); | ||
|
||
const validationResult2 = await policy.validate(validTros30Day); | ||
console.log(JSON.stringify(validationResult2, null, ' ')); | ||
} | ||
|
||
start(); |
Oops, something went wrong.