Skip to content

A local-first personal finance app

Add more filtering options for transactions in the Sankey report (#7442)

Emil Tveden Bjerglund6a96231c1a38
diff --git a/packages/desktop-client/src/components/reports/reports/Sankey.tsx b/packages/desktop-client/src/components/reports/reports/Sankey.tsx
index 0791fd8b86..056e35e37a 100644
--- a/packages/desktop-client/src/components/reports/reports/Sankey.tsx
+++ b/packages/desktop-client/src/components/reports/reports/Sankey.tsx
@@ -17,6 +17,7 @@ import type { SankeyData } from 'recharts/types/chart/Sankey';
import { send } from 'loot-core/platform/client/connection';
import * as monthUtils from 'loot-core/shared/months';
+import { mapField } from 'loot-core/shared/rules';
import type {
RuleConditionEntity,
SankeyWidget,
@@ -40,6 +41,7 @@ import { useReport } from '@desktop-client/components/reports/useReport';
import { fromDateRepr } from '@desktop-client/components/reports/util';
import { useCategories } from '@desktop-client/hooks/useCategories';
import { useDashboardWidget } from '@desktop-client/hooks/useDashboardWidget';
+import { useFormatList } from '@desktop-client/hooks/useFormatList';
import { useLocale } from '@desktop-client/hooks/useLocale';
import { useNavigate } from '@desktop-client/hooks/useNavigate';
import { useRuleConditionFilters } from '@desktop-client/hooks/useRuleConditionFilters';
@@ -206,7 +208,7 @@ type SankeyInnerProps = {
function SankeyInner({ widget }: SankeyInnerProps) {
const locale = useLocale();
const dispatch = useDispatch();
- const { t } = useTranslation();
+ const { t, i18n } = useTranslation();
const navigate = useNavigate();
const { isNarrowWidth } = useResponsive();
@@ -413,6 +415,24 @@ function SankeyInner({ widget }: SankeyInnerProps) {
const title = widget?.meta?.name || t('Sankey');
+ const ignoredFilterFields =
+ graphMode === 'budgeted'
+ ? [
+ ...new Set(
+ conditions
+ .filter(
+ c => c.field !== 'category' && c.field !== 'category_group',
+ )
+ .map(c => mapField(c.field)),
+ ),
+ ]
+ : [];
+
+ const ignoredFilterFieldsList = useFormatList(
+ ignoredFilterFields,
+ i18n.language,
+ );
+
if (!datesInitialized || !data) {
return <LoadingIndicator />;
}
@@ -459,15 +479,7 @@ function SankeyInner({ widget }: SankeyInnerProps) {
onDeleteFilter={onDeleteFilter}
conditionsOp={conditionsOp}
onConditionsOpChange={onConditionsOpChange}
- filterExclude={[
- 'date',
- 'payee',
- 'notes',
- 'amount',
- 'cleared',
- 'reconciled',
- 'transfer',
- ]}
+ filterExclude={['date']}
inlineContent={
<>
<View
@@ -573,6 +585,25 @@ function SankeyInner({ widget }: SankeyInnerProps) {
</View>
)}
+ {ignoredFilterFields.length > 0 && (
+ <View
+ style={{
+ marginTop: 10,
+ padding: '8px 12px',
+ backgroundColor: theme.warningBackground,
+ borderRadius: 4,
+ color: theme.warningText,
+ }}
+ >
+ <Text style={{ fontSize: 13 }}>
+ <Trans>
+ Filters on <strong>{ignoredFilterFieldsList}</strong>{' '}
+ are ignored in <strong>Budgeted</strong> mode.
+ </Trans>
+ </Text>
+ </View>
+ )}
+
{!isNarrowWidth && (
<View style={{ marginTop: 30 }}>
<Trans>
diff --git a/upcoming-release-notes/7442.md b/upcoming-release-notes/7442.md
new file mode 100644
index 0000000000..2e67bd4449
--- /dev/null
+++ b/upcoming-release-notes/7442.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [emiltb]
+---
+
+Add more filtering options for transactions in Spent mode of the Sankey chart