Skip to content

Instantly share code, notes, and snippets.

@domtalbot
Created October 9, 2018 10:01
Show Gist options
  • Save domtalbot/dd136a4aa0f19bf8ed0c73c325ceab1b to your computer and use it in GitHub Desktop.
Save domtalbot/dd136a4aa0f19bf8ed0c73c325ceab1b to your computer and use it in GitHub Desktop.
financeDevelopmentFunds
financeDevelopmentFunds(type: string): number {
let calcTotal = 0;
let compTotal = 0;
const seniorFixed = this.data.finance.senior.fixedSum || 0;
const seniorLTV = this.data.finance.senior.ltv || 0;
const seniorLTC = this.data.finance.senior.ltc || 0;
const seniorLTGDV = this.data.finance.senior.ltGDV || 100;
const mezzFixed = this.data.finance.mezz.fixedSum || 0;
const mezzLTV = this.data.finance.mezz.ltv || 0;
const mezzLTC = this.data.finance.mezz.ltc || 0;
const mezzLTGDV = this.data.finance.mezz.ltGDV || 100;
const investorFixed = this.data.finance.investor.fixedSum || 0;
const investorLTV = this.data.finance.investor.ltv || 0;
const investorLTC = this.data.finance.investor.ltc || 0;
const investorLTGDV = this.data.finance.investor.ltGDV || 100;
const gdv = this.summaryGDVTotal();
const developmentCost = this.calcTotal('developmentContent');
const financePurchaseTotal = this.financePurchaseFunds('senior')
+ this.financePurchaseFunds('mezz')
+ this.financePurchaseFunds('investor');
switch (type) {
case 'senior':
return Math.max(Math.min((seniorFixed > 0 ? seniorFixed - this.financePurchaseFunds('senior') : (seniorLTC / 100) * developmentCost), (seniorLTGDV / 100) * gdv - this.financePurchaseFunds('senior')), 0);
case 'mezz':
return Math.max(Math.min((mezzFixed > 0 ? Math.max(mezzFixed - this.financePurchaseFunds('mezz'), 0) : (mezzLTC / 100) * developmentCost - this.financeDevelopmentFunds('senior')), (mezzLTGDV / 100) * gdv - this.financePurchaseFunds('mezz')), 0);
case 'investor':
return Math.max(Math.min((investorFixed > 0 ? Math.max(investorFixed - this.financePurchaseFunds('investor'), 0) : (investorLTC / 100) * developmentCost - this.financeDevelopmentFunds('senior') - this.financeDevelopmentFunds('mezz')), (investorLTGDV / 100) * gdv - this.financePurchaseFunds('investor')), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment