-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRealEstateDealBuilder.ts
117 lines (100 loc) · 2.74 KB
/
RealEstateDealBuilder.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
export interface RealEstateDeal {
salePrice: number;
downpaymentPercentage: number;
annualMortgageInterestRate: number;
mortgageAmortization: number;
propertyTaxRate: number;
monthlyHoaDues: number;
vacancyRate: number;
monthlyRent: number;
landlordPaidUtilities: boolean;
needsPropertyManagement: boolean;
unitCount: number;
newConstruction: boolean;
closingEquity?: number;
}
/**
* The `RealEstateDealBuilder` class allows for easy construction of real estate deal
* objects with customizable parameters.
*/
export class RealEstateDealBuilder {
private deal: RealEstateDeal;
constructor() {
this.deal = {
salePrice: 0,
downpaymentPercentage: 20,
annualMortgageInterestRate: 0,
mortgageAmortization: 25,
propertyTaxRate: 1,
monthlyHoaDues: 0,
vacancyRate: 2.5,
monthlyRent: 0,
landlordPaidUtilities: false,
needsPropertyManagement: false,
unitCount: 1,
newConstruction: false,
};
}
setDeal(partialDeal: Partial<RealEstateDeal>) {
this.deal = {
...this.deal,
...partialDeal
};
return this;
}
setSalePrice(price: number): RealEstateDealBuilder {
this.deal.salePrice = price;
return this;
}
setDownpaymentPercentage(percentage: number): RealEstateDealBuilder {
this.deal.downpaymentPercentage = percentage;
return this;
}
setAnnualMortgageInterestRate(rate: number): RealEstateDealBuilder {
this.deal.annualMortgageInterestRate = rate;
return this;
}
setMortgageAmortization(years: number): RealEstateDealBuilder {
this.deal.mortgageAmortization = years;
return this;
}
setPropertyTaxRate(rate: number): RealEstateDealBuilder {
this.deal.propertyTaxRate = rate;
return this;
}
setMonthlyHoaDues(dues: number): RealEstateDealBuilder {
this.deal.monthlyHoaDues = dues;
return this;
}
setVacancyRate(rate: number): RealEstateDealBuilder {
this.deal.vacancyRate = rate;
return this;
}
setMonthlyRent(rent: number): RealEstateDealBuilder {
this.deal.monthlyRent = rent;
return this;
}
setLandlordPaidUtilities(paid: boolean): RealEstateDealBuilder {
this.deal.landlordPaidUtilities = paid;
return this;
}
setNeedsPropertyManagement(needs: boolean): RealEstateDealBuilder {
this.deal.needsPropertyManagement = needs;
return this;
}
setUnitCount(count: number): RealEstateDealBuilder {
this.deal.unitCount = count;
return this;
}
setNewConstruction(isNew: boolean): RealEstateDealBuilder {
this.deal.newConstruction = isNew;
return this;
}
setClosingEquity(equity: number): RealEstateDealBuilder {
this.deal.closingEquity = equity;
return this;
}
build(): RealEstateDeal {
return this.deal;
}
}