@cubedelement.com/realty-investor-timeline 5.2.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [5.4.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.3.0...v5.4.0) (2025-12-19)
2
+
3
+
4
+ ### Features
5
+
6
+ * update timeline enddate ([#71](https://github.com/kvernon/realty-investor-timeline/issues/71)) ([e74a6dd](https://github.com/kvernon/realty-investor-timeline/commit/e74a6dd4eaabc43ab593be38411310e470ab7158))
7
+
8
+ # [5.3.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.2.0...v5.3.0) (2025-12-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * more no money; expose properties ([#70](https://github.com/kvernon/realty-investor-timeline/issues/70)) ([52f0ee7](https://github.com/kvernon/realty-investor-timeline/commit/52f0ee718fccc33c4891add239bd50f4228661c8))
14
+
1
15
  # [5.2.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.1.0...v5.2.0) (2025-12-19)
2
16
 
3
17
 
@@ -16,18 +16,20 @@ const get_min_cost_down_by_rule_1 = require("./get-min-cost-down-by-rule");
16
16
  function canInvestByUser(rental, user, date, properties) {
17
17
  const result = new rental_investor_validator_1.RentalInvestorValidator();
18
18
  if (rental.isOwned) {
19
- result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.PropertyIsAlreadyOwned));
19
+ result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.PropertyIsAlreadyOwned, '', []));
20
20
  return result;
21
21
  }
22
22
  const minCostDownByRule = (0, get_min_cost_down_by_rule_1.getMinCostDownByRule)(rental, user.purchaseRules);
23
23
  if (!user.hasMoneyToInvest(date, properties, minCostDownByRule)) {
24
- result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.UserHasNoMoneyToInvest, `user balance: ${user.ledgerCollection.getBalance(date)}`));
24
+ result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.UserHasNoMoneyToInvest, `user balance: ${user.ledgerCollection.getBalance(date)}`, [
25
+ { name: 'balance', value: user.ledgerCollection.getBalance(date) },
26
+ ]));
25
27
  }
26
28
  if (!user.hasMinimumSavings(date, properties)) {
27
- result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.UserHasNotSavedEnoughMoney, `user balance: ${user.ledgerCollection.getBalance(date)}, minimumSavings: ${user.getMinimumSavings(date, properties)}`));
29
+ result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.UserHasNotSavedEnoughMoney, `user balance: ${user.ledgerCollection.getBalance(date)}, minimumSavings: ${user.getMinimumSavings(date, properties)}`, [{ name: 'balance', value: user.ledgerCollection.getBalance(date) }]));
28
30
  }
29
31
  if (!user.purchaseRules || user.purchaseRules.length === 0) {
30
- result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.NoRules, 'user has no purchase rules'));
32
+ result.results.push(new user_invest_result_1.UserInvestResult(investment_reasons_1.InvestmentReasons.NoRules, 'user has no purchase rules', []));
31
33
  return result;
32
34
  }
33
35
  if (!result.canInvest) {
@@ -18,7 +18,10 @@ const getCostDownUserInvestmentResults = (rental, _holdRules, purchaseRules) =>
18
18
  }
19
19
  const userInvestResults = resultReasonToRule.values.map((v) => {
20
20
  if (!outOfPocket.evaluate(v)) {
21
- return new user_invest_result_1.UserInvestResult(resultReasonToRule.investmentReason, `rule: ${outOfPocket.value} property: ${v}`);
21
+ return new user_invest_result_1.UserInvestResult(resultReasonToRule.investmentReason, `rule: ${outOfPocket.value} property: ${v}`, [
22
+ { value: outOfPocket.value, name: 'rule' },
23
+ { value: v, name: 'property' },
24
+ ]);
22
25
  }
23
26
  return null;
24
27
  });
@@ -31,7 +31,10 @@ const getEquityCaptureUserInvestmentResults = (rental, holdRules, purchaseRules,
31
31
  }
32
32
  const equityCaptureAmount = (0, get_equity_capture_amount_1.getEquityCaptureAmount)(investmentPercent, v, sellPriceEstimate);
33
33
  if (!maxCapGains.evaluate(equityCaptureAmount)) {
34
- return new user_invest_result_1.UserInvestResult(resultReasonToRule.investmentReason, `rule: ${maxCapGains.value} property: ${equityCaptureAmount}`);
34
+ return new user_invest_result_1.UserInvestResult(resultReasonToRule.investmentReason, `rule: ${maxCapGains.value} property: ${equityCaptureAmount}`, [
35
+ { value: maxCapGains.value, name: 'rule' },
36
+ { value: equityCaptureAmount, name: 'property' },
37
+ ]);
35
38
  }
36
39
  return null;
37
40
  });
@@ -58,7 +58,10 @@ class ReasonToRule {
58
58
  }
59
59
  return this.values.map((v) => {
60
60
  if (!rule.evaluate(v)) {
61
- return new user_invest_result_1.UserInvestResult(this.investmentReason, `rule: ${rule.value} property: ${v}`);
61
+ return new user_invest_result_1.UserInvestResult(this.investmentReason, `rule: ${rule.value} property: ${v}`, [
62
+ { name: 'rule', value: rule.value },
63
+ { name: 'property', value: v },
64
+ ]);
62
65
  }
63
66
  });
