Fix Net Worth Calculations (#6968)
* fix: computed priorPeriodNetWorth and use it as a baseline for net worth calculations * add release notes * correct spelling * Update VRT screenshots Auto-generated by VRT workflow PR: #6968 * Update VRT screenshots Auto-generated by VRT workflow PR: #6968 * Update VRT screenshots Auto-generated by VRT workflow PR: #6968 * Update VRT screenshots Auto-generated by VRT workflow PR: #6968 * Update VRT screenshots Auto-generated by VRT workflow PR: #6968 * note --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: youngcw <calebyoung94@gmail.com>
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 103 KiB After Width: | Height: | Size: 103 KiB |
|
Before Width: | Height: | Size: 104 KiB After Width: | Height: | Size: 106 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 89 KiB |
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 94 KiB |
@@ -187,8 +187,12 @@ function recalculate(
|
||||
});
|
||||
});
|
||||
|
||||
const priorPeriodNetWorth = data.reduce(
|
||||
(sum, account) => sum + account.starting,
|
||||
0,
|
||||
);
|
||||
|
||||
let hasNegative = false;
|
||||
let startNetWorth = 0;
|
||||
let endNetWorth = 0;
|
||||
let lowestNetWorth: number | null = null;
|
||||
let highestNetWorth: number | null = null;
|
||||
@@ -236,11 +240,8 @@ function recalculate(
|
||||
x = d.parseISO(intervalItem + '-01');
|
||||
}
|
||||
|
||||
const change = last ? total - last.y : 0;
|
||||
const change = last ? total - last.y : total - priorPeriodNetWorth;
|
||||
|
||||
if (arr.length === 0) {
|
||||
startNetWorth = total;
|
||||
}
|
||||
endNetWorth = total;
|
||||
|
||||
// Use standardized format from ReportOptions
|
||||
@@ -292,7 +293,7 @@ function recalculate(
|
||||
end: endDate,
|
||||
},
|
||||
netWorth: endNetWorth,
|
||||
totalChange: endNetWorth - startNetWorth,
|
||||
totalChange: endNetWorth - priorPeriodNetWorth,
|
||||
lowestNetWorth,
|
||||
highestNetWorth,
|
||||
accounts: data
|
||||
|
||||
6
upcoming-release-notes/6968.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfixes
|
||||
authors: [PratikSilwal5]
|
||||
---
|
||||
|
||||
Correctly calculate the net worth change value on the first month of the report.
|
||||