Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2703 - Fixes inaccurate running balance when hiding reconciled transactions #3603

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/desktop-client/src/components/accounts/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,12 @@ class AccountInternal extends PureComponent<
this.paged.unsubscribe();
}

// Filter out reconciled transactions if necessary.
if (!this.state.showReconciled) {
// Filter out reconciled transactions if they are hidden
// and we're not showing balances.
if (
!this.state.showReconciled &&
(!this.state.showBalances || !this.canCalculateBalance())
) {
query = query.filter({ reconciled: { $eq: false } });
}

Expand Down Expand Up @@ -1746,6 +1750,7 @@ class AccountInternal extends PureComponent<
payees={payees}
balances={allBalances}
showBalances={!!allBalances}
showReconciled={showReconciled}
showCleared={showCleared}
showAccount={
!accountId ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function TransactionList({
payees,
balances,
showBalances,
showReconciled,
showCleared,
showAccount,
headerContent,
Expand Down Expand Up @@ -203,8 +204,9 @@ export function TransactionList({
accounts={accounts}
categoryGroups={categoryGroups}
payees={payees}
showBalances={showBalances}
balances={balances}
showBalances={showBalances}
showReconciled={showReconciled}
showCleared={showCleared}
showAccount={showAccount}
showCategory={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,15 @@ function TransactionTableInner({
}
}, [isAddingPrev, props.isAdding, newNavigator]);

// Don't render reconciled transactions if we're hiding them.
const transactionsToRender = useMemo(
() =>
props.showReconciled
? props.transactions
: props.transactions.filter(t => !t.reconciled),
[props.transactions, props.showReconciled],
);

const renderRow = ({ item, index, editing }) => {
const {
transactions,
Expand Down Expand Up @@ -1982,7 +1991,7 @@ function TransactionTableInner({
navigator={tableNavigator}
ref={tableRef}
listContainerRef={listContainerRef}
items={props.transactions}
items={transactionsToRender}
renderItem={renderRow}
renderEmpty={renderEmpty}
loadMore={props.loadMoreTransactions}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3603.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [wysinder]
---

Fixes inaccurate running balance when hiding reconciled transactions