mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-11 12:43:09 -05:00
🐛 (schedules) fix showing balance of approximate transactions (#1473)
Closes #1328 Closes #1471
This commit is contained in:
committed by
GitHub
parent
8ee4768f58
commit
e78430db62
2
.github/workflows/check.yml
vendored
2
.github/workflows/check.yml
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 (
|
||||
<Text
|
||||
style={{
|
||||
@@ -28,7 +29,10 @@ function DetailedBalance({ name, balance }) {
|
||||
>
|
||||
{name}{' '}
|
||||
<PrivacyFilter>
|
||||
<Text style={{ fontWeight: 600 }}>{format(balance, 'financial')}</Text>
|
||||
<Text style={{ fontWeight: 600 }}>
|
||||
{!isExactBalance && '~ '}
|
||||
{format(balance, 'financial')}
|
||||
</Text>
|
||||
</PrivacyFilter>
|
||||
</Text>
|
||||
);
|
||||
@@ -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 <DetailedBalance name="Selected balance:" balance={balance} />;
|
||||
return (
|
||||
<DetailedBalance
|
||||
name="Selected balance:"
|
||||
balance={balance}
|
||||
isExactBalance={isExactBalance}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function MoreBalances({ balanceQuery }) {
|
||||
|
||||
6
upcoming-release-notes/1473.md
Normal file
6
upcoming-release-notes/1473.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
category: Bugfix
|
||||
authors: [MatissJanis]
|
||||
---
|
||||
|
||||
Fix approximate schedule values showing in balance pill when selected
|
||||
Reference in New Issue
Block a user