@cubedelement.com/realty-investor-timeline 5.7.3 → 5.7.4
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/ledger-collection.js +2 -5
- package/dist/src/ledger/ledger-item.d.ts +14 -6
- package/dist/src/ledger/ledger-item.js +31 -15
- package/dist/src/utils/data-compare-date.d.ts +1 -1
- package/dist/src/utils/data-compare-date.js +1 -1
- package/dist/src/utils/get-date-quarter.d.ts +5 -0
- package/dist/src/utils/get-date-quarter.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [5.7.4](https://github.com/kvernon/realty-investor-timeline/compare/v5.7.3...v5.7.4) (2026-01-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* quarter calculations ([#79](https://github.com/kvernon/realty-investor-timeline/issues/79)) ([9c60f23](https://github.com/kvernon/realty-investor-timeline/commit/9c60f23d4f2fa0d1c87e3c4538f33c13f5f8e0b9))
|
|
7
|
+
|
|
1
8
|
## [5.7.3](https://github.com/kvernon/realty-investor-timeline/compare/v5.7.2...v5.7.3) (2026-01-15)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -10,7 +10,6 @@ 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");
|
|
14
13
|
class LedgerCollection {
|
|
15
14
|
collection;
|
|
16
15
|
getSummaryByType(collection, type) {
|
|
@@ -132,9 +131,8 @@ class LedgerCollection {
|
|
|
132
131
|
if (!date) {
|
|
133
132
|
date = this.collection.last().created;
|
|
134
133
|
}
|
|
135
|
-
const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
|
|
136
134
|
const boundary = this.filter((li) => {
|
|
137
|
-
return li.dateLessThanOrEqualToAndQuarter(date
|
|
135
|
+
return li.dateLessThanOrEqualToAndQuarter(date) && li.typeMatches(ledger_item_type_1.LedgerItemType.CashFlow);
|
|
138
136
|
});
|
|
139
137
|
if (boundary.length === 0) {
|
|
140
138
|
return 0;
|
|
@@ -158,9 +156,8 @@ class LedgerCollection {
|
|
|
158
156
|
if (!date) {
|
|
159
157
|
date = this.collection.last().created;
|
|
160
158
|
}
|
|
161
|
-
const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
|
|
162
159
|
const boundary = this.filter((li) => {
|
|
163
|
-
return li.dateLessThanOrEqualToAndQuarter(date
|
|
160
|
+
return li.dateLessThanOrEqualToAndQuarter(date);
|
|
164
161
|
});
|
|
165
162
|
return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
|
|
166
163
|
}
|
|
@@ -15,16 +15,24 @@ export declare class LedgerItem {
|
|
|
15
15
|
*/
|
|
16
16
|
getQuarter(): -1 | QuarterType;
|
|
17
17
|
isAmountGreaterThanZero(): boolean;
|
|
18
|
-
dateMatchesYearAndMonth(
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
dateMatchesYearAndMonth(date: Date): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* returns `true` if date's date is less than or equal to the created date
|
|
21
|
+
* @param date
|
|
22
|
+
*/
|
|
23
|
+
dateLessThanOrEqualTo(date: Date): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* returns `true` if date's date is grater than or equal to the created date
|
|
26
|
+
* @param date
|
|
27
|
+
*/
|
|
28
|
+
dateGreaterThanOrEqualTo(date: Date): boolean;
|
|
29
|
+
dateNotGreaterThan(date: Date): boolean;
|
|
21
30
|
dateMatchesYear(year: number): boolean;
|
|
22
31
|
/**
|
|
23
|
-
* returns true if
|
|
32
|
+
* returns `true` if date's date is more recent than or equal to the created date and the quarter matches
|
|
24
33
|
* @param date
|
|
25
|
-
* @param quarter
|
|
26
34
|
*/
|
|
27
|
-
dateLessThanOrEqualToAndQuarter(date: Date
|
|
35
|
+
dateLessThanOrEqualToAndQuarter(date: Date): boolean;
|
|
28
36
|
/**
|
|
29
37
|
* @deprecated, use {@link dateLessThanOrEqualToAndQuarter}
|
|
30
38
|
* @param year
|
|
@@ -43,26 +43,40 @@ class LedgerItem {
|
|
|
43
43
|
isAmountGreaterThanZero() {
|
|
44
44
|
return this.amount > 0;
|
|
45
45
|
}
|
|
46
|
-
dateMatchesYearAndMonth(
|
|
47
|
-
if (!
|
|
46
|
+
dateMatchesYearAndMonth(date) {
|
|
47
|
+
if (!date) {
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
-
if (!this.dateMatchesYear(
|
|
50
|
+
if (!this.dateMatchesYear(date.getUTCFullYear())) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
|
-
return
|
|
53
|
+
return date.getUTCMonth() === this.created.getUTCMonth();
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
/**
|
|
56
|
+
* returns `true` if date's date is less than or equal to the created date
|
|
57
|
+
* @param date
|
|
58
|
+
*/
|
|
59
|
+
dateLessThanOrEqualTo(date) {
|
|
60
|
+
if (!date || !this.created) {
|
|
57
61
|
return false;
|
|
58
62
|
}
|
|
59
|
-
return (0, data_compare_date_1.default)(this.created,
|
|
63
|
+
return (0, data_compare_date_1.default)(this.created, date) >= 0;
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
/**
|
|
66
|
+
* returns `true` if date's date is grater than or equal to the created date
|
|
67
|
+
* @param date
|
|
68
|
+
*/
|
|
69
|
+
dateGreaterThanOrEqualTo(date) {
|
|
70
|
+
if (!date || !this.created) {
|
|
63
71
|
return false;
|
|
64
72
|
}
|
|
65
|
-
return (0, data_compare_date_1.default)(this.created,
|
|
73
|
+
return (0, data_compare_date_1.default)(this.created, date) <= 0;
|
|
74
|
+
}
|
|
75
|
+
dateNotGreaterThan(date) {
|
|
76
|
+
if (!date || !this.created) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return (0, data_compare_date_1.default)(this.created, date) !== 1;
|
|
66
80
|
}
|
|
67
81
|
dateMatchesYear(year) {
|
|
68
82
|
if (!this.created) {
|
|
@@ -71,18 +85,20 @@ class LedgerItem {
|
|
|
71
85
|
return year === this.created.getUTCFullYear();
|
|
72
86
|
}
|
|
73
87
|
/**
|
|
74
|
-
* returns true if
|
|
88
|
+
* returns `true` if date's date is more recent than or equal to the created date and the quarter matches
|
|
75
89
|
* @param date
|
|
76
|
-
* @param quarter
|
|
77
90
|
*/
|
|
78
|
-
dateLessThanOrEqualToAndQuarter(date
|
|
91
|
+
dateLessThanOrEqualToAndQuarter(date) {
|
|
79
92
|
if (!this.created) {
|
|
80
93
|
return false;
|
|
81
94
|
}
|
|
82
|
-
if (!this.
|
|
95
|
+
if (!this.dateMatchesYear(date.getUTCFullYear())) {
|
|
83
96
|
return false;
|
|
84
97
|
}
|
|
85
|
-
|
|
98
|
+
if (this.getQuarter() !== (0, get_date_quarter_1.getDateQuarter)(date)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
return this.dateGreaterThanOrEqualTo(date);
|
|
86
102
|
}
|
|
87
103
|
/**
|
|
88
104
|
* @deprecated, use {@link dateLessThanOrEqualToAndQuarter}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* used to determine which is
|
|
2
|
+
* used to determine which date is the the oldest, a or b. If a is more in the past, then you'll get -1, if b then 1. Finally, if everything is the
|
|
3
3
|
* same, then 0.
|
|
4
4
|
* @param dateA
|
|
5
5
|
* @param dateB
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/**
|
|
4
|
-
* used to determine which is
|
|
4
|
+
* used to determine which date is the the oldest, a or b. If a is more in the past, then you'll get -1, if b then 1. Finally, if everything is the
|
|
5
5
|
* same, then 0.
|
|
6
6
|
* @param dateA
|
|
7
7
|
* @param dateB
|
|
@@ -7,3 +7,8 @@ export type QuarterType = 0 | 1 | 2 | 3;
|
|
|
7
7
|
* @param date
|
|
8
8
|
*/
|
|
9
9
|
export declare const getDateQuarter: (date: Date) => QuarterType;
|
|
10
|
+
/**
|
|
11
|
+
* takes a month (0 - 11) and return the quarter it belongs to, which will be 0, 1, 2, or 3
|
|
12
|
+
* @param month
|
|
13
|
+
*/
|
|
14
|
+
export declare const getDateQuarterByMonth: (month: number) => QuarterType;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDateQuarter = void 0;
|
|
3
|
+
exports.getDateQuarterByMonth = exports.getDateQuarter = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* takes a date and return the quarter it belongs to, which will be 0, 1, 2, or 3
|
|
6
6
|
* @param date
|
|
7
7
|
*/
|
|
8
8
|
const getDateQuarter = (date) => Math.floor(date.getUTCMonth() / 3);
|
|
9
9
|
exports.getDateQuarter = getDateQuarter;
|
|
10
|
+
/**
|
|
11
|
+
* takes a month (0 - 11) and return the quarter it belongs to, which will be 0, 1, 2, or 3
|
|
12
|
+
* @param month
|
|
13
|
+
*/
|
|
14
|
+
const getDateQuarterByMonth = (month) => Math.floor(month / 3);
|
|
15
|
+
exports.getDateQuarterByMonth = getDateQuarterByMonth;
|
package/package.json
CHANGED