Skip to content

Instantly share code, notes, and snippets.

@petehouston
Created March 18, 2020 15:53
Show Gist options
  • Save petehouston/9d82a82d8abaefcd38c612315f0e97c4 to your computer and use it in GitHub Desktop.
Save petehouston/9d82a82d8abaefcd38c612315f0e97c4 to your computer and use it in GitHub Desktop.
Calculator Strategy
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