@cubedelement.com/realty-investor-timeline 5.6.0 → 5.7.1

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.7.1](https://github.com/kvernon/realty-investor-timeline/compare/v5.7.0...v5.7.1) (2026-01-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * interface and infinity corrections ([#76](https://github.com/kvernon/realty-investor-timeline/issues/76)) ([3b38a43](https://github.com/kvernon/realty-investor-timeline/commit/3b38a43046b821670eff699553e7a59aa48f70f6))
7
+
8
+ # [5.7.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.6.0...v5.7.0) (2026-01-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * quarterly summaries ([#75](https://github.com/kvernon/realty-investor-timeline/issues/75)) ([5401e78](https://github.com/kvernon/realty-investor-timeline/commit/5401e786d118bb9accb4fa7418fd05cddd481fea))
14
+
1
15
  # [5.6.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.5.1...v5.6.0) (2026-01-13)
2
16
 
3
17
 
@@ -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 {
@@ -45,7 +45,7 @@ export interface ILedgerCollection {
45
45
  * @param date
46
46
  */
47
47
  getCashFlowYearAverage(date?: Date): number;
48
- getSummaryMonth(date: Date): ILedgerSummary;
48
+ getSummaryMonth(date: Date): ILedgerDetailSummary;
49
49
  getSummaryAnnual(year?: number): ILedgerSummary;
50
50
  getSummariesAnnual(year?: number): ILedgerSummary[];
51
51
  /**
@@ -107,7 +107,7 @@ export declare class LedgerCollection implements ILedgerCollection {
107
107
  getCashFlowMonth(date?: Date): number;
108
108
  getAverageCashFlowMonthByQuarter(date?: Date): number;
109
109
  getCashFlowQuarter(date?: Date): number;
110
- getSummaryMonth(date: Date): ILedgerSummary;
110
+ getSummaryMonth(date: Date): ILedgerDetailSummary;
111
111
  getSummaryAnnual(year?: number): ILedgerSummary;
112
112
  getSummariesAnnual(year?: number): ILedgerSummary[];
113
113
  /**
@@ -132,10 +132,9 @@ class LedgerCollection {
132
132
  if (!date) {
133
133
  date = this.collection.last().created;
134
134
  }
135
- const quarter = Math.floor(date.getUTCMonth() / 3);
136
- const year = date.getUTCFullYear();
135
+ const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
137
136
  const boundary = this.filter((li) => {
138
- return li.dateMatchesYearAndQuarter(year, quarter);
137
+ return li.dateLessThanOrEqualToAndQuarter(date, quarter);
139
138
  });
140
139
  if (boundary.length === 0) {
141
140
  return 0;
@@ -144,14 +143,14 @@ class LedgerCollection {
144
143
  if (cashFlowItems.length === 0) {
145
144
  return 0;
146
145
  }
147
- if (cashFlowItems.length === 0) {
148
- return 0;
149
- }
150
146
  const firstMonth = cashFlowItems[0].created.getUTCMonth();
151
147
  const lastMonth = cashFlowItems[cashFlowItems.length - 1].created.getUTCMonth();
152
148
  const monthsWithData = lastMonth - firstMonth + 1;
153
149
  const totalCashFlow = this.getCashFlowQuarter(date);
154
- return totalCashFlow / monthsWithData;
150
+ if (totalCashFlow === 0) {
151
+ return 0;
152
+ }
153
+ return (0, currency_1.default)(totalCashFlow / monthsWithData);
155
154
  }
156
155
  getCashFlowQuarter(date) {
157
156
  if (this.isEmpty()) {
@@ -161,9 +160,8 @@ class LedgerCollection {
161
160
  date = this.collection.last().created;
162
161
  }
163
162
  const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
164
- const year = date.getUTCFullYear();
165
163
  const boundary = this.filter((li) => {
166
- return li.dateMatchesYearAndQuarter(year, quarter);
164
+ return li.dateLessThanOrEqualToAndQuarter(date, quarter);
167
165
  });
168
166
  return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
169
167
  }
@@ -176,6 +174,7 @@ class LedgerCollection {
176
174
  balance: 0,
177
175
  cashFlow: 0,
178
176
  averageCashFlow: 0,
177
+ averageQuarterlyCashFlow: 0,
179
178
  equity: 0,
180
179
  purchases: 0,
181
180
  };
@@ -192,6 +191,7 @@ class LedgerCollection {
192
191
  result.equity = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Equity);
193
192
  result.purchases = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Purchase);
194
193
  result.balance = this.filter((li) => li.dateNotGreaterThan(date)).reduce((previousValue, currentValue) => previousValue + currentValue.amount, 0);
194
+ result.averageQuarterlyCashFlow = this.getAverageCashFlowMonthByQuarter(date);
195
195
  return result;
196
196
  }
197
197
  getSummaryAnnual(year) {
@@ -229,7 +229,6 @@ class LedgerCollection {
229
229
  }
230
230
  const collection = [];
231
231
  const lastLedgerItem = boundary[boundary.length - 1];
232
- //need to determine monthDiff between boundary
233
232
  const totalMonths = (0, date_fns_1.differenceInMonths)(boundary[0].created, lastLedgerItem.created);
234
233
  if (totalMonths === 0) {
235
234
  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
  */
@@ -12,12 +13,23 @@ export declare class LedgerItem {
12
13
  /**
13
14
  * if one is found, a zero based quarter number, otherwise you'll get -1
14
15
  */
15
- getQuarter(): number;
16
+ getQuarter(): -1 | QuarterType;
16
17
  isAmountGreaterThanZero(): boolean;
17
18
  dateMatchesYearAndMonth(today: Date): boolean;
18
19
  dateLessThanOrEqualTo(today: Date): boolean;
19
20
  dateNotGreaterThan(today: Date): boolean;
20
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
+ */
21
33
  dateMatchesYearAndQuarter(year: number, quarter: number): boolean;
22
34
  typeMatches(itemType: LedgerItemType): boolean;
23
35
  getYear(): number;
@@ -70,6 +70,25 @@ class LedgerItem {
70
70
  }
71
71
  return year === this.created.getUTCFullYear();
72
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
+ */
73
92
  dateMatchesYearAndQuarter(year, quarter) {
74
93
  if (!this.created) {
75
94
  return false;
@@ -1 +1,9 @@
1
- export declare const getDateQuarter: (date: Date) => number;
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;
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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
+ */
4
8
  const getDateQuarter = (date) => Math.floor(date.getUTCMonth() / 3);
5
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.6.0",
3
+ "version": "5.7.1",
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",