64
67
  }
@@ -2,10 +2,21 @@ import { InvestmentReasons } from './investment-reasons';
2
2
  export interface IUserInvestResult {
3
3
  message: string;
4
4
  investmentReason: InvestmentReasons;
5
+ properties: {
6
+ name: string;
7
+ value: number;
8
+ }[];
5
9
  }
6
10
  export declare class UserInvestResult implements IUserInvestResult {
7
11
  get message(): string;
8
12
  investmentReason: InvestmentReasons;
9
- constructor(reason?: InvestmentReasons, message?: string);
13
+ properties: {
14
+ name: string;
15
+ value: number;
16
+ }[];
17
+ constructor(reason: InvestmentReasons, message: string, properties: {
18
+ name: string;
19
+ value: number;
20
+ }[]);
10
21
  private readonly _message;
11
22
  }
@@ -8,9 +8,11 @@ class UserInvestResult {
8
8
  return `${investment_reasons_1.InvestmentReasons[this.investmentReason]}${theMessage}`;
9
9
  }
10
10
  investmentReason;
11
- constructor(reason = investment_reasons_1.InvestmentReasons.Unknown, message = '') {
11
+ properties;
12
+ constructor(reason = investment_reasons_1.InvestmentReasons.Unknown, message, properties) {
12
13
  this.investmentReason = reason;
13
14
  this._message = message;
15
+ this.properties = properties;
14
16
  }
15
17
  _message;
16
18
  }
@@ -1,4 +1,8 @@
1
1
  export interface IHistoricalReason {
2
2
  reason: string;
3
3
  date: Date;
4
+ additionalInfo: {
5
+ name: string;
6
+ value: number;
7
+ }[];
4
8
  }
@@ -19,20 +19,20 @@ const looper = (options, timeline) => {
19
19
  const salary = new ledger_1.LedgerItem();
20
20
  salary.amount = result.user.monthlySavedAmount;
21
21
  salary.type = ledger_1.LedgerItemType.Salary;
22
- salary.created = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate, (date) => date.setUTCHours(1));
22
+ salary.created = (0, data_clone_date_1.cloneDateUtc)(result.endDate, (date) => date.setUTCHours(1));
23
23
  salary.note = 'saved for month';
24
24
  result.user.ledgerCollection.add(salary);
25
25
  }
26
- result.rentals = (0, update_historical_rentals_1.updateHistoricalRentals)(properties_1.RentalSingleFamily, options.propertyGeneratorSingleFamily, result.rentals, timeline.endDate, result.user.loanSettings);
27
- result.rentals = (0, update_historical_rentals_1.updateHistoricalRentals)(properties_1.RentalPassiveApartment, options.propertyGeneratorPassiveApartment, result.rentals, timeline.endDate, result.user.loanSettings);
26
+ result.rentals = (0, update_historical_rentals_1.updateHistoricalRentals)(properties_1.RentalSingleFamily, options.propertyGeneratorSingleFamily, result.rentals, result.endDate, result.user.loanSettings);
27
+ result.rentals = (0, update_historical_rentals_1.updateHistoricalRentals)(properties_1.RentalPassiveApartment, options.propertyGeneratorPassiveApartment, result.rentals, result.endDate, result.user.loanSettings);
28
28
  //step 2: get cash flow
