Skip to content

Commit

Permalink
Show/hide reconciled transactions in the account view (#2542)
Browse files Browse the repository at this point in the history
* Show/hide reconciled transactions

* Adding release note

* Fixing lint issues

* Filters should still apply after hiding/showing reconciled

* Using fetch transactions with filter parameter
  • Loading branch information
davidkus authored Apr 4, 2024
1 parent 8b34ba3 commit 66dc593
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/desktop-client/src/components/accounts/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ class AccountInternal extends PureComponent {
showBalances: props.showBalances,
balances: null,
showCleared: props.showCleared,
showReconciled: props.showReconciled,
editingName: false,
isAdding: false,
latestDate: null,
Expand Down Expand Up @@ -359,6 +360,11 @@ class AccountInternal extends PureComponent {
this.paged.unsubscribe();
}

// Filter out reconciled transactions if necessary.
if (!this.state.showReconciled) {
query = query.filter({ reconciled: { $eq: false } });
}

this.paged = pagedQuery(
query.select('*'),
async (data, prevData) => {
Expand Down Expand Up @@ -420,6 +426,7 @@ class AccountInternal extends PureComponent {
showBalances: nextProps.showBalances,
balances: null,
showCleared: nextProps.showCleared,
showReconciled: nextProps.showReconciled,
reconcileAmount: null,
},
() => {
Expand Down Expand Up @@ -651,6 +658,19 @@ class AccountInternal extends PureComponent {
this.setState({ showCleared: true });
}
break;
case 'toggle-reconciled':
if (this.state.showReconciled) {
this.props.savePrefs({ ['hide-reconciled-' + accountId]: true });
this.setState({ showReconciled: false }, () =>
this.fetchTransactions(this.state.filters),
);
} else {
this.props.savePrefs({ ['hide-reconciled-' + accountId]: false });
this.setState({ showReconciled: true }, () =>
this.fetchTransactions(this.state.filters),
);
}
break;
default:
}
};
Expand Down Expand Up @@ -1404,6 +1424,7 @@ class AccountInternal extends PureComponent {
showBalances,
balances,
showCleared,
showReconciled,
} = this.state;

const account = accounts.find(account => account.id === accountId);
Expand Down Expand Up @@ -1462,6 +1483,7 @@ class AccountInternal extends PureComponent {
showBalances={showBalances}
showExtraBalances={showExtraBalances}
showCleared={showCleared}
showReconciled={showReconciled}
showEmptyMessage={showEmptyMessage}
balanceQuery={balanceQuery}
canCalculateBalance={this.canCalculateBalance}
Expand Down Expand Up @@ -1605,6 +1627,7 @@ export function Account() {
const [expandSplits] = useLocalPref('expand-splits');
const [showBalances] = useLocalPref(`show-balances-${params.id}`);
const [hideCleared] = useLocalPref(`hide-cleared-${params.id}`);
const [hideReconciled] = useLocalPref(`hide-reconciled-${params.id}`);
const [showExtraBalances] = useLocalPref(
`show-extra-balances-${params.id || 'all-accounts'}`,
);
Expand All @@ -1626,6 +1649,7 @@ export function Account() {
expandSplits,
showBalances,
showCleared: !hideCleared,
showReconciled: !hideReconciled,
showExtraBalances,
payees,
modalShowing,
Expand Down
8 changes: 8 additions & 0 deletions packages/desktop-client/src/components/accounts/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function AccountHeader({
showBalances,
showExtraBalances,
showCleared,
showReconciled,
showEmptyMessage,
balanceQuery,
reconcileAmount,
Expand Down Expand Up @@ -323,6 +324,7 @@ export function AccountHeader({
isSorted={isSorted}
showBalances={showBalances}
showCleared={showCleared}
showReconciled={showReconciled}
onMenuSelect={item => {
setMenuOpen(false);
onMenuSelect(item);
Expand Down Expand Up @@ -382,6 +384,7 @@ function AccountMenu({
showBalances,
canShowBalances,
showCleared,
showReconciled,
onClose,
isSorted,
onReconcile,
Expand Down Expand Up @@ -419,6 +422,11 @@ function AccountMenu({
name: 'toggle-cleared',
text: (showCleared ? 'Hide' : 'Show') + ' “cleared” checkboxes',
},
{
name: 'toggle-reconciled',
text:
(showReconciled ? 'Hide' : 'Show') + ' reconciled transactions',
},
{ name: 'export', text: 'Export' },
{ name: 'reconcile', text: 'Reconcile' },
account &&
Expand Down
1 change: 1 addition & 0 deletions packages/loot-core/src/types/prefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type LocalPrefs = Partial<
'expand-splits': boolean;
[key: `show-extra-balances-${string}`]: boolean;
[key: `hide-cleared-${string}`]: boolean;
[key: `hide-reconciled-${string}`]: boolean;
'budget.collapsed': string[];
'budget.summaryCollapsed': boolean;
'budget.showHiddenCategories': boolean;
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/2542.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Features
authors: [davidkus]
---

Adding menu item to show/hide reconciled transactions in the account view.

0 comments on commit 66dc593

Please sign in to comment.