Skip to content

A local-first personal finance app

Custom Reports show activity fix (#2785)

Neile7c6611c8823
diff --git a/packages/desktop-client/src/components/reports/ChooseGraph.tsx b/packages/desktop-client/src/components/reports/ChooseGraph.tsx
index b195b7eecf..bf5dec7b05 100644
--- a/packages/desktop-client/src/components/reports/ChooseGraph.tsx
+++ b/packages/desktop-client/src/components/reports/ChooseGraph.tsx
@@ -48,7 +48,9 @@ export function ChooseGraph({
showOffBudget = false,
intervalsCount,
}: ChooseGraphProps) {
- const graphStyle = compact ? { ...style } : { flexGrow: 1 };
+ const graphStyle = compact
+ ? { ...style }
+ : { flexGrow: 1, overflow: 'hidden' };
const balanceTypeOp =
ReportOptions.balanceTypeMap.get(balanceType) || 'totalDebts';
@@ -147,6 +149,7 @@ export function ChooseGraph({
balanceTypeOp={balanceTypeOp}
showHiddenCategories={showHiddenCategories}
showOffBudget={showOffBudget}
+ interval={interval}
/>
);
}
@@ -162,6 +165,7 @@ export function ChooseGraph({
groupBy={groupBy}
showHiddenCategories={showHiddenCategories}
showOffBudget={showOffBudget}
+ interval={interval}
/>
);
}
diff --git a/packages/desktop-client/src/components/reports/ReportOptions.ts b/packages/desktop-client/src/components/reports/ReportOptions.ts
index 0ae9c6b0a5..53f0b3bb77 100644
--- a/packages/desktop-client/src/components/reports/ReportOptions.ts
+++ b/packages/desktop-client/src/components/reports/ReportOptions.ts
@@ -121,7 +121,7 @@ const dateRangeOptions: dateRangeProps[] = [
{
description: 'Year to date',
name: 'yearToDate',
- Daily: true,
+ Daily: false,
Weekly: true,
Monthly: true,
Yearly: true,
@@ -129,7 +129,7 @@ const dateRangeOptions: dateRangeProps[] = [
{
description: 'Last year',
name: 'lastYear',
- Daily: true,
+ Daily: false,
Weekly: true,
Monthly: true,
Yearly: true,
@@ -137,7 +137,7 @@ const dateRangeOptions: dateRangeProps[] = [
{
description: 'All time',
name: 'allTime',
- Daily: true,
+ Daily: false,
Weekly: true,
Monthly: true,
Yearly: true,
diff --git a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
index 9499953299..03a5934b33 100644
--- a/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/AreaGraph.tsx
@@ -206,7 +206,7 @@ export function AreaGraph({
top: 0,
right: labelsMargin,
left: leftMargin,
- bottom: 0,
+ bottom: 10,
}}
>
{compact ? null : (
diff --git a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
index 6b455cf234..e6f1a0a6eb 100644
--- a/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/BarGraph.tsx
@@ -36,6 +36,7 @@ import { numberFormatterTooltip } from '../numberFormatter';
import { adjustTextSize } from './adjustTextSize';
import { renderCustomLabel } from './renderCustomLabel';
+import { showActivity } from './showActivity';
type PayloadChild = {
props: {
@@ -183,61 +184,6 @@ export function BarGraph({
const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 0;
- const onShowActivity = item => {
- const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte';
- const field = groupBy === 'Interval' ? null : groupBy.toLowerCase();
- const hiddenCategories = categories.list
- .filter(f => f.hidden)
- .map(e => e.id);
- const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id);
-
- const conditions = [
- ...filters,
- { field, op: 'is', value: item.id, type: 'id' },
- {
- field: 'date',
- op: 'gte',
- value: data.startDate,
- options: { date: true },
- type: 'date',
- },
- {
- field: 'date',
- op: 'lte',
- value: data.endDate,
- options: { date: true },
- type: 'date',
- },
- balanceTypeOp !== 'totalTotals' && {
- field: 'amount',
- op: amount,
- value: 0,
- type: 'number',
- },
- hiddenCategories.length > 0 &&
- !showHiddenCategories && {
- field: 'category',
- op: 'notOneOf',
- value: hiddenCategories,
- type: 'id',
- },
- offBudgetAccounts.length > 0 &&
- !showOffBudget && {
- field: 'account',
- op: 'notOneOf',
- value: offBudgetAccounts,
- type: 'id',
- },
- ].filter(f => f);
- navigate('/accounts', {
- state: {
- goBack: true,
- conditions,
- categoryId: item.id,
- },
- });
- };
-
return (
<Container
style={{
@@ -309,10 +255,23 @@ export function BarGraph({
!['Group', 'Interval'].includes(groupBy) &&
setPointer('pointer')
}
- onClick={
+ onClick={item =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
- onShowActivity
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp,
+ filters,
+ showHiddenCategories,
+ showOffBudget,
+ type: 'totals',
+ startDate: data.startDate,
+ endDate: data.endDate,
+ field: groupBy.toLowerCase(),
+ id: item.id,
+ })
}
>
{viewLabels && !compact && (
diff --git a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
index 7267f49b79..3eab0f182d 100644
--- a/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/DonutGraph.tsx
@@ -17,6 +17,7 @@ import { Container } from '../Container';
import { adjustTextSize } from './adjustTextSize';
import { renderCustomLabel } from './renderCustomLabel';
+import { showActivity } from './showActivity';
const RADIAN = Math.PI / 180;
@@ -207,61 +208,6 @@ export function DonutGraph({
const { isNarrowWidth } = useResponsive();
const [pointer, setPointer] = useState('');
- const onShowActivity = item => {
- const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte';
- const field = groupBy === 'Interval' ? null : groupBy.toLowerCase();
- const hiddenCategories = categories.list
- .filter(f => f.hidden)
- .map(e => e.id);
- const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id);
-
- const conditions = [
- ...filters,
- { field, op: 'is', value: item.id, type: 'id' },
- {
- field: 'date',
- op: 'gte',
- value: data.startDate,
- options: { date: true },
- type: 'date',
- },
- {
- field: 'date',
- op: 'lte',
- value: data.endDate,
- options: { date: true },
- type: 'date',
- },
- balanceTypeOp !== 'totalTotals' && {
- field: 'amount',
- op: amount,
- value: 0,
- type: 'number',
- },
- hiddenCategories.length > 0 &&
- !showHiddenCategories && {
- field: 'category',
- op: 'notOneOf',
- value: hiddenCategories,
- type: 'id',
- },
- offBudgetAccounts.length > 0 &&
- !showOffBudget && {
- field: 'account',
- op: 'notOneOf',
- value: offBudgetAccounts,
- type: 'id',
- },
- ].filter(f => f);
- navigate('/accounts', {
- state: {
- goBack: true,
- conditions,
- categoryId: item.id,
- },
- });
- };
-
const getVal = obj => {
if (balanceTypeOp === 'totalDebts') {
return -1 * obj[balanceTypeOp];
@@ -309,10 +255,23 @@ export function DonutGraph({
setPointer('pointer');
}
}}
- onClick={
+ onClick={item =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
- onShowActivity
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp,
+ filters,
+ showHiddenCategories,
+ showOffBudget,
+ type: 'totals',
+ startDate: data.startDate,
+ endDate: data.endDate,
+ field: groupBy.toLowerCase(),
+ id: item.id,
+ })
}
>
{data.legend.map((entry, index) => (
diff --git a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
index 15577b4e95..d47575f88b 100644
--- a/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/LineGraph.tsx
@@ -31,6 +31,8 @@ import { Container } from '../Container';
import { getCustomTick } from '../getCustomTick';
import { numberFormatterTooltip } from '../numberFormatter';
+import { showActivity } from './showActivity';
+
type PayloadItem = {
dataKey: string;
value: number;
@@ -116,6 +118,7 @@ type LineGraphProps = {
balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals';
showHiddenCategories?: boolean;
showOffBudget?: boolean;
+ interval?: string;
};
export function LineGraph({
@@ -127,6 +130,7 @@ export function LineGraph({
balanceTypeOp,
showHiddenCategories,
showOffBudget,
+ interval,
}: LineGraphProps) {
const navigate = useNavigate();
const categories = useCategories();
@@ -143,49 +147,20 @@ export function LineGraph({
const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 5;
const onShowActivity = (item, id, payload) => {
- const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte';
- const field = groupBy === 'Interval' ? null : groupBy.toLowerCase();
- const hiddenCategories = categories.list
- .filter(f => f.hidden)
- .map(e => e.id);
- const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id);
-
- const conditions = [
- ...filters,
- { field, op: 'is', value: id, type: 'id' },
- {
- field: 'date',
- op: 'is',
- value: payload.payload.dateStart,
- options: { date: true },
- },
- balanceTypeOp !== 'totalTotals' && {
- field: 'amount',
- op: amount,
- value: 0,
- type: 'number',
- },
- hiddenCategories.length > 0 &&
- !showHiddenCategories && {
- field: 'category',
- op: 'notOneOf',
- value: hiddenCategories,
- type: 'id',
- },
- offBudgetAccounts.length > 0 &&
- !showOffBudget && {
- field: 'account',
- op: 'notOneOf',
- value: offBudgetAccounts,
- type: 'id',
- },
- ].filter(f => f);
- navigate('/accounts', {
- state: {
- goBack: true,
- conditions,
- categoryId: item.id,
- },
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp,
+ filters,
+ showHiddenCategories,
+ showOffBudget,
+ type: 'time',
+ startDate: payload.payload.intervalStartDate,
+ endDate: payload.payload.intervalEndDate,
+ field: groupBy.toLowerCase(),
+ id,
+ interval,
});
};
diff --git a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
index f2c2807eb1..81463d147d 100644
--- a/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/StackedBarGraph.tsx
@@ -33,6 +33,7 @@ import { getCustomTick } from '../getCustomTick';
import { numberFormatterTooltip } from '../numberFormatter';
import { renderCustomLabel } from './renderCustomLabel';
+import { showActivity } from './showActivity';
type PayloadItem = {
name: string;
@@ -146,6 +147,7 @@ type StackedBarGraphProps = {
balanceTypeOp: 'totalAssets' | 'totalDebts' | 'totalTotals';
showHiddenCategories?: boolean;
showOffBudget?: boolean;
+ interval?: string;
};
export function StackedBarGraph({
@@ -158,6 +160,7 @@ export function StackedBarGraph({
balanceTypeOp,
showHiddenCategories,
showOffBudget,
+ interval,
}: StackedBarGraphProps) {
const navigate = useNavigate();
const categories = useCategories();
@@ -173,53 +176,6 @@ export function StackedBarGraph({
const leftMargin = Math.abs(largestValue) > 1000000 ? 20 : 0;
- const onShowActivity = (item, id) => {
- const amount = balanceTypeOp === 'totalDebts' ? 'lte' : 'gte';
- const field = groupBy === 'Interval' ? null : groupBy.toLowerCase();
- const hiddenCategories = categories.list
- .filter(f => f.hidden)
- .map(e => e.id);
- const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id);
-
- const conditions = [
- ...filters,
- { field, op: 'is', value: id, type: 'id' },
- {
- field: 'date',
- op: 'is',
- value: item.dateStart,
- options: { date: true },
- },
- balanceTypeOp !== 'totalTotals' && {
- field: 'amount',
- op: amount,
- value: 0,
- type: 'number',
- },
- hiddenCategories.length > 0 &&
- !showHiddenCategories && {
- field: 'category',
- op: 'notOneOf',
- value: hiddenCategories,
- type: 'id',
- },
- offBudgetAccounts.length > 0 &&
- !showOffBudget && {
- field: 'account',
- op: 'notOneOf',
- value: offBudgetAccounts,
- type: 'id',
- },
- ].filter(f => f);
- navigate('/accounts', {
- state: {
- goBack: true,
- conditions,
- categoryId: item.id,
- },
- });
- };
-
return (
<Container
style={{
@@ -236,7 +192,7 @@ export function StackedBarGraph({
width={width}
height={height}
data={data.intervalData}
- margin={{ top: 0, right: 0, left: leftMargin, bottom: 0 }}
+ margin={{ top: 0, right: 0, left: leftMargin, bottom: 10 }}
style={{ cursor: pointer }}
>
{(!isNarrowWidth || !compact) && (
@@ -297,7 +253,21 @@ export function StackedBarGraph({
onClick={e =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
- onShowActivity(e, entry.id)
+ showActivity({
+ navigate,
+ categories,
+ accounts,
+ balanceTypeOp,
+ filters,
+ showHiddenCategories,
+ showOffBudget,
+ type: 'time',
+ startDate: e.intervalStartDate,
+ endDate: e.intervalEndDate,
+ field: groupBy.toLowerCase(),
+ id: entry.id,
+ interval,
+ })
}
>
{viewLabels && !compact && (
diff --git a/packages/desktop-client/src/components/reports/graphs/showActivity.ts b/packages/desktop-client/src/components/reports/graphs/showActivity.ts
index fdbe64f826..892664b812 100644
--- a/packages/desktop-client/src/components/reports/graphs/showActivity.ts
+++ b/packages/desktop-client/src/components/reports/graphs/showActivity.ts
@@ -1,10 +1,13 @@
import { type NavigateFunction } from 'react-router-dom';
+import * as monthUtils from 'loot-core/src/shared/months';
import { type AccountEntity } from 'loot-core/types/models/account';
import { type CategoryEntity } from 'loot-core/types/models/category';
import { type CategoryGroupEntity } from 'loot-core/types/models/category-group';
import { type RuleConditionEntity } from 'loot-core/types/models/rule';
+import { ReportOptions } from '../ReportOptions';
+
type showActivityProps = {
navigate: NavigateFunction;
categories: { list: CategoryEntity[]; grouped: CategoryGroupEntity[] };
@@ -18,6 +21,7 @@ type showActivityProps = {
endDate?: string;
field?: string;
id?: string;
+ interval?: string;
};
export function showActivity({
@@ -33,22 +37,29 @@ export function showActivity({
endDate,
field,
id,
+ interval = 'Day',
}: showActivityProps) {
- const amount =
- balanceTypeOp === 'totalDebts' || type === 'debts' ? 'lte' : 'gte';
+ const isOutFlow =
+ balanceTypeOp === 'totalDebts' || type === 'debts' ? true : false;
const hiddenCategories = categories.list.filter(f => f.hidden).map(e => e.id);
const offBudgetAccounts = accounts.filter(f => f.offbudget).map(e => e.id);
+ const fromDate =
+ interval === 'Weekly'
+ ? 'dayFromDate'
+ : (((ReportOptions.intervalMap.get(interval) || 'Day').toLowerCase() +
+ 'FromDate') as 'dayFromDate' | 'monthFromDate' | 'yearFromDate');
+ const isDateOp = interval === 'Weekly' || type !== 'time';
const conditions = [
...filters,
id && { field, op: 'is', value: id, type: 'id' },
{
field: 'date',
- op: type === 'time' ? 'is' : 'gte',
- value: startDate,
- options: { date: true },
+ op: isDateOp ? 'gte' : 'is',
+ value: isDateOp ? startDate : monthUtils[fromDate](startDate),
+ type: 'date',
},
- type !== 'time' && {
+ isDateOp && {
field: 'date',
op: 'lte',
value: endDate,
@@ -59,9 +70,13 @@ export function showActivity({
(type === 'totals' || type === 'time')
) && {
field: 'amount',
- op: amount,
+ op: 'gte',
value: 0,
- type: 'number',
+ options: {
+ type: 'number',
+ inflow: !isOutFlow,
+ outflow: isOutFlow,
+ },
},
hiddenCategories.length > 0 &&
!showHiddenCategories && {
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
index 78882fc98b..0da32fb5ce 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTable.tsx
@@ -98,6 +98,7 @@ export function ReportTable({
compactStyle={compactStyle}
showHiddenCategories={showHiddenCategories}
showOffBudget={showOffBudget}
+ interval={interval}
/>
);
}, []);
@@ -129,6 +130,7 @@ export function ReportTable({
totalScrollRef={totalScrollRef}
handleScroll={handleScroll}
height={32 + scrollWidthTotals}
+ interval={interval}
/>
);
},
diff --git a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
index cf3de8cf15..57aec0d235 100644
--- a/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
+++ b/packages/desktop-client/src/components/reports/graphs/tableGraph/ReportTableRow.tsx
@@ -32,6 +32,7 @@ type ReportTableRowProps = {
totalStyle?: CSSProperties;
showHiddenCategories?: boolean;
showOffBudget?: boolean;
+ interval: string;
totalScrollRef?: RefObject<HTMLDivElement>;
handleScroll?: UIEventHandler<HTMLDivElement>;
height?: number;
@@ -56,6 +57,7 @@ export const ReportTableRow = memo(
totalScrollRef,
handleScroll,
height,
+ interval,
}: ReportTableRowProps) => {
const average = amountToInteger(item[balanceTypeOp]) / intervalsCount;
const groupByItem = groupBy === 'Interval' ? 'date' : 'name';
@@ -68,6 +70,7 @@ export const ReportTableRow = memo(
const pointer =
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id)
? 'pointer'
: 'inherit';
@@ -75,6 +78,7 @@ export const ReportTableRow = memo(
const hoverUnderline =
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id)
? {
cursor: pointer,
@@ -132,6 +136,7 @@ export const ReportTableRow = memo(
onClick={() =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id) &&
showActivity({
navigate,
@@ -143,8 +148,10 @@ export const ReportTableRow = memo(
showOffBudget,
type: 'time',
startDate: intervalItem.intervalStartDate || '',
+ endDate: intervalItem.intervalEndDate || '',
field: groupBy.toLowerCase(),
id: item.id,
+ interval,
})
}
width="flex"
@@ -171,6 +178,7 @@ export const ReportTableRow = memo(
onClick={() =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id) &&
showActivity({
navigate,
@@ -205,6 +213,7 @@ export const ReportTableRow = memo(
onClick={() =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id) &&
showActivity({
navigate,
@@ -240,6 +249,7 @@ export const ReportTableRow = memo(
onClick={() =>
!isNarrowWidth &&
!['Group', 'Interval'].includes(groupBy) &&
+ !compact &&
!categories.grouped.map(g => g.id).includes(item.id) &&
showActivity({
navigate,
diff --git a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
index ce952a89c6..10a1f870c6 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReport.tsx
@@ -124,8 +124,10 @@ export function CustomReport() {
const [dateRange, setDateRange] = useState(loadReport.dateRange);
const [dataCheck, setDataCheck] = useState(false);
const dateRangeLine =
- ReportOptions.dateRange.filter(f => f[interval as keyof dateRangeProps])
- .length - 3;
+ interval === 'Daily'
+ ? 0
+ : ReportOptions.dateRange.filter(f => f[interval as keyof dateRangeProps])
+ .length - 3;
const [intervals, setIntervals] = useState(
monthUtils.rangeInclusive(startDate, endDate),
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
index ab8b3a0e11..0ad83924bf 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/custom-spreadsheet.ts
@@ -155,7 +155,7 @@ export function createCustomSpreadsheet({
let totalDebts = 0;
const intervalData = intervals.reduce(
- (arr: IntervalEntity[], intervalItem) => {
+ (arr: IntervalEntity[], intervalItem, index) => {
let perIntervalAssets = 0;
let perIntervalDebts = 0;
const stacked: Record<string, number> = {};
@@ -214,7 +214,11 @@ export function createCustomSpreadsheet({
ReportOptions.intervalFormat.get(interval) || '',
),
...stacked,
- intervalStartDate: intervalItem,
+ intervalStartDate: index === 0 ? startDate : intervalItem,
+ intervalEndDate:
+ index + 1 === intervals.length
+ ? endDate
+ : monthUtils.subDays(intervals[index + 1], 1),
totalDebts: integerToAmount(perIntervalDebts),
totalAssets: integerToAmount(perIntervalAssets),
totalTotals: integerToAmount(perIntervalDebts + perIntervalAssets),
@@ -235,6 +239,8 @@ export function createCustomSpreadsheet({
showOffBudget,
showHiddenCategories,
showUncategorized,
+ startDate,
+ endDate,
});
return { ...calc };
});
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts b/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts
index 170cc42131..ed3048d291 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/grouped-spreadsheet.ts
@@ -180,6 +180,8 @@ export function createGroupedSpreadsheet({
showOffBudget,
showHiddenCategories,
showUncategorized,
+ startDate,
+ endDate,
});
return { ...calc };
});
diff --git a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
index a01332e4b9..3f4bc44b7b 100644
--- a/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
+++ b/packages/desktop-client/src/components/reports/spreadsheets/recalculate.ts
@@ -1,3 +1,4 @@
+import * as monthUtils from 'loot-core/src/shared/months';
import { amountToInteger, integerToAmount } from 'loot-core/src/shared/util';
import {
type GroupedEntity,
@@ -20,6 +21,8 @@ type recalculateProps = {
showOffBudget?: boolean;
showHiddenCategories?: boolean;
showUncategorized?: boolean;
+ startDate: string;
+ endDate: string;
};
export function recalculate({
@@ -31,11 +34,13 @@ export function recalculate({
showOffBudget,
showHiddenCategories,
showUncategorized,
+ startDate,
+ endDate,
}: recalculateProps): GroupedEntity {
let totalAssets = 0;
let totalDebts = 0;
const intervalData = intervals.reduce(
- (arr: IntervalEntity[], intervalItem) => {
+ (arr: IntervalEntity[], intervalItem, index) => {
const last = arr.length === 0 ? null : arr[arr.length - 1];
const intervalAssets = filterHiddenItems(
@@ -77,7 +82,11 @@ export function recalculate({
totalDebts: integerToAmount(intervalDebts),
totalTotals: integerToAmount(intervalAssets + intervalDebts),
change,
- intervalStartDate: intervalItem,
+ intervalStartDate: index === 0 ? startDate : intervalItem,
+ intervalEndDate:
+ index + 1 === intervals.length
+ ? endDate
+ : monthUtils.subDays(intervals[index + 1], 1),
});
return arr;
diff --git a/packages/loot-core/src/types/models/reports.d.ts b/packages/loot-core/src/types/models/reports.d.ts
index ca893d5f14..eccc1c79f9 100644
--- a/packages/loot-core/src/types/models/reports.d.ts
+++ b/packages/loot-core/src/types/models/reports.d.ts
@@ -79,6 +79,7 @@ export type IntervalEntity = {
date?: string;
change?: number;
intervalStartDate?: string;
+ intervalEndDate?: string;
totalAssets: number;
totalDebts: number;
totalTotals: number;
diff --git a/upcoming-release-notes/2785.md b/upcoming-release-notes/2785.md
new file mode 100644
index 0000000000..7b7979ac19
--- /dev/null
+++ b/upcoming-release-notes/2785.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [carkom]
+---
+
+Hardens "showActivity" elements of custom reports, switched to "inflow/outflow" filters. Fixes issue with weekly show activity clicks not filtering dates correctly.