29
29
  for (let index = 0; index < result.rentals.length; index++) {
30
30
  const pr = result.rentals[index];
31
31
  if (pr.property && pr.property.isOwned) {
32
32
  const cashFlow = new ledger_1.LedgerItem();
33
- cashFlow.amount = pr.property.getCashFlowByDate(timeline.endDate);
33
+ cashFlow.amount = pr.property.getCashFlowByDate(result.endDate);
34
34
  cashFlow.type = ledger_1.LedgerItemType.CashFlow;
35
- cashFlow.created = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate, (date) => {
35
+ cashFlow.created = (0, data_clone_date_1.cloneDateUtc)(result.endDate, (date) => {
36
36
  date.setUTCHours(2);
37
37
  date.setUTCMinutes(index);
38
38
  });
@@ -47,27 +47,28 @@ const looper = (options, timeline) => {
47
47
  }
48
48
  //step 3: sell properties
49
49
  const forSaleProperties = result.rentals
50
- .filter((r) => r.property && r.property.canSell(timeline.endDate))
50
+ .filter((r) => r.property && r.property.canSell(result.endDate))
51
51
  .sort((a, b) => (0, property_sort_1.default)(a.property, b.property, result.user.holdRules));
52
52
  for (let index = 0; index < forSaleProperties.length; index++) {
53
53
  const pr = forSaleProperties[index];
54
- pr.property.soldDate = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate);
54
+ pr.property.soldDate = (0, data_clone_date_1.cloneDateUtc)(result.endDate);
55
55
  const equityFromSell = new ledger_1.LedgerItem();
56
- equityFromSell.amount = pr.property.getEquityFromSell(timeline.endDate);
56
+ equityFromSell.amount = pr.property.getEquityFromSell(result.endDate);
57
57
  equityFromSell.type = ledger_1.LedgerItemType.Equity;
58
- equityFromSell.created = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate, (date) => {
58
+ equityFromSell.created = (0, data_clone_date_1.cloneDateUtc)(result.endDate, (date) => {
59
59
  date.setUTCHours(3);
60
60
  date.setUTCMinutes(index);
61
61
  });
62
62
  equityFromSell.note = `for: ${pr.property.address}, id: ${pr.property.id} (${properties_1.PropertyType[pr.property.propertyType]})`;
63
63
  result.user.ledgerCollection.add(equityFromSell);
64
64
  }
65
- if (!result.user.hasMoneyToInvest(timeline.endDate, result.rentals.map((x) => x.property).filter((x) => x.isOwned))) {
66
- const issue = new investments_1.UserInvestResult(investments_1.InvestmentReasons.UserHasNoMoneyToInvest, `user balance: ${result.user.ledgerCollection.getBalance(result.endDate)}`);
65
+ if (!result.user.hasMoneyToInvest(result.endDate, result.rentals.map((x) => x.property).filter((x) => x.isOwned))) {
66
+ const issueUserHasNoMoneyToInvest = new investments_1.UserInvestResult(investments_1.InvestmentReasons.UserHasNoMoneyToInvest, `user balance: ${result.user.ledgerCollection.getBalance(result.endDate)}`, [{ name: 'balance', value: result.user.ledgerCollection.getBalance(result.endDate) }]);
67
67
  result.rentals.forEach((r) => {
68
68
  r.reasons.push({
69
- reason: issue.message,
70
- date: (0, data_clone_date_1.cloneDateUtc)(timeline.endDate),
69
+ reason: issueUserHasNoMoneyToInvest.message,
70
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
71
+ additionalInfo: [{ name: 'balance', value: result.user.ledgerCollection.getBalance(result.endDate) }],
71
72
  });
72
73
  });
73
74
  return result;
@@ -75,12 +76,13 @@ const looper = (options, timeline) => {
75
76
  //step 4: buy new properties
76
77
  const purchaseRentals = result.rentals
77
78
  .map((r) => {
78
- if (r.property && r.property.isAvailableByDate(timeline.endDate)) {
79
- const validator = r.property.canInvestByUser(result.user, timeline.endDate, result.rentals.map((h) => h.property));
79
+ if (r.property && r.property.isAvailableByDate(result.endDate)) {
80
+ const validator = r.property.canInvestByUser(result.user, result.endDate, result.rentals.map((h) => h.property));
80
81
  if (!validator.canInvest) {
81
82
  r.reasons = r.reasons.concat(validator.results.map((reasons) => ({
82
83
  reason: reasons.message,
83
- date: (0, data_clone_date_1.cloneDateUtc)(timeline.endDate),
84
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
85
+ additionalInfo: reasons.properties,
84
86
  })));
85
87
  }
86
88
  return validator.canInvest ? r.property : null;
@@ -92,7 +94,7 @@ const looper = (options, timeline) => {
92
94
  const rentalProperty = purchaseRentals[index];
93
95
  if (rentalProperty) {
94
96
  // check cash
95
- const purchaseCreated = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate, (date) => {
97
+ const purchaseCreated = (0, data_clone_date_1.cloneDateUtc)(result.endDate, (date) => {
96
98
  date.setUTCHours(4);
97
99
  date.setUTCMinutes(index);
98
100
  });
@@ -108,12 +110,24 @@ const looper = (options, timeline) => {
108
110
  if (!purchase.isAmountGreaterThanZero()) {
109
111
  result.user.ledgerCollection.add(purchase);
110
112
  // set to purchase
111
- rentalProperty.purchaseDate = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate);
113
+ rentalProperty.purchaseDate = (0, data_clone_date_1.cloneDateUtc)(result.endDate);
112
114
  if (rentalProperty.propertyType === properties_1.PropertyType.PassiveApartment) {
113
115
  rentalProperty.costDownPrice = minCostDownByRule;
114
116
  }
115
117
  }
116
118
  }
119
+ else {
120
+ const issueMetMinCostYetUserHasNoMoneyToInvest = new investments_1.UserInvestResult(investments_1.InvestmentReasons.UserHasNoMoneyToInvest, `user balance: ${result.user.ledgerCollection.getBalance(result.endDate)}`, [{ name: 'balance', value: result.user.ledgerCollection.getBalance(result.endDate) }]);
121
+ result.rentals
122
+ .filter((x) => x.property.id === rentalProperty.id)
123
+ .forEach((r) => {
124
+ r.reasons.push({
125
+ reason: issueMetMinCostYetUserHasNoMoneyToInvest.message,
126
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
127
+ additionalInfo: issueMetMinCostYetUserHasNoMoneyToInvest.properties,
128
+ });
129
+ });
130
+ }
117
131
  }
118
132
  }
119
133
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubedelement.com/realty-investor-timeline",
3
- "version": "5.2.0",
3
+ "version": "5.4.0",
4
4
  "description": "A way to determine if and when your expenses would be covered",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",