Skip to content

Commit

Permalink
feat: calculate resale values over time
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Nov 27, 2024
1 parent 46873e3 commit 00b65ff
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/models/Lifetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export interface LifetimeData {
// gasBillYearly: number;
depreciatedHouseResaleValue: number;
fairholdLandPurchaseResaleValue: number;
houseAge: number;
[key: number]: number;
}

Expand Down Expand Up @@ -79,6 +80,7 @@ export class Lifetime {
params.maintenancePercentage * newBuildPriceIterative;
let depreciatedHouseResaleValueIterative = params.property.depreciatedBuildPrice;
let fairholdLandPurchaseResaleValueIterative = params.fairholdLandPurchase.discountedLandPrice;
let houseAgeIterative = params.property.age;

for (let i = 0; i < params.yearsForecast - 1; i++) {
incomeYearlyIterative =
Expand All @@ -103,8 +105,18 @@ export class Lifetime {
marketRentYearlyIterative - marketRentLandYearlyIterative;
maintenanceCostIterative =
newBuildPriceIterative * params.maintenancePercentage;
depreciatedHouseResaleValueIterative = 0// TODO
fairholdLandPurchaseResaleValueIterative = 0// TODO

/* A new instance of the `Property` class is needed here in order to
re-calculate the depreciated house value as the house gets older*/
const iterativeProperty = new Property({
...params.property,
age: houseAgeIterative
});
/* Use the `calculateDepreciatedBuildPrice()` method on the new `Property` class
to calculate an updated depreciated house value */
depreciatedHouseResaleValueIterative = iterativeProperty.calculateDepreciatedBuildPrice()
fairholdLandPurchaseResaleValueIterative = (1 + params.constructionPriceGrowthPerYear) // TODO: replace variable name with cpiGrowthPerYear
houseAgeIterative += 1

if (i < params.marketPurchase.houseMortgage.termYears - 1) {
newbuildHouseMortgageYearlyIterative = params.marketPurchase.houseMortgage.yearlyPaymentBreakdown[i].yearlyPayment;
Expand Down Expand Up @@ -138,7 +150,8 @@ export class Lifetime {
marketLandRentYearly: marketRentLandYearlyIterative,
marketHouseRentYearly: marketRentHouseYearlyIterative,
depreciatedHouseResaleValue: depreciatedHouseResaleValueIterative,
fairholdLandPurchaseResaleValue: fairholdLandPurchaseResaleValueIterative
fairholdLandPurchaseResaleValue: fairholdLandPurchaseResaleValueIterative,
houseAge: houseAgeIterative,
});
}
return lifetime;
Expand Down

0 comments on commit 00b65ff

Please sign in to comment.