@cubedelement.com/realty-investor-timeline 5.5.1 → 5.7.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/src/account/i-user-goal.d.ts +5 -0
  3. package/dist/src/account/user.d.ts +20 -1
  4. package/dist/src/account/user.js +21 -0
  5. package/dist/src/ledger/i-ledger-summary.d.ts +6 -0
  6. package/dist/src/ledger/ledger-collection.d.ts +6 -2
  7. package/dist/src/ledger/ledger-collection.js +40 -1
  8. package/dist/src/ledger/ledger-item.d.ts +17 -0
  9. package/dist/src/ledger/ledger-item.js +38 -0
  10. package/dist/src/time/default-has-met-goal-or-max-time.js +1 -1
  11. package/dist/src/time/looper.js +1 -1
  12. package/dist/src/utils/get-date-quarter.d.ts +9 -0
  13. package/dist/src/utils/get-date-quarter.js +9 -0
  14. package/package.json +1 -1
  15. package/.github/dependabot.yml +0 -10
  16. package/docs/_media/badge.svg +0 -1
  17. package/docs/account/i-user-goal/index.md +0 -11
  18. package/docs/account/i-user-goal/interfaces/IUserGoal.md +0 -47
  19. package/docs/account/i-user-investor-check/index.md +0 -11
  20. package/docs/account/i-user-investor-check/interfaces/IUserInvestorCheck.md +0 -206
  21. package/docs/account/index.md +0 -31
  22. package/docs/account/user/classes/User.md +0 -312
  23. package/docs/account/user/index.md +0 -15
  24. package/docs/account/user/interfaces/IUser.md +0 -282
  25. package/docs/caching/index.md +0 -19
  26. package/docs/caching/value-cache/classes/ValueCache.md +0 -194
  27. package/docs/caching/value-cache/index.md +0 -15
  28. package/docs/caching/value-cache/interfaces/IValueCache.md +0 -104
  29. package/docs/calculations/can-invest-by-user/functions/canInvestByUser.md +0 -35
  30. package/docs/calculations/can-invest-by-user/index.md +0 -11
  31. package/docs/calculations/cash-on-cash-return/functions/cashOnCashReturn.md +0 -29
  32. package/docs/calculations/cash-on-cash-return/index.md +0 -11
  33. package/docs/calculations/get-cost-down/functions/getCostDown.md +0 -27
  34. package/docs/calculations/get-cost-down/index.md +0 -11
  35. package/docs/calculations/get-cost-down-user-investment-results/functions/getCostDownUserInvestmentResults.md +0 -33
  36. package/docs/calculations/get-cost-down-user-investment-results/index.md +0 -11
  37. package/docs/calculations/get-equity-capture-amount/functions/getEquityCaptureAmount.md +0 -31
  38. package/docs/calculations/get-equity-capture-amount/index.md +0 -11
  39. package/docs/calculations/get-equity-capture-user-investment-results/functions/getEquityCaptureUserInvestmentResults.md +0 -33
  40. package/docs/calculations/get-equity-capture-user-investment-results/index.md +0 -11
  41. package/docs/calculations/get-investment-percent/functions/getInvestmentPercent.md +0 -27
  42. package/docs/calculations/get-investment-percent/index.md +0 -11
  43. package/docs/calculations/get-min-cost-down-by-rule/functions/getMinCostDownByRule.md +0 -25
  44. package/docs/calculations/get-min-cost-down-by-rule/index.md +0 -11
  45. package/docs/calculations/get-monthly-mortgage/functions/getMonthlyMortgage.md +0 -43
  46. package/docs/calculations/get-monthly-mortgage/index.md +0 -11
  47. package/docs/calculations/get-monthly-principal-interest-tax-interest/functions/getMonthlyPrincipalInterestTaxInterest.md +0 -43
  48. package/docs/calculations/get-monthly-principal-interest-tax-interest/index.md +0 -11
  49. package/docs/calculations/get-sell-price-estimate/functions/getSellPriceEstimate.md +0 -33
  50. package/docs/calculations/get-sell-price-estimate/index.md +0 -11
  51. package/docs/calculations/index.md +0 -73
  52. package/docs/calculations/return-on-capital-gain/functions/returnOnCapitalGain.md +0 -31
  53. package/docs/calculations/return-on-capital-gain/index.md +0 -11
  54. package/docs/formatters/currency/functions/default.md +0 -21
  55. package/docs/formatters/currency/index.md +0 -11
  56. package/docs/formatters/index.md +0 -7
  57. package/docs/generators/factory-passive-apartment/functions/generateRentalPassiveApartment.md +0 -35
  58. package/docs/generators/factory-passive-apartment/index.md +0 -11
  59. package/docs/generators/factory-single-family/functions/generateSingleFamily.md +0 -35
  60. package/docs/generators/factory-single-family/index.md +0 -11
  61. package/docs/generators/generate-property/index.md +0 -11
  62. package/docs/generators/generate-property/type-aliases/GenerateProperty.md +0 -37
  63. package/docs/generators/generic-generate-property/functions/genericGenerateProperty.md +0 -35
  64. package/docs/generators/generic-generate-property/index.md +0 -11
  65. package/docs/generators/i-property-entity-options/index.md +0 -11
  66. package/docs/generators/i-property-entity-options/interfaces/IPropertyEntityOptions.md +0 -113
  67. package/docs/generators/index.md +0 -49
  68. package/docs/generators/rental-generator/classes/RentalGenerator.md +0 -248
  69. package/docs/generators/rental-generator/index.md +0 -15
  70. package/docs/generators/rental-generator/interfaces/IRentalGenerator.md +0 -65
  71. package/docs/index/index.md +0 -487
  72. package/docs/index.md +0 -258
  73. package/docs/investments/index.md +0 -85
  74. package/docs/investments/investment-reasons/enumerations/InvestmentReasons.md +0 -119
  75. package/docs/investments/investment-reasons/index.md +0 -11
  76. package/docs/investments/investment-reasons-decorator/functions/InvestmentReasonForHoldRuleTypes.md +0 -25
  77. package/docs/investments/investment-reasons-decorator/functions/InvestmentReasonForPurchaseRuleTypes.md +0 -25
  78. package/docs/investments/investment-reasons-decorator/functions/getInvestmentReasons.md +0 -33
  79. package/docs/investments/investment-reasons-decorator/functions/getInvestmentReasonsForPurchaseTypes.md +0 -25
  80. package/docs/investments/investment-reasons-decorator/index.md +0 -18
  81. package/docs/investments/investment-reasons-decorator/type-aliases/PropertyDecoratorType.md +0 -29
  82. package/docs/investments/reason-to-rule/classes/ReasonToRule.md +0 -263
  83. package/docs/investments/reason-to-rule/index.md +0 -16
  84. package/docs/investments/reason-to-rule/interfaces/IReasonToRule.md +0 -189
  85. package/docs/investments/reason-to-rule/interfaces/IReasonToRuleMeta.md +0 -33
  86. package/docs/investments/rental-investor-validator/classes/RentalInvestorValidator.md +0 -53
  87. package/docs/investments/rental-investor-validator/index.md +0 -15
  88. package/docs/investments/rental-investor-validator/interfaces/IRentalInvestorValidator.md +0 -25
  89. package/docs/investments/user-invest-result/classes/UserInvestResult.md +0 -65
  90. package/docs/investments/user-invest-result/index.md +0 -15
  91. package/docs/investments/user-invest-result/interfaces/IUserInvestResult.md +0 -25
  92. package/docs/investments/user-result-estimates/index.md +0 -11
  93. package/docs/investments/user-result-estimates/type-aliases/UserResultEstimates.md +0 -33
  94. package/docs/ledger/i-ledger-summary/index.md +0 -11
  95. package/docs/ledger/i-ledger-summary/interfaces/ILedgerSummary.md +0 -57
  96. package/docs/ledger/index.md +0 -43
  97. package/docs/ledger/ledger-collection/classes/LedgerCollection.md +0 -425
  98. package/docs/ledger/ledger-collection/index.md +0 -19
  99. package/docs/ledger/ledger-collection/interfaces/ILedgerCollection.md +0 -313
  100. package/docs/ledger/ledger-collection/type-aliases/LedgerItemPredicate.md +0 -25
  101. package/docs/ledger/ledger-item/classes/LedgerItem.md +0 -211
  102. package/docs/ledger/ledger-item/index.md +0 -11
  103. package/docs/ledger/ledger-item-type/enumerations/LedgerItemType.md +0 -57
  104. package/docs/ledger/ledger-item-type/index.md +0 -11
  105. package/docs/loans/i-loan-settings/index.md +0 -11
  106. package/docs/loans/i-loan-settings/interfaces/ILoanSetting.md +0 -33
  107. package/docs/loans/index.md +0 -19
  108. package/docs/loans/loan-settings/enumerations/LoanSettings.md +0 -41
  109. package/docs/loans/loan-settings/index.md +0 -11
  110. package/docs/modules.md +0 -88
  111. package/docs/properties/i-entity-existence/index.md +0 -11
  112. package/docs/properties/i-entity-existence/interfaces/IEntityExistence.md +0 -33
  113. package/docs/properties/i-property-entity/index.md +0 -11
  114. package/docs/properties/i-property-entity/interfaces/IPropertyEntity.md +0 -159
  115. package/docs/properties/i-rental-property-entity/index.md +0 -11
  116. package/docs/properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md +0 -416
  117. package/docs/properties/index.md +0 -43
  118. package/docs/properties/property-sort/functions/default.md +0 -35
  119. package/docs/properties/property-sort/index.md +0 -11
  120. package/docs/properties/property-type/enumerations/PropertyType.md +0 -33
  121. package/docs/properties/property-type/index.md +0 -11
  122. package/docs/properties/rental-passive-apartment/classes/RentalPassiveApartment.md +0 -558
  123. package/docs/properties/rental-passive-apartment/index.md +0 -11
  124. package/docs/properties/rental-single-family/classes/RentalSingleFamily.md +0 -639
  125. package/docs/properties/rental-single-family/index.md +0 -11
  126. package/docs/rules/eval-type/index.md +0 -11
  127. package/docs/rules/eval-type/type-aliases/EvalType.md +0 -25
  128. package/docs/rules/eval-types/functions/AtLeastOrMore.md +0 -25
  129. package/docs/rules/eval-types/functions/NoMoreThan.md +0 -25
  130. package/docs/rules/eval-types/index.md +0 -12
  131. package/docs/rules/get-enum-type-by-value/functions/getEnumTypeByValue.md +0 -23
  132. package/docs/rules/get-enum-type-by-value/index.md +0 -11
  133. package/docs/rules/get-rules/functions/getRules.md +0 -27
  134. package/docs/rules/get-rules/index.md +0 -11
  135. package/docs/rules/hold-rule-types/enumerations/HoldRuleTypes.md +0 -49
  136. package/docs/rules/hold-rule-types/index.md +0 -11
  137. package/docs/rules/i-rule/index.md +0 -11
  138. package/docs/rules/i-rule/interfaces/IRule.md +0 -41
  139. package/docs/rules/index.md +0 -67
  140. package/docs/rules/purchase-rule-types/enumerations/PurchaseRuleTypes.md +0 -78
  141. package/docs/rules/purchase-rule-types/index.md +0 -11
  142. package/docs/rules/rule-evaluation/classes/RuleEvaluation.md +0 -103
  143. package/docs/rules/rule-evaluation/index.md +0 -15
  144. package/docs/rules/rule-evaluation/interfaces/IRuleEvaluation.md +0 -73
  145. package/docs/time/default-has-met-goal-or-max-time/functions/defaultHasMetGoalOrMaxTime.md +0 -39
  146. package/docs/time/default-has-met-goal-or-max-time/index.md +0 -11
  147. package/docs/time/has-met-goal-or-max-time/index.md +0 -11
  148. package/docs/time/has-met-goal-or-max-time/type-aliases/HasMetGoalOrMaxTime.md +0 -39
  149. package/docs/time/i-historical-property/index.md +0 -11
  150. package/docs/time/i-historical-property/interfaces/IHistoricalProperty.md +0 -25
  151. package/docs/time/i-historical-reason/index.md +0 -11
  152. package/docs/time/i-historical-reason/interfaces/IHistoricalReason.md +0 -25
  153. package/docs/time/i-loop-options/index.md +0 -11
  154. package/docs/time/i-loop-options/interfaces/ILoopOptions.md +0 -71
  155. package/docs/time/i-loop-recursive-options/index.md +0 -11
  156. package/docs/time/i-loop-recursive-options/interfaces/ILoopRecursiveOptions.md +0 -33
  157. package/docs/time/index.md +0 -85
  158. package/docs/time/looper/functions/looper.md +0 -25
  159. package/docs/time/looper/index.md +0 -15
  160. package/docs/time/looper/type-aliases/LooperType.md +0 -25
  161. package/docs/time/movement/functions/movement.md +0 -27
  162. package/docs/time/movement/index.md +0 -11
  163. package/docs/time/simulate/functions/simulate.md +0 -23
  164. package/docs/time/simulate/index.md +0 -16
  165. package/docs/time/simulate/interfaces/IGenOptions.md +0 -163
  166. package/docs/time/simulate/interfaces/ISimulateOptions.md +0 -115
  167. package/docs/time/timeline/classes/Timeline.md +0 -175
  168. package/docs/time/timeline/index.md +0 -15
  169. package/docs/time/timeline/interfaces/ITimeline.md +0 -83
  170. package/docs/time/update-historical-rentals/functions/updateHistoricalRentals.md +0 -41
  171. package/docs/time/update-historical-rentals/index.md +0 -11
  172. package/docs/utils/data-are-same-date/functions/default.md +0 -25
  173. package/docs/utils/data-are-same-date/index.md +0 -11
  174. package/docs/utils/data-clone-date/functions/cloneDateUtc.md +0 -27
  175. package/docs/utils/data-clone-date/index.md +0 -11
  176. package/docs/utils/data-compare-date/functions/default.md +0 -28
  177. package/docs/utils/data-compare-date/index.md +0 -11
  178. package/docs/utils/data-number/functions/randomNumberBetween.md +0 -25
  179. package/docs/utils/data-number/index.md +0 -11
  180. package/docs/utils/data-property-entity/functions/randomPropertyEntity.md +0 -23
  181. package/docs/utils/data-property-entity/index.md +0 -15
  182. package/docs/utils/data-property-entity/type-aliases/RandomPropertyEntity.md +0 -21
  183. package/docs/utils/ensure/functions/ensureArray.md +0 -39
  184. package/docs/utils/ensure/index.md +0 -15
  185. package/docs/utils/ensure/type-aliases/EnsureArrayPredicate.md +0 -29
  186. package/docs/utils/index.md +0 -43
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [5.7.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.6.0...v5.7.0) (2026-01-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * quarterly summaries ([#75](https://github.com/kvernon/realty-investor-timeline/issues/75)) ([5401e78](https://github.com/kvernon/realty-investor-timeline/commit/5401e786d118bb9accb4fa7418fd05cddd481fea))
7
+
8
+ # [5.6.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.5.1...v5.6.0) (2026-01-13)
9
+
10
+
11
+ ### Features
12
+
13
+ * quarterly cash flow ([#74](https://github.com/kvernon/realty-investor-timeline/issues/74)) ([8700a3c](https://github.com/kvernon/realty-investor-timeline/commit/8700a3c889d865cc6f31a61c4a230b046606602c))
14
+
1
15
  ## [5.5.1](https://github.com/kvernon/realty-investor-timeline/compare/v5.5.0...v5.5.1) (2026-01-02)
2
16
 
3
17
 
@@ -8,4 +8,9 @@ export interface IUserGoal {
8
8
  * @param today
9
9
  */
10
10
  metMonthlyGoal(today: Date): boolean;
11
+ /**
12
+ * takes data from a quarterly average cash flow and compares it to the monthly goal. The reason on quarterly is that apartments do distributions quarterly, so you have to spread those out monthly
13
+ * @param today
14
+ */
15
+ metAverageQuarterlyGoal(today: Date): boolean;
11
16
  }
@@ -14,10 +14,15 @@ export interface IUser extends IUserInvestorCheck {
14
14
  */
15
15
  monthlySavedAmount: number;
16
16
  /**
17
- * method used to help determine if you have met your expenses
17
+ * returns your passive income for the year + month date supplied
18
18
  * @param today
19
19
  */
20
20
  getCashFlowMonth(today: Date): number;
21
+ /**
22
+ * returns the cash flow by a quarter. This is ideal when evaluating your distributions that are not monthly.
23
+ * @param today
24
+ */
25
+ getCashFlowQuarter(today: Date): number;
21
26
  clone(): IUser;
22
27
  }
23
28
  export declare class User implements IUser {
@@ -38,6 +43,20 @@ export declare class User implements IUser {
38
43
  * @param today
39
44
  */
40
45
  metMonthlyGoal(today: Date): boolean;
46
+ /**
47
+ * takes data from a quarterly average cash flow and compares it to the monthly goal. The reason on quarterly is that apartments do distributions quarterly, so you have to spread those out monthly
48
+ * @param today
49
+ */
50
+ metAverageQuarterlyGoal(today: Date): boolean;
51
+ /**
52
+ * returns the cash flow by a quarter. This is ideal when evaluating your distributions that are not monthly.
53
+ * @param today
54
+ */
55
+ getCashFlowQuarter(today: Date): number;
56
+ /**
57
+ * returns your passive income for the year + month date supplied
58
+ * @param today
59
+ */
41
60
  getCashFlowMonth(today: Date): number;
42
61
  /**
43
62
  * an amount which the user can save per month after expenses, like, after my pay check I could put this amount into savings
@@ -28,6 +28,27 @@ class User {
28
28
  metMonthlyGoal(today) {
29
29
  return this.getCashFlowMonth(today) >= this.monthlyIncomeAmountGoal;
30
30
  }
31
+ /**
32
+ * takes data from a quarterly average cash flow and compares it to the monthly goal. The reason on quarterly is that apartments do distributions quarterly, so you have to spread those out monthly
33
+ * @param today
34
+ */
35
+ metAverageQuarterlyGoal(today) {
36
+ return this.getCashFlowQuarter(today) >= this.monthlyIncomeAmountGoal;
37
+ }
38
+ /**
39
+ * returns the cash flow by a quarter. This is ideal when evaluating your distributions that are not monthly.
40
+ * @param today
41
+ */
42
+ getCashFlowQuarter(today) {
43
+ if (!this.ledgerCollection) {
44
+ return 0;
45
+ }
46
+ return (0, currency_1.default)(this.ledgerCollection.getAverageCashFlowMonthByQuarter(today));
47
+ }
48
+ /**
49
+ * returns your passive income for the year + month date supplied
50
+ * @param today
51
+ */
31
52
  getCashFlowMonth(today) {
32
53
  if (!this.ledgerCollection) {
33
54
  return 0;
@@ -6,3 +6,9 @@ export interface ILedgerSummary {
6
6
  purchases: number;
7
7
  equity: number;
8
8
  }
9
+ export interface ILedgerDetailSummary extends ILedgerSummary {
10
+ /**
11
+ * a way to determine the average monthly cash flow using the quarterly totals
12
+ */
13
+ averageQuarterlyCashFlow: number;
14
+ }
@@ -1,5 +1,5 @@
1
1
  import { LedgerItem } from './ledger-item';
2
- import { ILedgerSummary } from './i-ledger-summary';
2
+ import { ILedgerDetailSummary, ILedgerSummary } from './i-ledger-summary';
3
3
  import { LedgerItemType } from './ledger-item-type';
4
4
  import { IRentalPropertyEntity } from '../properties';
5
5
  export interface ILedgerCollection {
@@ -11,6 +11,8 @@ export interface ILedgerCollection {
11
11
  filter(pred?: LedgerItemPredicate): LedgerItem[];
12
12
  add(item: LedgerItem | Iterable<LedgerItem>): void;
13
13
  getCashFlowMonth(date?: Date): number;
14
+ getAverageCashFlowMonthByQuarter(date?: Date): number;
15
+ getCashFlowQuarter(date?: Date): number;
14
16
  /**
15
17
  * This method gets the total of savings needed for all properties by x amount of months.
16
18
  * @example
@@ -103,7 +105,9 @@ export declare class LedgerCollection implements ILedgerCollection {
103
105
  */
104
106
  getCashFlowYearAverage(date?: Date): number;
105
107
  getCashFlowMonth(date?: Date): number;
106
- getSummaryMonth(date: Date): ILedgerSummary;
108
+ getAverageCashFlowMonthByQuarter(date?: Date): number;
109
+ getCashFlowQuarter(date?: Date): number;
110
+ getSummaryMonth(date: Date): ILedgerDetailSummary;
107
111
  getSummaryAnnual(year?: number): ILedgerSummary;
108
112
  getSummariesAnnual(year?: number): ILedgerSummary[];
109
113
  /**
@@ -10,6 +10,7 @@ const properties_1 = require("../properties");
10
10
  const currency_1 = __importDefault(require("../formatters/currency"));
11
11
  const data_clone_date_1 = require("../utils/data-clone-date");
12
12
  const date_fns_1 = require("date-fns");
13
+ const get_date_quarter_1 = require("../utils/get-date-quarter");
13
14
  class LedgerCollection {
14
15
  collection;
15
16
  getSummaryByType(collection, type) {
@@ -124,6 +125,43 @@ class LedgerCollection {
124
125
  }
125
126
  return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
126
127
  }
128
+ getAverageCashFlowMonthByQuarter(date) {
129
+ if (this.isEmpty()) {
130
+ return 0;
131
+ }
132
+ if (!date) {
133
+ date = this.collection.last().created;
134
+ }
135
+ const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
136
+ const boundary = this.filter((li) => {
137
+ return li.dateLessThanOrEqualToAndQuarter(date, quarter);
138
+ });
139
+ if (boundary.length === 0) {
140
+ return 0;
141
+ }
142
+ const cashFlowItems = boundary.filter((x) => x.typeMatches(ledger_item_type_1.LedgerItemType.CashFlow));
143
+ if (cashFlowItems.length === 0) {
144
+ return 0;
145
+ }
146
+ const firstMonth = cashFlowItems[0].created.getUTCMonth();
147
+ const lastMonth = cashFlowItems[cashFlowItems.length - 1].created.getUTCMonth();
148
+ const monthsWithData = lastMonth - firstMonth + 1;
149
+ const totalCashFlow = this.getCashFlowQuarter(date);
150
+ return (0, currency_1.default)(totalCashFlow / monthsWithData);
151
+ }
152
+ getCashFlowQuarter(date) {
153
+ if (this.isEmpty()) {
154
+ return 0;
155
+ }
156
+ if (!date) {
157
+ date = this.collection.last().created;
158
+ }
159
+ const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
160
+ const boundary = this.filter((li) => {
161
+ return li.dateLessThanOrEqualToAndQuarter(date, quarter);
162
+ });
163
+ return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
164
+ }
127
165
  getSummaryMonth(date) {
128
166
  if (!date) {
129
167
  throw new Error('no date supplied');
@@ -133,6 +171,7 @@ class LedgerCollection {
133
171
  balance: 0,
134
172
  cashFlow: 0,
135
173
  averageCashFlow: 0,
174
+ averageQuarterlyCashFlow: 0,
136
175
  equity: 0,
137
176
  purchases: 0,
138
177
  };
@@ -149,6 +188,7 @@ class LedgerCollection {
149
188
  result.equity = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Equity);
150
189
  result.purchases = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Purchase);
151
190
  result.balance = this.filter((li) => li.dateNotGreaterThan(date)).reduce((previousValue, currentValue) => previousValue + currentValue.amount, 0);
191
+ result.averageQuarterlyCashFlow = this.getAverageCashFlowMonthByQuarter(date);
152
192
  return result;
153
193
  }
154
194
  getSummaryAnnual(year) {
@@ -186,7 +226,6 @@ class LedgerCollection {
186
226
  }
187
227
  const collection = [];
188
228
  const lastLedgerItem = boundary[boundary.length - 1];
189
- //need to determine monthDiff between boundary
190
229
  const totalMonths = (0, date_fns_1.differenceInMonths)(boundary[0].created, lastLedgerItem.created);
191
230
  if (totalMonths === 0) {
192
231
  collection.push(this.getSummaryMonth(boundary[0].created));
@@ -1,4 +1,5 @@
1
1
  import { LedgerItemType } from './ledger-item-type';
2
+ import { QuarterType } from '../utils/get-date-quarter';
2
3
  /**
3
4
  * this is an entry into the account. Think of it as a checking account, and it's simply a transaction line.
4
5
  */
@@ -9,11 +10,27 @@ export declare class LedgerItem {
9
10
  note?: string;
10
11
  constructor(amount?: number, type?: LedgerItemType, created?: Date, note?: string);
11
12
  getMonth(): number;
13
+ /**
14
+ * if one is found, a zero based quarter number, otherwise you'll get -1
15
+ */
16
+ getQuarter(): -1 | QuarterType;
12
17
  isAmountGreaterThanZero(): boolean;
13
18
  dateMatchesYearAndMonth(today: Date): boolean;
14
19
  dateLessThanOrEqualTo(today: Date): boolean;
15
20
  dateNotGreaterThan(today: Date): boolean;
16
21
  dateMatchesYear(year: number): boolean;
22
+ /**
23
+ * returns true if the date is less than or equal to the date passed in and the quarter matches
24
+ * @param date
25
+ * @param quarter
26
+ */
27
+ dateLessThanOrEqualToAndQuarter(date: Date, quarter: QuarterType): boolean;
28
+ /**
29
+ * @deprecated, use {@link dateLessThanOrEqualToAndQuarter}
30
+ * @param year
31
+ * @param quarter
32
+ */
33
+ dateMatchesYearAndQuarter(year: number, quarter: number): boolean;
17
34
  typeMatches(itemType: LedgerItemType): boolean;
18
35
  getYear(): number;
19
36
  clone(): LedgerItem;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LedgerItem = void 0;
7
7
  const ledger_item_type_1 = require("./ledger-item-type");
8
8
  const data_compare_date_1 = __importDefault(require("../utils/data-compare-date"));
9
+ const get_date_quarter_1 = require("../utils/get-date-quarter");
9
10
  /**
10
11
  * this is an entry into the account. Think of it as a checking account, and it's simply a transaction line.
11
12
  */
@@ -30,6 +31,15 @@ class LedgerItem {
30
31
  }
31
32
  return this.created.getUTCMonth();
32
33
  }
34
+ /**
35
+ * if one is found, a zero based quarter number, otherwise you'll get -1
36
+ */
37
+ getQuarter() {
38
+ if (!this.created) {
39
+ return -1;
40
+ }
41
+ return (0, get_date_quarter_1.getDateQuarter)(this.created);
42
+ }
33
43
  isAmountGreaterThanZero() {
34
44
  return this.amount > 0;
35
45
  }
@@ -60,6 +70,34 @@ class LedgerItem {
60
70
  }
61
71
  return year === this.created.getUTCFullYear();
62
72
  }
73
+ /**
74
+ * returns true if the date is less than or equal to the date passed in and the quarter matches
75
+ * @param date
76
+ * @param quarter
77
+ */
78
+ dateLessThanOrEqualToAndQuarter(date, quarter) {
79
+ if (!this.created) {
80
+ return false;
81
+ }
82
+ if (!this.dateLessThanOrEqualTo(date)) {
83
+ return false;
84
+ }
85
+ return this.getQuarter() === quarter;
86
+ }
87
+ /**
88
+ * @deprecated, use {@link dateLessThanOrEqualToAndQuarter}
89
+ * @param year
90
+ * @param quarter
91
+ */
92
+ dateMatchesYearAndQuarter(year, quarter) {
93
+ if (!this.created) {
94
+ return false;
95
+ }
96
+ if (!this.dateMatchesYear(year)) {
97
+ return false;
98
+ }
99
+ return this.getQuarter() === quarter;
100
+ }
63
101
  typeMatches(itemType) {
64
102
  return this.type === itemType;
65
103
  }
@@ -14,7 +14,7 @@ const defaultHasMetGoalOrMaxTime = (start, today, user, maxYears) => {
14
14
  if ((0, date_fns_1.isEqual)(start, today) && !user) {
15
15
  return false;
16
16
  }
17
- if (user && user.metMonthlyGoal(today)) {
17
+ if (user && user.metAverageQuarterlyGoal(today)) {
18
18
  return true;
19
19
  }
20
20
  const maxDate = (0, data_clone_date_1.cloneDateUtc)(start, (date) => {
@@ -42,7 +42,7 @@ const looper = (options, timeline) => {
42
42
  }
43
43
  }
44
44
  }
45
- if (result.user.metMonthlyGoal(result.endDate)) {
45
+ if (result.user.metAverageQuarterlyGoal(result.endDate)) {
46
46
  return result;
47
47
  }
48
48
  //step 3: sell properties
@@ -0,0 +1,9 @@
1
+ /**
2
+ * zero based quarter numbers
3
+ */
4
+ export type QuarterType = 0 | 1 | 2 | 3;
5
+ /**
6
+ * takes a date and return the quarter it belongs to, which will be 0, 1, 2, or 3
7
+ * @param date
8
+ */
9
+ export declare const getDateQuarter: (date: Date) => QuarterType;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDateQuarter = void 0;
4
+ /**
5
+ * takes a date and return the quarter it belongs to, which will be 0, 1, 2, or 3
6
+ * @param date
7
+ */
8
+ const getDateQuarter = (date) => Math.floor(date.getUTCMonth() / 3);
9
+ exports.getDateQuarter = getDateQuarter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubedelement.com/realty-investor-timeline",
3
- "version": "5.5.1",
3
+ "version": "5.7.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",
@@ -1,10 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: "npm"
4
- directory: "/"
5
- schedule:
6
- interval: "weekly"
7
- pull-request-branch-name:
8
- separator: "-"
9
- prefix: "feature/"
10
- version: "patch"
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="116" height="20" role="img" aria-label="Coverage: 89.34%"><title>Coverage: 89.34%</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="116" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="63" height="20" fill="#555"/><rect x="63" width="53" height="20" fill="#dfb317"/><rect width="116" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="325" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="530">Coverage</text><text x="325" y="140" transform="scale(.1)" fill="#fff" textLength="530">Coverage</text><text aria-hidden="true" x="885" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">89.34%</text><text x="885" y="140" transform="scale(.1)" fill="#fff" textLength="430">89.34%</text></g></svg>
@@ -1,11 +0,0 @@
1
- [**@cubedelement.com/realty-investor-timeline**](../../index.md)
2
-
3
- ---
4
-
5
- [@cubedelement.com/realty-investor-timeline](../../modules.md) / account/i-user-goal
6
-
7
- # account/i-user-goal
8
-
9
- ## Interfaces
10
-
11
- - [IUserGoal](interfaces/IUserGoal.md)
@@ -1,47 +0,0 @@
1
- [**@cubedelement.com/realty-investor-timeline**](../../../index.md)
2
-
3
- ---
4
-
5
- [@cubedelement.com/realty-investor-timeline](../../../modules.md) / [account/i-user-goal](../index.md) / IUserGoal
6
-
7
- # Interface: IUserGoal
8
-
9
- Defined in: [account/i-user-goal.ts:3](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-goal.ts#L3)
10
-
11
- ## Extended by
12
-
13
- - [`IUserInvestorCheck`](../../i-user-investor-check/interfaces/IUserInvestorCheck.md)
14
-
15
- ## Properties
16
-
17
- ### monthlyIncomeAmountGoal
18
-
19
- > **monthlyIncomeAmountGoal**: `number`
20
-
21
- Defined in: [account/i-user-goal.ts:7](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-goal.ts#L7)
22
-
23
- used to determine how much you need want for monthly expenses
24
-
25
- ## Methods
26
-
27
- ### metMonthlyGoal()
28
-
29
- > **metMonthlyGoal**(`today`, `properties`): `boolean`
30
-
31
- Defined in: [account/i-user-goal.ts:14](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-goal.ts#L14)
32
-
33
- method used to help determine if you have met your expenses
34
-
35
- #### Parameters
36
-
37
- ##### today
38
-
39
- `Date`
40
-
41
- ##### properties
42
-
43
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
44
-
45
- #### Returns
46
-
47
- `boolean`
@@ -1,11 +0,0 @@
1
- [**@cubedelement.com/realty-investor-timeline**](../../index.md)
2
-
3
- ---
4
-
5
- [@cubedelement.com/realty-investor-timeline](../../modules.md) / account/i-user-investor-check
6
-
7
- # account/i-user-investor-check
8
-
9
- ## Interfaces
10
-
11
- - [IUserInvestorCheck](interfaces/IUserInvestorCheck.md)
@@ -1,206 +0,0 @@
1
- [**@cubedelement.com/realty-investor-timeline**](../../../index.md)
2
-
3
- ---
4
-
5
- [@cubedelement.com/realty-investor-timeline](../../../modules.md) / [account/i-user-investor-check](../index.md) / IUserInvestorCheck
6
-
7
- # Interface: IUserInvestorCheck
8
-
9
- Defined in: [account/i-user-investor-check.ts:9](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L9)
10
-
11
- ## Extends
12
-
13
- - [`IUserGoal`](../../i-user-goal/interfaces/IUserGoal.md)
14
-
15
- ## Extended by
16
-
17
- - [`IUser`](../../user/interfaces/IUser.md)
18
-
19
- ## Properties
20
-
21
- ### holdRules
22
-
23
- > **holdRules**: [`IRuleEvaluation`](../../../rules/rule-evaluation/interfaces/IRuleEvaluation.md)\<[`HoldRuleTypes`](../../../rules/hold-rule-types/enumerations/HoldRuleTypes.md)\>[]
24
-
25
- Defined in: [account/i-user-investor-check.ts:23](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L23)
26
-
27
- a system to determine how to hold onto the properties the longest. This scenario says as long as it meets 1 rule
28
-
29
- ---
30
-
31
- ### ledgerCollection
32
-
33
- > `readonly` **ledgerCollection**: [`ILedgerCollection`](../../../ledger/ledger-collection/interfaces/ILedgerCollection.md)
34
-
35
- Defined in: [account/i-user-investor-check.ts:13](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L13)
36
-
37
- the collection which is used to keep a balance sheet.
38
-
39
- ---
40
-
41
- ### loanSettings
42
-
43
- > **loanSettings**: [`ILoanSetting`](../../../loans/i-loan-settings/interfaces/ILoanSetting.md)[]
44
-
45
- Defined in: [account/i-user-investor-check.ts:18](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L18)
46
-
47
- a collection of loan settings for how to get a loan for single family or some other kind of property
48
-
49
- ---
50
-
51
- ### monthlyIncomeAmountGoal
52
-
53
- > **monthlyIncomeAmountGoal**: `number`
54
-
55
- Defined in: [account/i-user-goal.ts:7](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-goal.ts#L7)
56
-
57
- used to determine how much you need want for monthly expenses
58
-
59
- #### Inherited from
60
-
61
- [`IUserGoal`](../../i-user-goal/interfaces/IUserGoal.md).[`monthlyIncomeAmountGoal`](../../i-user-goal/interfaces/IUserGoal.md#monthlyincomeamountgoal)
62
-
63
- ---
64
-
65
- ### purchaseRules
66
-
67
- > **purchaseRules**: [`IRuleEvaluation`](../../../rules/rule-evaluation/interfaces/IRuleEvaluation.md)\<[`PurchaseRuleTypes`](../../../rules/purchase-rule-types/enumerations/PurchaseRuleTypes.md)\>[]
68
-
69
- Defined in: [account/i-user-investor-check.ts:60](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L60)
70
-
71
- a system to weed out the properties you don't want. This scenario says as long as it meets 1 rule
72
-
73
- ## Methods
74
-
75
- ### getAvailableSavings()
76
-
77
- > **getAvailableSavings**(`date`, `properties`): `number`
78
-
79
- Defined in: [account/i-user-investor-check.ts:55](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L55)
80
-
81
- should be the total balance - savings, using [getMinimumSavings](IUserInvestorCheck.md#getminimumsavings), for determining monthly cash to save for single family properties
82
-
83
- #### Parameters
84
-
85
- ##### date
86
-
87
- `Date`
88
-
89
- ##### properties
90
-
91
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
92
-
93
- #### Returns
94
-
95
- `number`
96
-
97
- ---
98
-
99
- ### getMinimumSavings()
100
-
101
- > **getMinimumSavings**(`date`, `properties`): `number`
102
-
103
- Defined in: [account/i-user-investor-check.ts:48](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L48)
104
-
105
- used to retrieve the amount required to keep in savings
106
-
107
- #### Parameters
108
-
109
- ##### date
110
-
111
- `Date`
112
-
113
- ##### properties
114
-
115
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
116
-
117
- #### Returns
118
-
119
- `number`
120
-
121
- ---
122
-
123
- ### hasMinimumSavings()
124
-
125
- > **hasMinimumSavings**(`date`, `properties`): `boolean`
126
-
127
- Defined in: [account/i-user-investor-check.ts:41](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L41)
128
-
129
- a way to determine if the user has enough money. This is different because with
130
- single family homes, you would have to save a certain amount of monthly mortgage
131
-
132
- #### Parameters
133
-
134
- ##### date
135
-
136
- `Date`
137
-
138
- ##### properties
139
-
140
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
141
-
142
- #### Returns
143
-
144
- `boolean`
145
-
146
- ---
147
-
148
- ### hasMoneyToInvest()
149
-
150
- > **hasMoneyToInvest**(`date`, `properties`, `contribution`?): `boolean`
151
-
152
- Defined in: [account/i-user-investor-check.ts:33](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-investor-check.ts#L33)
153
-
154
- based upon [getMinimumSavings](IUserInvestorCheck.md#getminimumsavings), it checks to see if there is an amount remaining that can be used along with the [contribution](IUserInvestorCheck.md#contribution).
155
-
156
- #### Parameters
157
-
158
- ##### date
159
-
160
- `Date`
161
-
162
- ##### properties
163
-
164
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
165
-
166
- ##### contribution?
167
-
168
- `number`
169
-
170
- #### Returns
171
-
172
- `boolean`
173
-
174
- #### Example
175
-
176
- ```ts
177
- availableSavings - contribution >= 0;
178
- ```
179
-
180
- ---
181
-
182
- ### metMonthlyGoal()
183
-
184
- > **metMonthlyGoal**(`today`, `properties`): `boolean`
185
-
186
- Defined in: [account/i-user-goal.ts:14](https://github.com/kvernon/realty-investor-timeline/blob/c7446a8a5576468ac5874a2dd8323180fa97a55b/src/account/i-user-goal.ts#L14)
187
-
188
- method used to help determine if you have met your expenses
189
-
190
- #### Parameters
191
-
192
- ##### today
193
-
194
- `Date`
195
-
196
- ##### properties
197
-
198
- [`IRentalPropertyEntity`](../../../properties/i-rental-property-entity/interfaces/IRentalPropertyEntity.md)[]
199
-
200
- #### Returns
201
-
202
- `boolean`
203
-
204
- #### Inherited from
205
-
206
- [`IUserGoal`](../../i-user-goal/interfaces/IUserGoal.md).[`metMonthlyGoal`](../../i-user-goal/interfaces/IUserGoal.md#metmonthlygoal)