Created
March 18, 2020 15:53
-
-
Save petehouston/9d82a82d8abaefcd38c612315f0e97c4 to your computer and use it in GitHub Desktop.
Calculator Strategy
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
class RentCalculator { | |
constructor() { | |
this.calculator = { | |
'Base_Flat': this._calcBaseFlat, | |
'Base_Percentage': this._calcBasePercentage, | |
'Base_Amount': this._calcBaseAmount, | |
'Gross_Flat': this._calcGrossFlat, | |
'Gross_Percentage': this._calcGrossPercentage, | |
'Gross_Amount': this._calcGrossAmount, | |
} | |
} | |
calculateAverageBaseRent(leaseTerm, baseRate, escalationType, escalationValue, freeRentType, opex, sizeSf, numOfFreeMonths) { | |
let calculator = this.calculator[freeRentType + '_' + escalationType]; | |
if (typeof calculator === 'undefined') { | |
return 0; | |
} | |
return calculator(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonth); | |
} | |
_calcBaseFlat(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
_calcBasePercentage(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
_calcBaseAmount(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
_calcGrossFlat(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
_calcGrossPercentage(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
_calcGrossAmount(leaseTerm, baseRate, escalationValue, opex, sizeSf, numOfFreeMonths) { | |
// TODO | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment