@cubedelement.com/realty-investor-timeline 5.7.2 → 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 CHANGED
@@ -1,3 +1,17 @@
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
+
8
+ ## [5.7.3](https://github.com/kvernon/realty-investor-timeline/compare/v5.7.2...v5.7.3) (2026-01-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * ledger-item filter method update ([#78](https://github.com/kvernon/realty-investor-timeline/issues/78)) ([e8b1c86](https://github.com/kvernon/realty-investor-timeline/commit/e8b1c86c3a290041e67b794811899e2c5d888953))
14
+
1
15
  ## [5.7.2](https://github.com/kvernon/realty-investor-timeline/compare/v5.7.1...v5.7.2) (2026-01-15)
2
16
 
3
17
 
@@ -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,19 +131,14 @@ 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, quarter);
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;
141
139
  }
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();
140
+ const firstMonth = boundary[0].created.getUTCMonth();
141
+ const lastMonth = boundary[boundary.length - 1].created.getUTCMonth();
148
142
  const monthsWithData = lastMonth - firstMonth + 1;
149
143
  if (monthsWithData <= 0) {
150
144
  return 0;
@@ -162,9 +156,8 @@ class LedgerCollection {
162
156
  if (!date) {
163
157
  date = this.collection.last().created;
164
158
  }
165
- const quarter = (0, get_date_quarter_1.getDateQuarter)(date);
166
159
  const boundary = this.filter((li) => {
167
- return li.dateLessThanOrEqualToAndQuarter(date, quarter);
160
+ return li.dateLessThanOrEqualToAndQuarter(date);
168
161
  });
169
162
  return this.getSummaryByType(boundary, ledger_item_type_1.LedgerItemType.CashFlow);
170
163
  }
@@ -15,16 +15,24 @@ export declare class LedgerItem {
15
15
  */
16
16
  getQuarter(): -1 | QuarterType;
17
17
  isAmountGreaterThanZero(): boolean;
18
- dateMatchesYearAndMonth(today: Date): boolean;
19
- dateLessThanOrEqualTo(today: Date): boolean;
20
- dateNotGreaterThan(today: Date): boolean;
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 the date is less than or equal to the date passed in and the quarter matches
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, quarter: QuarterType): boolean;
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(today) {
47
- if (!today) {
46
+ dateMatchesYearAndMonth(date) {
47
+ if (!date) {
48
48
  return false;
49
49
  }
50
- if (!this.dateMatchesYear(today.getUTCFullYear())) {
50
+ if (!this.dateMatchesYear(date.getUTCFullYear())) {
51
51
  return false;
52
52
  }
53
- return today.getUTCMonth() === this.created.getUTCMonth();
53
+ return date.getUTCMonth() === this.created.getUTCMonth();
54
54
  }
55
- dateLessThanOrEqualTo(today) {
56
- if (!today || !this.created) {
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, today) >= 0;
63
+ return (0, data_compare_date_1.default)(this.created, date) >= 0;
60
64
  }
61
- dateNotGreaterThan(today) {
62
- if (!today || !this.created) {
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, today) !== 1;
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 the date is less than or equal to the date passed in and the quarter matches
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, quarter) {
91
+ dateLessThanOrEqualToAndQuarter(date) {
79
92
  if (!this.created) {
80
93
  return false;
81
94
  }
82
- if (!this.dateLessThanOrEqualTo(date)) {
95
+ if (!this.dateMatchesYear(date.getUTCFullYear())) {
83
96
  return false;
84
97
  }
85
- return this.getQuarter() === quarter;
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 before, a or b. If a, then you'll get -1, if b then 1. Finally, if everything is the
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 before, a or b. If a, then you'll get -1, if b then 1. Finally, if everything is the
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cubedelement.com/realty-investor-timeline",
3
- "version": "5.7.2",
3
+ "version": "5.7.4",
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",