Genability / genability-js

Node.js and Browser Javascript SDK for Genability APIs.
MIT License
0 stars 2 forks source link

isTariffRateWithFactor helper method #200

Closed jasonriley closed 3 years ago

jasonriley commented 3 years ago

There is a method in the tariff.ts file called isTariffRateTiered that takes a TariffRate and tells the caller if its tiered or not. This issue is to add a new helpers similar to this, but to tell the caller if the rate has a rate factor. Call the method isTariffRateWithFactor.

This returns true if either a) the tariff rate has a value in the variableFactorKey populated, or if not if one of its tariff rate bands has a calculationFactor populated.

Unit tests: 1) no variableFactorKey populated and no calculationFactor on any rate band. Returns false. 2) yes variableFactorKey populated but no calculationFactor on any rate band. Returns true. 3) no variableFactorKey populated but one of its tariff rate bands with a calculationFactor. Returns true.