@cubedelement.com/realty-investor-timeline 5.3.0 → 5.5.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.5.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.4.0...v5.5.0) (2025-12-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * expose cache time ([#72](https://github.com/kvernon/realty-investor-timeline/issues/72)) ([5e1c35f](https://github.com/kvernon/realty-investor-timeline/commit/5e1c35f0d838c6bf7f11e5cd0b380bf4ff6a7203))
7
+
8
+ # [5.4.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.3.0...v5.4.0) (2025-12-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * update timeline enddate ([#71](https://github.com/kvernon/realty-investor-timeline/issues/71)) ([e74a6dd](https://github.com/kvernon/realty-investor-timeline/commit/e74a6dd4eaabc43ab593be38411310e470ab7158))
14
+
1
15
  # [5.3.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.2.0...v5.3.0) (2025-12-19)
2
16
 
3
17
 
@@ -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,27 @@ 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))) {
65
+ if (!result.user.hasMoneyToInvest(result.endDate, result.rentals.map((x) => x.property).filter((x) => x.isOwned))) {
66
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
69
  reason: issueUserHasNoMoneyToInvest.message,
70
- date: (0, data_clone_date_1.cloneDateUtc)(timeline.endDate),
70
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
71
71
  additionalInfo: [{ name: 'balance', value: result.user.ledgerCollection.getBalance(result.endDate) }],
72
72
  });
73
73
  });
@@ -76,12 +76,12 @@ const looper = (options, timeline) => {
76
76
  //step 4: buy new properties
77
77
  const purchaseRentals = result.rentals
78
78
  .map((r) => {
79
- if (r.property && r.property.isAvailableByDate(timeline.endDate)) {
80
- 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));
81
81
  if (!validator.canInvest) {
82
82
  r.reasons = r.reasons.concat(validator.results.map((reasons) => ({
83
83
  reason: reasons.message,
84
- date: (0, data_clone_date_1.cloneDateUtc)(timeline.endDate),
84
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
85
85
  additionalInfo: reasons.properties,
86
86
  })));
87
87
  }
@@ -94,7 +94,7 @@ const looper = (options, timeline) => {
94
94
  const rentalProperty = purchaseRentals[index];
95
95
  if (rentalProperty) {
96
96
  // check cash
97
- const purchaseCreated = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate, (date) => {
97
+ const purchaseCreated = (0, data_clone_date_1.cloneDateUtc)(result.endDate, (date) => {
98
98
  date.setUTCHours(4);
99
99
  date.setUTCMinutes(index);
100
100
  });
@@ -110,7 +110,7 @@ const looper = (options, timeline) => {
110
110
  if (!purchase.isAmountGreaterThanZero()) {
111
111
  result.user.ledgerCollection.add(purchase);
112
112
  // set to purchase
113
- rentalProperty.purchaseDate = (0, data_clone_date_1.cloneDateUtc)(timeline.endDate);
113
+ rentalProperty.purchaseDate = (0, data_clone_date_1.cloneDateUtc)(result.endDate);
114
114
  if (rentalProperty.propertyType === properties_1.PropertyType.PassiveApartment) {
115
115
  rentalProperty.costDownPrice = minCostDownByRule;
116
116
  }
@@ -123,7 +123,7 @@ const looper = (options, timeline) => {
123
123
  .forEach((r) => {
124
124
  r.reasons.push({
125
125
  reason: issueMetMinCostYetUserHasNoMoneyToInvest.message,
126
- date: (0, data_clone_date_1.cloneDateUtc)(timeline.endDate),
126
+ date: (0, data_clone_date_1.cloneDateUtc)(result.endDate),
127
127
  additionalInfo: issueMetMinCostYetUserHasNoMoneyToInvest.properties,
128
128
  });
129
129
  });
@@ -10,6 +10,10 @@ export interface IGenOptions extends IPropertyEntityOptions {
10
10
  * Used to provide an amount of Random properties
11
11
  */
12
12
  maxRentalOpportunities: number;
13
+ /**
14
+ * Used to say how long a property should be cached
15
+ */
16
+ maxMonthsToCache?: number;
13
17
  }
14
18
  export interface ISimulateOptions {
15
19
  /**
@@ -76,14 +76,16 @@ function simulate(options = {
76
76
  lowestEquityCapturePercent: 7,
77
77
  highestEquityCapturePercent: 15,
78
78
  maxRentalOpportunities: 4,
79
+ maxMonthsToCache: 2,
79
80
  },
80
81
  }) {
81
82
  const formattedUtcDate = (0, data_clone_date_1.cloneDateUtc)(options.startDate ?? new Date());
82
83
  if (!options.generatorOptionsPassiveApartment && !options.generatorOptionsSingleFamily) {
83
84
  throw new Error('Invalid Argument: must declare at least 1, either generatorOptionsSingleFamily or generatorOptionsPassiveApartment');
84
85
  }
85
- const propertyGeneratorSingleFamily = Object.assign(new rental_generator_1.RentalGenerator(new value_cache_1.ValueCache((0, data_clone_date_1.cloneDateUtc)(formattedUtcDate), [], 2), factory_single_family_1.generateSingleFamily), options.generatorOptionsSingleFamily);
86
- const propertyGeneratorPassiveApartment = Object.assign(new rental_generator_1.RentalGenerator(new value_cache_1.ValueCache((0, data_clone_date_1.cloneDateUtc)(formattedUtcDate), [], 2), factory_passive_apartment_1.generateRentalPassiveApartment), options.generatorOptionsPassiveApartment);
86
+ const defaultMaxMonthsToCache = 2;
87
+ const propertyGeneratorSingleFamily = Object.assign(new rental_generator_1.RentalGenerator(new value_cache_1.ValueCache((0, data_clone_date_1.cloneDateUtc)(formattedUtcDate), [], options.generatorOptionsSingleFamily?.maxMonthsToCache || defaultMaxMonthsToCache), factory_single_family_1.generateSingleFamily), options.generatorOptionsSingleFamily);
88
+ const propertyGeneratorPassiveApartment = Object.assign(new rental_generator_1.RentalGenerator(new value_cache_1.ValueCache((0, data_clone_date_1.cloneDateUtc)(formattedUtcDate), [], options.generatorOptionsPassiveApartment?.maxMonthsToCache || defaultMaxMonthsToCache), factory_passive_apartment_1.generateRentalPassiveApartment), options.generatorOptionsPassiveApartment);
87
89
  const totalSavings = new ledger_1.LedgerItem();
88
90
  totalSavings.amount = options.amountInSavings;
89
91
  totalSavings.note = 'money saved up before you start';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubedelement.com/realty-investor-timeline",
3
- "version": "5.3.0",
3
+ "version": "5.5.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",