diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 4e949a465b9..6e00fcb98f9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: '19' - name: Check migrations diff --git a/.github/workflows/issues-feature-implemented.yml b/.github/workflows/issues-feature-implemented.yml index 039ee5e500b..4c8bf1ea7f2 100644 --- a/.github/workflows/issues-feature-implemented.yml +++ b/.github/workflows/issues-feature-implemented.yml @@ -25,7 +25,7 @@ jobs: steps: # This is not a security concern because we have approved & merged the PR - uses: actions/checkout@v3 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: node-version: '19' - name: Handle feature requests diff --git a/packages/desktop-client/src/components/accounts/Account.js b/packages/desktop-client/src/components/accounts/Account.js index 7332c4cfdc0..638159a16b6 100644 --- a/packages/desktop-client/src/components/accounts/Account.js +++ b/packages/desktop-client/src/components/accounts/Account.js @@ -15,6 +15,7 @@ import * as queries from 'loot-core/src/client/queries'; import q, { runQuery, pagedQuery } from 'loot-core/src/client/query-helpers'; import { send, listen } from 'loot-core/src/platform/client/fetch'; import { currentDay } from 'loot-core/src/shared/months'; +import { getScheduledAmount } from 'loot-core/src/shared/schedules'; import { deleteTransaction, updateTransaction, @@ -137,7 +138,7 @@ function AllTransactions({ .map(scheduledTransaction => { let amount = (scheduledTransaction._inverse ? -1 : 1) * - scheduledTransaction.amount; + getScheduledAmount(scheduledTransaction.amount); return { balance: (runningBalance += amount), id: scheduledTransaction.id, diff --git a/packages/desktop-client/src/components/accounts/Balance.js b/packages/desktop-client/src/components/accounts/Balance.js index 8a2b7dde72b..700e2683d33 100644 --- a/packages/desktop-client/src/components/accounts/Balance.js +++ b/packages/desktop-client/src/components/accounts/Balance.js @@ -2,6 +2,7 @@ import React from 'react'; import { useCachedSchedules } from 'loot-core/src/client/data-hooks/schedules'; import q from 'loot-core/src/client/query-helpers'; +import { getScheduledAmount } from 'loot-core/src/shared/schedules'; import { useSelectedItems } from '../../hooks/useSelected'; import ArrowButtonRight1 from '../../icons/v2/ArrowButtonRight1'; @@ -15,7 +16,7 @@ import format from '../spreadsheet/format'; import useSheetValue from '../spreadsheet/useSheetValue'; import { isPreviewId } from '../transactions/TransactionsTable'; -function DetailedBalance({ name, balance }) { +function DetailedBalance({ name, balance, isExactBalance = true }) { return ( {name}{' '} - {format(balance, 'financial')} + + {!isExactBalance && '~ '} + {format(balance, 'financial')} + ); @@ -63,12 +67,19 @@ function SelectedBalance({ selectedItems, account }) { let previewIds = [...selectedItems] .filter(id => isPreviewId(id)) .map(id => id.slice(8)); + let isExactBalance = true; + for (let s of schedules) { if (previewIds.includes(s.id)) { + // If a schedule is `between X and Y` then we calculate the average + if (s._amountOp === 'isbetween') { + isExactBalance = false; + } + if (!account || account.id === s._account) { - scheduleBalance += s._amount; + scheduleBalance += getScheduledAmount(s._amount); } else { - scheduleBalance -= s._amount; + scheduleBalance -= getScheduledAmount(s._amount); } } } @@ -83,7 +94,13 @@ function SelectedBalance({ selectedItems, account }) { balance += scheduleBalance; } - return ; + return ( + + ); } function MoreBalances({ balanceQuery }) { diff --git a/upcoming-release-notes/1473.md b/upcoming-release-notes/1473.md new file mode 100644 index 00000000000..ee5b1f7588e --- /dev/null +++ b/upcoming-release-notes/1473.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [MatissJanis] +--- + +Fix approximate schedule values showing in balance pill when selected