Skip to content

Commit

Permalink
Show accurate balances when hiding reconciled transactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
wysinder committed Oct 8, 2024
1 parent bdeb194 commit 28dc971
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 4 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,9 @@ 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())) {

Check warning on line 491 in packages/desktop-client/src/components/accounts/Account.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `!this.state.showReconciled·&&·(!this.state.showBalances·||·!this.canCalculateBalance())` with `⏎······!this.state.showReconciled·&&⏎······(!this.state.showBalances·||·!this.canCalculateBalance())⏎····`
query = query.filter({ reconciled: { $eq: false } });
}

Expand Down Expand Up @@ -1746,6 +1747,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,12 @@ 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),

Check warning on line 1814 in packages/desktop-client/src/components/transactions/TransactionsTable.jsx

View workflow job for this annotation

GitHub Actions / lint

Replace `·props.showReconciled·?·props.transactions` with `⏎······props.showReconciled⏎········?·props.transactions⏎·······`
[props.transactions, props.showReconciled]

Check warning on line 1815 in packages/desktop-client/src/components/transactions/TransactionsTable.jsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
);

const renderRow = ({ item, index, editing }) => {
const {
transactions,
Expand Down Expand Up @@ -1982,7 +1988,7 @@ function TransactionTableInner({
navigator={tableNavigator}
ref={tableRef}
listContainerRef={listContainerRef}
items={props.transactions}
items={transactionsToRender}
renderItem={renderRow}
renderEmpty={renderEmpty}
loadMore={props.loadMoreTransactions}
Expand Down

0 comments on commit 28dc971

Please sign in to comment.