Skip to content

Commit

Permalink
chore: adopt tsdoc line break convention
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Nov 28, 2024
1 parent 2c68679 commit fd3d5a6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
15 changes: 9 additions & 6 deletions app/models/Fairhold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ type ConstructorParams = Pick<Fairhold, "affordability" | "landPriceOrRent">;
export class Fairhold {
/** Affordability is calculated as monthly housing cost / GDHI */
public affordability: number;
/** Depending on whether calculating `FairholdLandPurchase` or `FairholdLandRent`,
/**
* Depending on whether calculating `FairholdLandPurchase` or `FairholdLandRent`,
* pass the relevant figure (open market residual land value or estimated portion of monthly market rent
* that goes towards location)
*/
public landPriceOrRent: number;
/** The Fairhold discount is a multiplier, so Fairhold prices are `discountLand * open market value`
*/
/** The Fairhold discount is a multiplier, so Fairhold prices are `discountLand * open market value`*/
public discountLand: number;
/** When the class is instantiated for `FairholdLandPurchase`, this is the discounted up-front land purchase price;
/**
* When the class is instantiated for `FairholdLandPurchase`, this is the discounted up-front land purchase price;
* when instantiated for `FairholdLandPurchase`, this is the discounted monthly community ground rent
*/
public discountedLandPriceOrRent: number;
Expand All @@ -35,15 +36,17 @@ export class Fairhold {
this.discountedLandPriceOrRent = this.calculateDiscountedPriceOrRent();
}

/** Our formula is linear; the more expensive an area is, the lower the generated price multiplier is;
/**
* Our formula is linear; the more expensive an area is, the lower the generated price multiplier is;
* it plateaus at .15 of market rate
*/
private calculateFairholdDiscount() {
const discountLand = math.max(MULTIPLIER * this.affordability + OFFSET, PLATEAU)
return discountLand;
}

/** Multiplies market land price or rent by the discountLand multiplier;
/**
* Multiplies market land price or rent by the discountLand multiplier;
* in the event that land values are effectively negative, land price will be £1
*/
private calculateDiscountedPriceOrRent() {
Expand Down
3 changes: 2 additions & 1 deletion app/models/ForecastParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export interface ForecastParameters {
affordabilityThresholdIncomePercentage: number;
}

/** Parameters for forecasting changing costs over time,
/**
* Parameters for forecasting changing costs over time,
* all values except years are percentages represented in decimal form
*/
export const DEFAULT_FORECAST_PARAMETERS: ForecastParameters = {
Expand Down
6 changes: 4 additions & 2 deletions app/models/Lifetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export interface LifetimeData {
// gasBillYearly: number;
[key: number]: number;
}
/** The `Lifetime` class calculates yearly spend on housing over a lifetime (set by `yearsForecast`).
/**
* The `Lifetime` class calculates yearly spend on housing over a lifetime (set by `yearsForecast`).
* Instead of storing lifetime data within each tenure class itself,
* `Lifetime` is stored in its own class (to prevent excess duplication of properties like `incomeYearly`).
*/
Expand All @@ -48,7 +49,8 @@ export class Lifetime {
this.lifetimeData = this.calculateLifetime(params);
}

/** The function loops through and calculates all values for period set by yearsForecast,
/**
* The function loops through and calculates all values for period set by yearsForecast,
* pushing the results to the lifetime array (one object per-year)
*/
private calculateLifetime(params: LifetimeParams): LifetimeData[] {
Expand Down
3 changes: 2 additions & 1 deletion app/models/Mortgage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ type MortgageBreakdown = {
remainingBalance: number;
}[];

/** The `Mortgage` class is instantiated each time a mortgage needs to be calculated,
/**
* The `Mortgage` class is instantiated each time a mortgage needs to be calculated,
* meaning per-type of property, eg land or house, per-tenure
*/
export class Mortgage {
Expand Down
3 changes: 2 additions & 1 deletion app/models/tenure/FairholdLandPurchase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ interface FairholdLandPurchaseParams {
marketPurchase: MarketPurchase;
}

/** `FairholdLandPurchase` needs different params to FairholdLandRent,
/**
* `FairholdLandPurchase` needs different params to FairholdLandRent,
* which is why they are separate classes that both instantiate an instance of Fairhold.
* Where `FairholdLandRent` uses other classes (eg `MarketPurchase`, `ForecastParameters`), they are passed in*/
export class FairholdLandPurchase {
Expand Down
3 changes: 2 additions & 1 deletion app/models/tenure/FairholdLandRent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ interface FairholdLandRentParams {
marketPurchase: MarketPurchase;
}

/** `FairholdLandRent` needs different params to `FairholdLandPurchase`,
/**
* `FairholdLandRent` needs different params to `FairholdLandPurchase`,
* which is why they are separate classes that both instantiate an instance of `Fairhold`.
* Where `FairholdLandRent` uses other classes (eg `MarketPurchase`, `ForecastParameters`), they are passed in*/
export class FairholdLandRent {
Expand Down

0 comments on commit fd3d5a6

Please sign in to comment.