@cubedelement.com/realty-investor-timeline 5.6.0 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/src/ledger/i-ledger-summary.d.ts +6 -0
- package/dist/src/ledger/ledger-collection.d.ts +2 -2
- package/dist/src/ledger/ledger-collection.js +6 -10
- package/dist/src/ledger/ledger-item.d.ts +13 -1
- package/dist/src/ledger/ledger-item.js +19 -0
- package/dist/src/utils/get-date-quarter.d.ts +9 -1
- package/dist/src/utils/get-date-quarter.js +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
# [5.6.0](https://github.com/kvernon/realty-investor-timeline/compare/v5.5.1...v5.6.0) (2026-01-13)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -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 {
|
|
@@ -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):
|
|
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 =
|
|
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.
|
|
137
|
+
return li.dateLessThanOrEqualToAndQuarter(date, quarter);
|
|
139
138
|
});
|
|
140
139
|
if (boundary.length === 0) {
|
|
141
140
|
return 0;
|
|
@@ -144,14 +143,11 @@ 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
|
+
return (0, currency_1.default)(totalCashFlow / monthsWithData);
|
|
155
151
|
}
|
|
156
152
|
getCashFlowQuarter(date) {
|
|
157
153
|
if (this.isEmpty()) {
|
|
@@ -161,9 +157,8 @@ class LedgerCollection {
|
|
|
161
157
|
date = this.collection.last().created;
|
|
162
158
|
}
|
|
163
159
|
const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
|
|
164
|
-
const year = date.getUTCFullYear();
|
|
165
160
|
const boundary = this.filter((li) => {
|
|
166
|
-
return li.
|
|
161
|
+
return li.dateLessThanOrEqualToAndQuarter(date, quarter);
|
|
167
162
|
});
|
|
168
163
|
return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
|
|
169
164
|
}
|
|
@@ -176,6 +171,7 @@ class LedgerCollection {
|
|
|
176
171
|
balance: 0,
|
|
177
172
|
cashFlow: 0,
|
|
178
173
|
averageCashFlow: 0,
|
|
174
|
+
averageQuarterlyCashFlow: 0,
|
|
179
175
|
equity: 0,
|
|
180
176
|
purchases: 0,
|
|
181
177
|
};
|
|
@@ -192,6 +188,7 @@ class LedgerCollection {
|
|
|
192
188
|
result.equity = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Equity);
|
|
193
189
|
result.purchases = this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.Purchase);
|
|
194
190
|
result.balance = this.filter((li) => li.dateNotGreaterThan(date)).reduce((previousValue, currentValue) => previousValue + currentValue.amount, 0);
|
|
191
|
+
result.averageQuarterlyCashFlow = this.getAverageCashFlowMonthByQuarter(date);
|
|
195
192
|
return result;
|
|
196
193
|
}
|
|
197
194
|
getSummaryAnnual(year) {
|
|
@@ -229,7 +226,6 @@ class LedgerCollection {
|
|
|
229
226
|
}
|
|
230
227
|
const collection = [];
|
|
231
228
|
const lastLedgerItem = boundary[boundary.length - 1];
|
|
232
|
-
//need to determine monthDiff between boundary
|
|
233
229
|
const totalMonths = (0, date_fns_1.differenceInMonths)(boundary[0].created, lastLedgerItem.created);
|
|
234
230
|
if (totalMonths === 0) {
|
|
235
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
|
*/
|
|
@@ -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():
|
|
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
|
-
|
|
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