Skip to content

A local-first personal finance app

Mobile - Add cleared and uncleared Balances in Account Details (#2056)

HansiWursti4fb55d0d70ba
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-5-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-5-chromium-linux.png
index ee3954dd3f..5e5f6c3feb 100644
Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-5-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-5-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-6-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-6-chromium-linux.png
index 136f760a31..4de0dfb489 100644
Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-6-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-6-chromium-linux.png differ
diff --git a/packages/desktop-client/src/components/accounts/MobileAccount.jsx b/packages/desktop-client/src/components/accounts/MobileAccount.jsx
index f0a1f4ae5e..37285271bd 100644
--- a/packages/desktop-client/src/components/accounts/MobileAccount.jsx
+++ b/packages/desktop-client/src/components/accounts/MobileAccount.jsx
@@ -190,6 +190,8 @@ export function Account(props) {
};
const balance = queries.accountBalance(account);
+ const balanceCleared = queries.accountBalanceCleared(account);
+ const balanceUncleared = queries.accountBalanceUncleared(account);
const numberFormat = state.prefs.numberFormat || 'comma-dot';
const hideFraction = state.prefs.hideFraction || false;
@@ -213,6 +215,8 @@ export function Account(props) {
transactions={transactions}
prependTransactions={prependTransactions || []}
balance={balance}
+ balanceCleared={balanceCleared}
+ balanceUncleared={balanceUncleared}
isNewTransaction={isNewTransaction}
onLoadMore={() => {
paged?.fetchNext();
diff --git a/packages/desktop-client/src/components/accounts/MobileAccountDetails.jsx b/packages/desktop-client/src/components/accounts/MobileAccountDetails.jsx
index 7cea68bbd5..3dc2c8e142 100644
--- a/packages/desktop-client/src/components/accounts/MobileAccountDetails.jsx
+++ b/packages/desktop-client/src/components/accounts/MobileAccountDetails.jsx
@@ -12,6 +12,7 @@ import { MobileBackButton } from '../MobileBackButton';
import { Page } from '../Page';
import { PullToRefresh } from '../responsive/PullToRefresh';
import { CellValue } from '../spreadsheet/CellValue';
+import { useSheetValue } from '../spreadsheet/useSheetValue';
import { TransactionList } from '../transactions/MobileTransaction';
function TransactionSearchInput({ accountName, onSearch }) {
@@ -69,6 +70,8 @@ export function AccountDetails({
categories,
payees,
balance,
+ balanceCleared,
+ balanceUncleared,
isNewTransaction,
onLoadMore,
onSearch,
@@ -120,19 +123,75 @@ export function AccountDetails({
marginTop: 10,
}}
>
- <Label title="BALANCE" />
- <CellValue
- binding={balance}
- type="financial"
+ <View
style={{
- fontSize: 18,
- fontWeight: '500',
+ flexDirection: 'row',
+ boxSizing: 'content-box',
+ width: '100%',
+ justifyContent: 'space-evenly',
}}
- getStyle={value => ({
- color: value < 0 ? theme.errorText : theme.pillTextHighlighted,
- })}
- data-testid="account-balance"
- />
+ >
+ <View
+ style={{
+ visibility:
+ useSheetValue(balanceUncleared) === 0 ? 'hidden' : 'visible',
+ width: '33%',
+ }}
+ >
+ <Label
+ title="CLEARED"
+ style={{ textAlign: 'center', fontSize: 12 }}
+ />
+ <CellValue
+ binding={balanceCleared}
+ type="financial"
+ style={{
+ fontSize: 12,
+ textAlign: 'center',
+ fontWeight: '500',
+ }}
+ data-testid="account-balance-cleared"
+ />
+ </View>
+ <View style={{ width: '33%' }}>
+ <Label title="BALANCE" style={{ textAlign: 'center' }} />
+ <CellValue
+ binding={balance}
+ type="financial"
+ style={{
+ fontSize: 18,
+ textAlign: 'center',
+ fontWeight: '500',
+ }}
+ getStyle={value => ({
+ color: value < 0 ? theme.errorText : theme.pillTextHighlighted,
+ })}
+ data-testid="account-balance"
+ />
+ </View>
+ <View
+ style={{
+ visibility:
+ useSheetValue(balanceUncleared) === 0 ? 'hidden' : 'visible',
+ width: '33%',
+ }}
+ >
+ <Label
+ title="UNCLEARED"
+ style={{ textAlign: 'center', fontSize: 12 }}
+ />
+ <CellValue
+ binding={balanceUncleared}
+ type="financial"
+ style={{
+ fontSize: 12,
+ textAlign: 'center',
+ fontWeight: '500',
+ }}
+ data-testid="account-balance-uncleared"
+ />
+ </View>
+ </View>
<TransactionSearchInput
accountName={account.name}
onSearch={onSearch}
diff --git a/packages/loot-core/src/client/queries.ts b/packages/loot-core/src/client/queries.ts
index d74dbf8b8a..6a37151a38 100644
--- a/packages/loot-core/src/client/queries.ts
+++ b/packages/loot-core/src/client/queries.ts
@@ -103,6 +103,26 @@ export function accountBalance(acct) {
};
}
+export function accountBalanceCleared(acct) {
+ return {
+ name: `balanceCleared-${acct.id}`,
+ query: q('transactions')
+ .filter({ account: acct.id, cleared: true })
+ .options({ splits: 'none' })
+ .calculate({ $sum: '$amount' }),
+ };
+}
+
+export function accountBalanceUncleared(acct) {
+ return {
+ name: `balanceUncleared-${acct.id}`,
+ query: q('transactions')
+ .filter({ account: acct.id, cleared: false })
+ .options({ splits: 'none' })
+ .calculate({ $sum: '$amount' }),
+ };
+}
+
export function allAccountBalance() {
return {
query: q('transactions')
diff --git a/upcoming-release-notes/2056.md b/upcoming-release-notes/2056.md
new file mode 100644
index 0000000000..6ddbe6a839
--- /dev/null
+++ b/upcoming-release-notes/2056.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [HansiWursti]
+---
+
+Added cleared and uncleared Balances to Account Mobile View
\ No newline at end of file