Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gas object to Household #296

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions app/models/Household.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ export class Household {
fairholdLandRent: FairholdLandRent;
};
public lifetime: Lifetime;
public gasBillExistingBuildYearly: number;
public gasBillNewBuildOrRetrofitYearly: number;
public gasDemand = {
kwhExistingBuildYearly: 0,
kwhNewBuildOrRetrofitYearly: 0,
billExistingBuildYearly: 0,
billNewBuildOrRetrofitYearly: 0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be an instantiated object, or can it just be a type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh this was me confusing myself 😓 changed back to type in eca2ba6


constructor(params: ConstructorParams) {
this.incomePerPersonYearly = params.incomePerPersonYearly;
this.kwhCostPence = params.kwhCostPence;
this.property = params.property;
this.forecastParameters = params.forecastParameters;
this.incomeYearly = HEADS_PER_HOUSEHOLD * params.incomePerPersonYearly;
this.gasBillExistingBuildYearly = this.calculateGasBillExistingBuild(params);
this.gasBillNewBuildOrRetrofitYearly = this.calculateGasBillNewBuildOrRetrofit(params);
this.gasDemand = this.calculateGasDemand(params)
this.tenure = this.calculateTenures(params);
this.lifetime = this.calculateLifetime(params);
}
Expand Down Expand Up @@ -142,13 +145,24 @@ export class Household {
return new Lifetime(lifetimeParams);
}

private calculateGasBillExistingBuild(params: ConstructorParams) {
const gasBillExistingBuildYearly = this.kwhCostPence * params.property.size * KWH_M2_YR_EXISTING_BUILDS[params.property.houseType] / 100
return gasBillExistingBuildYearly
private calculateGasDemand(params: ConstructorParams) {
const kwhExistingBuildYearly = this.calculateKwhExistingBuildYearly(params);
const kwhNewBuildOrRetrofitYearly = this.calculateKwhNewBuildOrRetrofitYearly(params);
return {
kwhExistingBuildYearly,
kwhNewBuildOrRetrofitYearly,
billExistingBuildYearly: this.kwhCostPence * kwhExistingBuildYearly / 100,
billNewBuildOrRetrofitYearly: this.kwhCostPence * kwhNewBuildOrRetrofitYearly / 100
}
}

private calculateKwhExistingBuildYearly(params: ConstructorParams) {
const kwhYearly = params.property.size * KWH_M2_YR_EXISTING_BUILDS[params.property.houseType]
return kwhYearly
}

private calculateGasBillNewBuildOrRetrofit(params: ConstructorParams) {
const gasBillNewBuildOrRetrofitYearly = this.kwhCostPence * params.property.size * KWH_M2_YR_NEWBUILDS_RETROFIT[params.property.houseType] / 100
return gasBillNewBuildOrRetrofitYearly
private calculateKwhNewBuildOrRetrofitYearly(params: ConstructorParams) {
const kwhYearly = params.property.size * KWH_M2_YR_NEWBUILDS_RETROFIT[params.property.houseType]
return kwhYearly
}
}
4 changes: 2 additions & 2 deletions app/models/Lifetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export class Lifetime {
/** Initialises as user input house age and increments by one */
let houseAgeIterative = params.property.age;

let gasBillExistingBuildIterative = params.household.gasBillExistingBuildYearly;
let gasBillNewBuildOrRetrofitIterative = params.household.gasBillNewBuildOrRetrofitYearly;
let gasBillExistingBuildIterative = params.household.gasDemand.billExistingBuildYearly;
let gasBillNewBuildOrRetrofitIterative = params.household.gasDemand.billNewBuildOrRetrofitYearly;

// Initialise mortgage variables
/** Assuming a constant interest rate, this figures stays the same until the mortgage term (`marketPurchase.houseMortgage.termYears`) is reached */
Expand Down
Loading